1use crate::error::Severity;
19
20pub struct DiagnosticInfo {
24 pub code: &'static str,
25 pub summary: &'static str,
26 pub grammar_symbol: &'static [&'static str],
34 pub severity: Severity,
42}
43
44pub const BOOK_BASE_URL: &str = "https://bynk-lang.org";
48
49pub struct Explain {
64 pub code: &'static str,
67 pub blurb: &'static str,
70 pub example: &'static str,
72 pub page: &'static str,
77 pub anchor: &'static str,
79}
80
81impl Explain {
82 pub fn href(&self) -> String {
85 let mut url = format!("{BOOK_BASE_URL}{}/", self.page);
86 if !self.anchor.is_empty() {
87 url.push('#');
88 url.push_str(self.anchor);
89 }
90 url
91 }
92
93 pub fn in_site_link(&self) -> String {
99 let mut link = format!("{}/", self.page);
100 if !self.anchor.is_empty() {
101 link.push('#');
102 link.push_str(self.anchor);
103 }
104 link
105 }
106}
107
108pub const EXPLANATIONS: &[Explain] = &[
113 Explain {
114 code: "bynk.given.undeclared_capability",
115 blurb: "A handler may only use a capability it has itself declared with \
116 `given`. Effects in Bynk are explicit: the `given` clause is the \
117 handler's honest, checkable statement of every capability it \
118 reaches for, so a reader (and the compiler) can see a handler's \
119 full reach from its signature alone. Using a capability that is \
120 not in `given` is the missing half of that contract.",
121 example: "on get \"/now\" -> Text { // ✗ uses Clock without declaring it\n \
122 Clock.now()\n}\n\n\
123 on get \"/now\" given Clock -> Text { // ✓ declared, then used\n \
124 Clock.now()\n}",
125 page: "/book/guides/effects-and-capabilities/understand-the-capability-model",
126 anchor: "",
127 },
128 Explain {
129 code: "bynk.given.unknown_capability",
130 blurb: "A `given` clause names a capability that no provider declares. A \
131 capability is a typed interface to the outside world; it has to be \
132 *declared* (as a `capability`, or brought in from a consumed \
133 context) before a handler can ask for it. This usually means a \
134 typo in the capability name, or a missing `uses`/`consumes` that \
135 would bring the capability into scope.",
136 example: "on get \"/\" given Clok -> Text { … } // ✗ no capability named `Clok`\n\n\
137 on get \"/\" given Clock -> Text { … } // ✓ matches the declared capability",
138 page: "/book/reference/capabilities",
139 anchor: "declaring-a-capability",
140 },
141 Explain {
142 code: "bynk.http.error_status_position",
143 blurb: "An `ErrorStatus` name such as `Forbidden` stands for a status only as \
144 `RawError`'s first argument, where the compiler turns it into the \
145 number it answers. It is not a type, so a status can't be stored or \
146 passed to a helper. Name the status where the response is built, and \
147 let a helper build the body.",
148 example: "fn refusal(status: ErrorStatus, msg: String) -> HttpResult[()] { … } // ✗\n\n\
149 fn problem(msg: String) -> Bytes { Bytes.fromUtf8(msg) }\n\
150 RawError(Forbidden, problem(\"no access\"), \"text/plain\") // ✓",
151 page: "/book/reference/http",
152 anchor: "error-bodies",
153 },
154 Explain {
155 code: "bynk.http.raw_body_unbounded",
156 blurb: "A `@raw` route hands the handler its request body as untouched octets, \
157 buffered in memory up to a cap. With no cap there is no bound on that \
158 buffer, which is the denial of service request body limits exist to \
159 stop, so a raw route must have one: a `@limit(maxBody:)` on the \
160 handler, or a `limits { maxBody = … }` on the service.",
161 example: "@raw(contentType: \"image/png\") // ✗ no cap anywhere\n\
162 on POST(\"/avatars\") (body: Bytes) -> Effect[HttpResult[String]] { … }\n\n\
163 @raw(contentType: \"image/png\") // ✓ capped\n\
164 @limit(maxBody: 5_000_000)\n\
165 on POST(\"/avatars\") (body: Bytes) -> Effect[HttpResult[String]] { … }",
166 page: "/book/reference/http",
167 anchor: "raw-request-bodies",
168 },
169 Explain {
170 code: "bynk.provider.agent_call_undeclared_capability",
171 blurb: "A provider calls an agent handler, and the handler needs a capability \
172 the provider's `given` does not list. A handler's `given` is \
173 widened to cover the agent handlers it calls, but a provider's is \
174 not. The provider is constructed with exactly the capabilities in \
175 its `given`, and those are all it can hand on to the agent. So the \
176 provider must list everything the agent handler needs: the \
177 handler's own `given`, and the `given` of any agent handler it \
178 calls in turn.",
179 example: "agent Index {\n \
180 key name: String\n \
181 store hits: Cell[Int]\n \
182 on call withdraw() -> Effect[()] given Files { … }\n}\n\n\
183 provides Takedown = Bucket given Clock { // ✗ `withdraw` needs `Files`\n \
184 fn take(name: String) -> Effect[()] { Index(name).withdraw() }\n}\n\n\
185 provides Takedown = Bucket given Clock, Files { // ✓\n \
186 fn take(name: String) -> Effect[()] { Index(name).withdraw() }\n}",
187 page: "/book/guides/effects-and-capabilities/compose-a-provider",
188 anchor: "the-rules",
189 },
190 Explain {
191 code: "bynk.registry.withdrawn",
192 blurb: "Your `bynk.lock` locks a version that its registry has withdrawn. A \
193 withdrawal is a takedown — for a legal request or confirmed malware — \
194 so unlike a yank, which keeps a version for locked builds, the \
195 registry has deleted its archive and there is nothing to fetch. The \
196 message quotes the registry's reason. A machine that already has the \
197 tree in its store keeps building; elsewhere, move off the version \
198 with `bynk update` and the dependency's alias. The reason is unsigned, so when it was \
199 read through a mirror the message says the origin wasn't consulted.",
200 example: "error[bynk.registry.withdrawn]: `acme/money` 1.4.2 was withdrawn by \
201 registry `acme-internal`: \"removed at the copyright holder's request\"\n \
202 = note: `bynk.lock` locks this version; choose another with `bynk update money`\n\n\
203 $ bynk update money # resolves to the newest version not withdrawn",
204 page: "/book/guides/projects-build-and-deployment/run-a-private-registry",
205 anchor: "withdraw-a-version",
206 },
207 Explain {
208 code: "bynk.requires.unapproved",
209 blurb: "An adapter in a git or registry dependency requires an npm package \
210 your project hasn't approved. A dependency's adapters bring their \
211 npm packages into your build's `package.json`, and the next \
212 `npm install` runs whatever those packages run; so an npm package \
213 from someone else's code enters only after you approve it once. \
214 The approval is one package at one range, recorded in `bynk.lock` \
215 (`approved = true`), so a changed range asks again. Your own \
216 adapters and path dependencies need no approval.",
217 example: "# bynk.lock, as a fetch wrote it — the build fails until approved\n\
218 [[npm]]\npackage = \"jose\"\nrange = \"^5.2.0\"\n\
219 required-by = [\"acme/money:tokens\"]\n\n\
220 # after `bynk approve jose` — the build passes\n\
221 [[npm]]\npackage = \"jose\"\nrange = \"^5.2.0\"\n\
222 required-by = [\"acme/money:tokens\"]\napproved = true",
223 page: "/book/guides/projects-build-and-deployment/share-code-between-projects",
224 anchor: "approve-a-dependencys-npm-packages",
225 },
226 Explain {
227 code: "bynk.resolve.missing_field",
228 blurb: "A record must be constructed with every one of its fields. Bynk \
229 records have no defaults and no partial construction: a value of a \
230 record type is only valid once all its fields are present, so a \
231 downstream reader never has to wonder whether a field was set. \
232 Omitting a field is therefore an error, not a fill-in-later.",
233 example: "type User = { name: Text, age: Int }\n\n\
234 User { name: \"Ada\" } // ✗ missing `age`\n\
235 User { name: \"Ada\", age: 36 } // ✓ every field present",
236 page: "/book/reference/types",
237 anchor: "record-types",
238 },
239 Explain {
240 code: "bynk.resolve.unknown_field",
241 blurb: "A field access names a field the record type does not have. A \
242 record's fields are fixed by its type declaration; only those \
243 names exist on the value. This is usually a typo in the field \
244 name, or an access meant for a different type.",
245 example: "type User = { name: Text }\n\n\
246 user.nmae // ✗ no field `nmae`\n\
247 user.name // ✓ the declared field",
248 page: "/book/reference/types",
249 anchor: "record-types",
250 },
251 Explain {
252 code: "bynk.resolve.unknown_name",
253 blurb: "A name was referenced that is not in scope. Every name in Bynk \
254 must be introduced before use — as a `let` binding, a parameter, \
255 a `fn`, a type, or a member brought in through `uses`/`consumes`. \
256 An unknown name is typically a typo, a missing declaration, or a \
257 reference to something defined in a module that has not been \
258 brought into scope.",
259 example: "let greeting = \"hi\"\n\
260 greetng // ✗ no name `greetng` in scope\n\
261 greeting // ✓ the bound name",
262 page: "/book/guides/program-structure/how-a-program-is-shaped",
263 anchor: "",
264 },
265 Explain {
266 code: "bynk.resolve.unknown_type",
267 blurb: "A type name was referenced that does not exist. Types must be \
268 declared (with `type`), be one of Bynk's built-in types, or be \
269 brought into scope from another module before they can be named. \
270 An unknown type is usually a typo or a missing declaration/import.",
271 example: "fn greet(u: Usr) -> Text { … } // ✗ no type `Usr`\n\
272 fn greet(u: User) -> Text { … } // ✓ the declared type",
273 page: "/book/reference/types",
274 anchor: "",
275 },
276 Explain {
277 code: "bynk.types.claims_at_boundary",
278 blurb: "An `Oidc` actor's binder carries the verified token's claims (`who.claims`) for the \
279 handler that received the token. They are read there and never kept: a \
280 `TokenClaims` can't be a field, or cross a call, a message or an agent. Read the \
281 claim you need and keep that `String`.",
282 example: "type Seen = { claims: TokenClaims } // ✗\n\n\
283 let repo = w.claims.get(\"repository\") // ✓ keep the String",
284 page: "/book/reference/actors",
285 anchor: "reading-claims",
286 },
287];
288
289pub fn explain(code: &str) -> Option<&'static Explain> {
292 EXPLANATIONS.iter().find(|e| e.code == code)
293}
294
295pub const INDEX_PATH: &str = "/book/reference/diagnostics/";
298
299fn category_anchor(cat: &str) -> String {
303 category_title(cat)
304 .chars()
305 .filter_map(|c| match c {
306 ' ' => Some('-'),
307 c if c.is_alphanumeric() || c == '-' => Some(c.to_ascii_lowercase()),
308 _ => None,
309 })
310 .collect()
311}
312
313pub fn href(code: &str) -> String {
319 if let Some(e) = explain(code) {
320 return e.href();
321 }
322 let mut url = format!("{BOOK_BASE_URL}{INDEX_PATH}");
323 if lookup(code).is_some() {
324 url.push('#');
325 url.push_str(&category_anchor(category(code)));
326 }
327 url
328}
329
330pub fn lookup(code: &str) -> Option<&'static DiagnosticInfo> {
334 REGISTRY.iter().find(|d| d.code == code)
335}
336
337pub const REGISTRY: &[DiagnosticInfo] = &[
339 d(
340 "bynk.actor.bearer_identity_not_string_constructible",
341 "A `Bearer` actor's identity is not a string-constructible type.",
342 ),
343 d(
344 "bynk.actor.bearer_missing_secret",
345 "A `Bearer` actor does not name its signing secret.",
346 ),
347 d(
348 "bynk.actor.binder_shadows_param",
349 "A `by` actor binder collides with a handler parameter of the same name.",
350 ),
351 d(
352 "bynk.actor.by_on_agent",
353 "A `by` actor clause was placed on an agent `on call` handler, which has no actor.",
354 ),
355 d(
356 "bynk.actor.duplicate_sum_scheme",
357 "Two peers in a multi-actor sum share an authentication scheme.",
358 ),
359 d(
360 "bynk.actor.foreign_context_name_unkeyable",
361 "A context declaring a `Foreign` actor has a name no call key can be named from.",
362 ),
363 d(
364 "bynk.actor.foreign_duplicate_secret",
365 "A `Foreign` actor's secret is also another actor's secret in the same context.",
366 ),
367 d(
368 "bynk.actor.foreign_identity_unsupported",
369 "A `Foreign` actor declares an `identity`.",
370 ),
371 d(
372 "bynk.actor.foreign_missing_secret",
373 "A `Foreign` actor does not name the secret its calls are signed with.",
374 ),
375 d(
376 "bynk.actor.foreign_name_is_context_name",
377 "A `Foreign` actor's name could be read as a context's name.",
378 ),
379 d(
380 "bynk.actor.foreign_reserved_secret",
381 "A `Foreign` actor's secret uses a `BYNK_CALL_` edge key's name.",
382 ),
383 d(
384 "bynk.actor.foreign_secret_not_string",
385 "A `Foreign` actor's secret is not a string.",
386 ),
387 d(
388 "bynk.actor.identity_not_sealed",
389 "An actor identity type is not a context-ownable (sealed) value type.",
390 ),
391 d(
392 "bynk.actor.missing_by_on_http",
393 "An HTTP handler lacks the required `by` actor clause.",
394 ),
395 d(
396 "bynk.actor.oidc_identity_not_string_constructible",
397 "An `Oidc` actor's identity is not a string-constructible type.",
398 ),
399 d(
400 "bynk.actor.oidc_missing_audience",
401 "An `Oidc` actor does not name its `audience`.",
402 ),
403 d(
404 "bynk.actor.oidc_missing_issuer",
405 "An `Oidc` actor does not name its `issuer`.",
406 ),
407 d(
408 "bynk.actor.oidc_missing_jwks",
409 "An `Oidc` actor does not name its `jwks` endpoint.",
410 ),
411 d(
412 "bynk.actor.oidc_not_in_sum",
413 "An `Oidc` actor appears as a member of a multi-actor sum.",
414 ),
415 d(
416 "bynk.actor.oidc_trust_from_is_secret",
417 "An `Oidc` actor's `trustFrom` names an environment variable that an actor uses as its `secret`.",
418 ),
419 d(
420 "bynk.actor.oidc_trust_from_not_string",
421 "An `Oidc` actor's `trustFrom` isn't a string naming an environment variable.",
422 ),
423 d(
424 "bynk.actor.outside_context",
425 "An `actor` was declared outside a context (e.g. in a commons).",
426 ),
427 d(
428 "bynk.actor.refinement_base_unsupported",
429 "A refinement actor's base is not a `Bearer` actor (no claims to authorise against).",
430 ),
431 d(
432 "bynk.actor.refinement_in_sum",
433 "A refinement actor appears as a member of a multi-actor sum.",
434 ),
435 d(
436 "bynk.actor.refinement_predicate_unsupported",
437 "A refinement actor's `where` predicate is outside the closed claim-predicate set.",
438 ),
439 d(
440 "bynk.actor.scheme_not_admissible",
441 "An actor's scheme is not admissible on this handler's protocol.",
442 ),
443 d(
444 "bynk.actor.signature_identity_unsupported",
445 "A `Signature` actor declared an `identity`, which is not yet supported.",
446 ),
447 d(
448 "bynk.actor.signature_missing_header",
449 "A `Signature` actor does not name its signature header.",
450 ),
451 d(
452 "bynk.actor.signature_missing_secret",
453 "A `Signature` actor does not name its signing secret.",
454 ),
455 d(
456 "bynk.actor.signature_requires_body",
457 "A `Signature` handler does not take a `body` parameter.",
458 ),
459 d(
460 "bynk.actor.signature_tolerance_without_timestamp",
461 "A `Signature` actor set `tolerance` without a `timestamp` header.",
462 ),
463 d(
464 "bynk.actor.sum_requires_binder",
465 "A multi-actor sum `by` clause has no binder to match the resolved actor.",
466 ),
467 d(
468 "bynk.actor.unknown_actor",
469 "A handler's `by` clause names an actor that is not declared.",
470 ),
471 d(
472 "bynk.actor.unknown_scheme",
473 "An actor declares an authentication scheme that is not compiler-known.",
474 ),
475 d(
476 "bynk.actor.unreachable_sum_arm",
477 "A multi-actor sum has an arm unreachable after a catch-all (`None`) peer.",
478 ),
479 dg(
480 "bynk.adapter.consumes_context",
481 "An `adapter` consumed a context; adapter dependencies are adapter-to-adapter.",
482 &["consumes_decl"],
483 ),
484 dg(
485 "bynk.adapter.consumes_requires_selection",
486 "An `adapter` used a whole-unit or aliased `consumes`; adapters must select capabilities with `consumes U { Cap, … }`.",
487 &["consumes_decl"],
488 ),
489 dg(
490 "bynk.adapter.disallowed_item",
491 "An `adapter` declared a `service`, `agent`, or other item it may not contain.",
492 &["adapter_decl"],
493 ),
494 dg(
495 "bynk.adapter.duplicate_binding",
496 "An `adapter` declared more than one `binding` clause.",
497 &["binding_decl"],
498 ),
499 dg(
500 "bynk.adapter.include_duplicate",
501 "An adapter `binding … includes [ … ]` list names one file more than once.",
502 &["binding_decl"],
503 ),
504 dg(
505 "bynk.adapter.include_kind",
506 "An adapter `binding … includes [ … ]` entry is not a `.wasm` file; only WebAssembly modules can be included.",
507 &["binding_decl"],
508 ),
509 dg(
510 "bynk.adapter.include_missing",
511 "An adapter `binding … includes [ … ]` entry names a file that could not be read.",
512 &["binding_decl"],
513 ),
514 dg(
515 "bynk.adapter.include_outside",
516 "An adapter `binding … includes [ … ]` path is absolute or climbs out of the adapter's directory with `..`.",
517 &["binding_decl"],
518 ),
519 dg(
520 "bynk.adapter.no_binding",
521 "An `adapter` declares an external provider but no `binding` module to supply it.",
522 &["adapter_decl"],
523 ),
524 dg(
525 "bynk.adapter.provider_has_body",
526 "A provider inside an `adapter` has a Bynk body; adapter providers must be external.",
527 &["provider_decl"],
528 ),
529 d(
530 "bynk.agent.class_conflict",
531 "An agent class has more than one fate: it is renamed twice, both renamed and removed, or renamed onto a class that already has its own recorded history in `bynk.schema.lock`.",
532 ),
533 d(
534 "bynk.agent.class_removed",
535 "An agent class recorded in `bynk.schema.lock` is no longer declared, so a deployment's stored instances of it would be orphaned. If the class was never deployed, delete its `[agents]` entry from the lock; renaming or removing a deployed class gets its own declaration in a later state-migrations slice.",
536 ),
537 dg(
538 "bynk.agent.construction_arity",
539 "An agent was constructed with the wrong number of key arguments.",
540 &["agent_decl"],
541 ),
542 dg(
543 "bynk.agent.handler_arity",
544 "An agent handler was called with the wrong number of arguments.",
545 &["agent_decl"],
546 ),
547 dg(
548 "bynk.agent.handler_not_found",
549 "Called a handler the agent does not declare.",
550 &["agent_decl"],
551 ),
552 dg(
553 "bynk.agent.key_mismatch",
554 "An agent key argument has the wrong type.",
555 &["agent_decl"],
556 ),
557 warn(d(
558 "bynk.agent.migrate_below_floor",
559 "A `migrate` step reads a schema version below the agent's floor. A complete `bynk migrate sweep` raised the floor past it, so no stored instance can hold that version: the step emits nothing and can be deleted (warning).",
560 )),
561 d(
562 "bynk.agent.migrate_duplicate",
563 "Two `migrate` steps in one agent read the same schema version.",
564 ),
565 d(
566 "bynk.agent.migrate_duplicate_assignment",
567 "A `migrate` step assigns the same `store` field more than once; each field takes at most one value per step (record-literal semantics).",
568 ),
569 d(
570 "bynk.agent.migrate_impure",
571 "A `migrate` step uses an effect, a capability, `?`, `expect`, or the agent's `key`; steps are pure and key-free so a migration sweep can run them by object ID.",
572 ),
573 d(
574 "bynk.agent.migrate_incomplete",
575 "A `migrate` step does not account for every change between its version and the current shape: a removed field must be read (`old.f`) or dropped, and a retyped or re-kinded field must be assigned (or dropped, for a `Set`, `Log` or `Cache` field).",
576 ),
577 d(
578 "bynk.agent.migrate_shape_mismatch",
579 "A `migrate` step's declared old shape (or a `drop`) names a field the lock does not record at that version, or records with a different structure.",
580 ),
581 d(
582 "bynk.agent.migrate_unknown_version",
583 "A `migrate` step reads a schema version the lock does not record below the agent's current version.",
584 ),
585 d(
586 "bynk.agent.non_additive_state_change",
587 "An agent's stored state changed in a way deployed data cannot be read through — a `store` field was removed, retyped (including inside a stored record or sum), or changed storage kind. A renamed field is a removed field plus an added one. If the class was never deployed, delete its `[agents]` entry from `bynk.schema.lock`; otherwise widen rather than narrow, or stage the change through a new field.",
588 ),
589 dg(
590 "bynk.agent.outside_context",
591 "An `agent` was declared outside a context.",
592 &["agent_decl"],
593 ),
594 warn(d(
595 "bynk.agent.refinement_changed",
596 "A stored `store` field's refinement changed while its structure did not. A widening is safe; a narrowing faults on load for any stored value that no longer satisfies it (`RehydrationViolation`), so migrate the data first (warning).",
597 )),
598 d(
599 "bynk.agent.removed_live",
600 "A `removed agent` declaration names a class that is still declared; removing a class deletes its stored data.",
601 ),
602 d(
603 "bynk.agent.replaces_live",
604 "`agent New replaces Old` names an `Old` that is still declared; a rename moves the old class's data to the new one.",
605 ),
606 d(
607 "bynk.agent.replaces_unknown",
608 "`agent New replaces Old` names an `Old` that `bynk.schema.lock` does not record for this context, so there is no recorded class to rename.",
609 ),
610 dg(
611 "bynk.agent.return_not_effect",
612 "An agent handler's return type is not an `Effect`.",
613 &["agent_decl"],
614 ),
615 d(
616 "bynk.agent.state_name_conflict",
617 "A type is named `<Agent>State` beside agent `<Agent>`; that name is the agent's state record (its `Cell` fields), which its handlers and invariants see in place of the type.",
618 ),
619 warn(d(
620 "bynk.agent.version_without_path",
621 "A schema version between the agent's floor and its current version has no way forward: no `migrate` step covers it and its path to the current shape is not entirely additive, so a stored record at that version faults on load with `NoMigrationPath` (warning).",
622 )),
623 dg(
624 "bynk.agents.bad_state_initialiser",
625 "An agent `store` field initialiser is not a static value of the field's type.",
626 &["store_field"],
627 ),
628 dg(
629 "bynk.agents.non_zeroable_state_field",
630 "An agent `store` field has no initialiser and no implicit zero value.",
631 &["store_field"],
632 ),
633 d(
634 "bynk.asset.duplicate",
635 "An `asset` name is declared more than once in the same unit.",
636 ),
637 d(
638 "bynk.asset.invalid_at_path",
639 "An `asset`'s `at` path is not a URL path naming one file, or lies under `/_assets/` or `/_bynk/`.",
640 ),
641 warn(d(
642 "bynk.asset.may_shadow_route",
643 "A parameterised HTTP route matches a fixed asset path, so it never sees requests for that path (a warning).",
644 )),
645 d(
646 "bynk.asset.missing_file",
647 "An `asset` names a file that is not in the project's `assets/` folder.",
648 ),
649 d(
650 "bynk.asset.needs_project",
651 "A single-file build met an `asset` declaration; assets need a project build.",
652 ),
653 warn(d(
654 "bynk.asset.not_served",
655 "A deployable Bundle build met an `asset`; a Bundle ships no files, so its `.url` would not be served (a warning).",
656 )),
657 d(
658 "bynk.asset.outside_assets_dir",
659 "An `asset` path does not name a file in the project's `assets/` folder.",
660 ),
661 d(
662 "bynk.asset.outside_context_or_commons",
663 "An `asset` declaration appears outside a context or commons.",
664 ),
665 d(
666 "bynk.asset.path_conflict",
667 "Two different asset files would be served at one fixed path by the same Worker.",
668 ),
669 d(
670 "bynk.asset.shadows_route",
671 "A fixed asset path equals a literal HTTP route, which the platform-served asset makes unreachable.",
672 ),
673 d(
674 "bynk.asset.unreadable_file",
675 "An `asset` names a file in the project's `assets/` folder that could not be read.",
676 ),
677 d(
678 "bynk.asset.unsafe_path",
679 "An `asset` path is empty, absolute, or contains a `..` segment.",
680 ),
681 d(
682 "bynk.boundary.ambiguous_type",
683 "A value's type is declared, with different shapes, by more than one consumed context, so its fields cannot be read.",
684 ),
685 d(
686 "bynk.boundary.structural_mismatch",
687 "Data crossing a context boundary did not match the expected shape.",
688 ),
689 dg(
690 "bynk.capability.base_not_instantiable",
691 "A derived capability's base is not a platform resource that can be instantiated.",
692 &["capability_decl"],
693 ),
694 dg(
695 "bynk.capability.derived_outside_context",
696 "A derived capability was declared outside a context.",
697 &["capability_decl"],
698 ),
699 dg(
700 "bynk.capability.instance_only",
701 "A platform capability that is used only through named instances (`Service`, `R2`, `RateLimit`, `EdgeCache`) was used bare, in a `given` clause.",
702 &["given_clause"],
703 ),
704 dg(
705 "bynk.capability.invalid_option",
706 "A derived capability's option is not one string literal, is given twice, or (`@worker`) is not a Worker name outside the project.",
707 &["capability_decl"],
708 ),
709 dg(
710 "bynk.capability.missing_option",
711 "A derived capability lacks an option its base requires, such as a `Service` instance's `@worker`.",
712 &["capability_decl"],
713 ),
714 dg(
715 "bynk.capability.not_provided",
716 "On the Workers target, a capability a context requires has no provider in it.",
717 &["given_clause"],
718 ),
719 dg(
720 "bynk.capability.op_arity",
721 "A capability operation was called with the wrong number of arguments.",
722 &["capability_decl"],
723 ),
724 dg(
725 "bynk.capability.outside_context",
726 "A `capability` was declared outside a context.",
727 &["capability_decl"],
728 ),
729 dg(
730 "bynk.capability.provider_agent_cross_context",
731 "On the Workers target, a context requires a capability whose provider, in another context, constructs that context's agents; the consumer's Worker would build the provider without a binding for those agents' Durable Objects.",
732 &["given_clause"],
733 ),
734 dg(
735 "bynk.capability.unknown_base",
736 "A derived capability's base is not a capability the context consumes.",
737 &["capability_decl"],
738 ),
739 dg(
740 "bynk.capability.unknown_operation",
741 "Referenced an operation the capability does not declare.",
742 &["capability_decl"],
743 ),
744 dg(
745 "bynk.capability.unknown_option",
746 "A derived capability carries an option its base does not take.",
747 &["capability_decl"],
748 ),
749 d(
750 "bynk.cell.invalid_target",
751 "A `:=` write targets something that is not a `store Cell` field.",
752 ),
753 d(
754 "bynk.cell.self_reference",
755 "A `:=` right-hand side reads the cell being written (a read-modify-write); use `.update`.",
756 ),
757 d(
758 "bynk.cloudflare.edge_cache_duplicate",
759 "A context declares a second `EdgeCache` instance; the edge cache is one setting for the whole Worker.",
760 ),
761 d(
762 "bynk.cloudflare.edge_cache_exported",
763 "An exported capability reaches an `EdgeCache` instance through its provider's `given`; a consuming context would build it in its own Worker, whose purge misses this one's cache.",
764 ),
765 d(
766 "bynk.cloudflare.edge_cache_in_agent",
767 "An agent handler reaches an `EdgeCache` instance, directly or through a provider's `given`; an agent's purge would not reach the Worker's cache.",
768 ),
769 d(
770 "bynk.cloudflare.edge_cache_in_queue",
771 "A queue consumer reaches an `EdgeCache` instance; purge from a service handler instead.",
772 ),
773 d(
774 "bynk.cloudflare.edge_cache_in_schedule",
775 "An `on schedule` handler reaches an `EdgeCache` instance; a cron run's purge is accepted but clears nothing from the fetch cache, so purge from a service handler.",
776 ),
777 d(
778 "bynk.cloudflare.edge_cache_public_authenticated",
779 "In a context with `EdgeCache`, a `@cache(scope: public)` route is served by an actor that authenticates; its response would be shared at the edge with every caller.",
780 ),
781 dg(
782 "bynk.consumes.alias_conflict",
783 "Two `consumes` aliases collide.",
784 &["consumes_decl"],
785 ),
786 dg(
787 "bynk.consumes.capability_name_clash",
788 "Two flattened `consumes U { Cap }` capabilities collide, or one clashes with a local capability.",
789 &["consumes_decl"],
790 ),
791 dg(
792 "bynk.consumes.name_conflict",
793 "A `consumes` name collides with another name in scope.",
794 &["consumes_decl"],
795 ),
796 dg(
797 "bynk.consumes.self_reference",
798 "A context `consumes` itself.",
799 &["consumes_decl"],
800 ),
801 dg(
802 "bynk.consumes.service_arity",
803 "A consumed service was called with the wrong number of arguments.",
804 &["consumes_decl"],
805 ),
806 dg(
807 "bynk.consumes.signature_type_unconsumed",
808 "A cross-context call reaches a service whose signature names a type the consumed context itself consumes from a third context, which the caller does not consume.",
809 &["consumes_decl"],
810 ),
811 dg(
812 "bynk.consumes.target_is_commons",
813 "`consumes` targets a `commons` instead of a context.",
814 &["consumes_decl"],
815 ),
816 dg(
817 "bynk.consumes.unknown_context",
818 "`consumes` names a context that does not exist.",
819 &["consumes_decl"],
820 ),
821 dg(
822 "bynk.consumes.unknown_service",
823 "Called a service the consumed context does not declare.",
824 &["consumes_decl"],
825 ),
826 d(
827 "bynk.context.consumes_cycle",
828 "Contexts form a `consumes` dependency cycle.",
829 ),
830 d(
831 "bynk.context.duplicate_binding",
832 "A Worker would declare two bindings with the same name, such as an agent `Kv` and the `bynk.cloudflare` KV namespace (both `KV`).",
833 ),
834 d(
835 "bynk.context.external_construction",
836 "A context-owned type was constructed from outside that context.",
837 ),
838 d(
839 "bynk.context.external_decode",
840 "A context decoded a type another context owns and exports opaque, through `Json.decode`, `Json.decodeSql` or a `Codable` witness. Decoding creates a value, which only the owning context may do; its codec would check no more than the base type.",
841 ),
842 dg(
843 "bynk.context.external_provider",
844 "A bodiless (external) provider was declared outside an `adapter`.",
845 &["provider_decl"],
846 ),
847 d(
848 "bynk.context.opaque_inspection",
849 "An opaquely-exported type was inspected from outside its context.",
850 ),
851 d(
852 "bynk.context.rebrand_construction",
853 "A variant of a `uses`-sourced commons sum type was constructed directly inside a context, where the emitter's per-context rebrand leaves its constructors out of scope.",
854 ),
855 d(
856 "bynk.contract.duplicate_name",
857 "A function declares two contract clauses (`requires`/`ensures`) with the same name.",
858 ),
859 d(
860 "bynk.contract.impure_predicate",
861 "A contract predicate uses an effectful or test-only construct; a contract clause must be pure.",
862 ),
863 d(
864 "bynk.contract.not_bool",
865 "A contract predicate does not have type `Bool`.",
866 ),
867 d(
868 "bynk.contract.restated_by_test",
869 "A `case`/`property` merely restates a contract clause already declared at the function; the test is redundant.",
870 ),
871 d(
872 "bynk.contract.result_in_requires",
873 "A precondition (`requires`) references `result`; the return value is only in scope inside an `ensures`.",
874 ),
875 dg(
876 "bynk.cron.bad_params",
877 "A cron handler declares more than one parameter, or a non-`Int` one.",
878 &["cron_handler"],
879 ),
880 dg(
881 "bynk.cron.duplicate_schedule",
882 "Two cron handlers declare the same schedule.",
883 &["cron_handler"],
884 ),
885 dg(
886 "bynk.cron.invalid_schedule",
887 "A cron expression is not five whitespace-separated fields.",
888 &["cron_handler"],
889 ),
890 dg(
891 "bynk.cron.return_not_effect_result",
892 "A cron handler does not return `Effect[Result[(), E]]`.",
893 &["cron_handler"],
894 ),
895 d(
896 "bynk.d1.migration_name",
897 "A file in the project's `migrations/` folder isn't `migrations/<database>/NNNN_<name>.sql`, or shares its number with another migration of the same database.",
898 ),
899 d(
900 "bynk.d1.migration_unreadable",
901 "A `D1` migration in the project's `migrations/` folder can't be read, or isn't UTF-8 text.",
902 ),
903 warn(d(
904 "bynk.d1.migrations_unused",
905 "A directory in the project's `migrations/` folder matches no `D1` instance's database name, so its migrations are never applied, usually because the capability was renamed (warning).",
906 )),
907 d(
908 "bynk.dependency.path_outside_root",
909 "A path dependency declared by a dependency resolves outside the workspace; a dependency's own path dependencies are honoured only between members of one workspace.",
910 ),
911 d(
912 "bynk.deploy.contract_skew",
913 "A worker was compiled against a contract its live dependencies no longer provide, or no longer provides the contract its live callers were compiled against, so `bynk deploy --context` refuses to ship it.",
914 ),
915 d(
916 "bynk.deploy.foreign_contract_skew",
917 "A build breaks the contract a declared foreign caller's client was generated at, as pinned in `bynk.foreign.toml`, so `bynk deploy` refuses to ship it.",
918 ),
919 warn(d(
922 "bynk.doc.unresolved_link",
923 "A `[Name]` doc link resolves to nothing in the unit's scope (editor hint only).",
924 )),
925 d(
926 "bynk.duration.literal_overflow",
927 "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
928 ),
929 dg(
930 "bynk.effect.bind_in_pure_context",
931 "An `<-` bind was used in a pure (non-effectful) context.",
932 &["effect_let_stmt"],
933 ),
934 dg(
935 "bynk.effect.bind_on_non_effect",
936 "An `<-` bind was applied to a non-`Effect` value.",
937 &["effect_let_stmt"],
938 ),
939 d(
940 "bynk.effect.capability_in_pure_context",
941 "A capability was used in a pure context.",
942 ),
943 d(
944 "bynk.effect.cross_context_in_pure_context",
945 "A cross-context call was made in a pure context.",
946 ),
947 dg(
948 "bynk.effect.do_in_pure_context",
949 "A `do` statement was used in a pure (non-effectful) context.",
950 &["do_stmt"],
951 ),
952 dg(
953 "bynk.effect.do_on_non_effect",
954 "A `do` statement was applied to a non-`Effect` value.",
955 &["do_stmt"],
956 ),
957 dg(
958 "bynk.effect.do_requires_unit",
959 "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.",
960 &["do_stmt"],
961 ),
962 dg(
963 "bynk.effect.fn_value_in_pure_context",
964 "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
965 &["call"],
966 ),
967 d(
968 "bynk.effect.unbound_effect",
969 "An `Effect` value in an effectful body was built but not bound with `<-`, sequenced with `do` or returned — in a plain `let`, a list element or a constructor payload — so it runs eagerly and unawaited (#1658).",
970 ),
971 d(
972 "bynk.embed.binary_content",
973 "An `embed` names a file with a NUL byte, so it is binary, not text.",
974 ),
975 d(
976 "bynk.embed.duplicate",
977 "An `embed` name is declared more than once in the same unit.",
978 ),
979 d(
980 "bynk.embed.invalid_encoding",
981 "An `embed` names a file that is not valid UTF-8.",
982 ),
983 d(
984 "bynk.embed.missing_file",
985 "An `embed` names a file that is not in the project's `embeds/` folder.",
986 ),
987 d(
988 "bynk.embed.needs_project",
989 "A single-file build met an `embed` declaration, which needs a project's `embeds/` folder.",
990 ),
991 d(
992 "bynk.embed.outside_context_or_commons",
993 "An `embed` declaration appears outside a context or commons.",
994 ),
995 d(
996 "bynk.embed.outside_embeds_dir",
997 "An `embed` names a file outside the project's `embeds/` folder.",
998 ),
999 d(
1000 "bynk.embed.too_large",
1001 "An `embed` names a file over 256 KiB, or the project's embedded files total over 1 MiB.",
1002 ),
1003 d(
1004 "bynk.embed.unreadable_file",
1005 "An `embed` names a file in the project's `embeds/` folder that could not be read.",
1006 ),
1007 d(
1008 "bynk.embed.unsafe_path",
1009 "An `embed` path is empty, absolute, or contains a `..` segment.",
1010 ),
1011 d(
1012 "bynk.event.bad_params",
1013 "An `on event` handler declared the wrong number of parameters, or a second parameter whose type is not `EventEnvelope` — it takes the event payload and, optionally, the runtime envelope.",
1014 ),
1015 d(
1016 "bynk.event.bad_schema_dispatch",
1017 "A `via schema(...)` dispatch clause's argument is malformed — it must be a positive `Int` literal, a range of positive `Int` literals, or `_`.",
1018 ),
1019 d(
1020 "bynk.event.bad_schema_version",
1021 "An event's `@schema(N)` annotation is malformed — `N` must be a single, positive, positional `Int` literal, and `@schema` may appear at most once on an event.",
1022 ),
1023 dg(
1024 "bynk.event.duplicate_handler",
1025 "A `from Events` service declares more than one `on event` handler; it has exactly one.",
1026 &["event_handler"],
1027 ),
1028 d(
1029 "bynk.event.emit_not_an_event",
1030 "`Events.emit[E]` named a type `E` that is declared in this context, but is not itself an `event` — only an `event` type may be emitted.",
1031 ),
1032 d(
1033 "bynk.event.emit_outside_owner",
1034 "`Events.emit[E]` named an event `E` not declared in the emitting context — only an event's declaring context may emit it.",
1035 ),
1036 d(
1037 "bynk.event.handler_param_type_mismatch",
1038 "An `on event(e: T)` handler's declared parameter type does not match its `from Events(E)` header's event type.",
1039 ),
1040 d(
1041 "bynk.event.non_additive_schema_change",
1042 "An event's field shape changed in a way the schema registry cannot evolve additively — a field was removed, retyped, added without a default, or lost a default it previously had. Give the new shape a new event type name, or make the change additive.",
1043 ),
1044 d(
1045 "bynk.event.outside_context",
1046 "An `event` was declared outside a context.",
1047 ),
1048 d(
1049 "bynk.event.pattern_duplicate_field",
1050 "A `from Events(E { ... })` subscription pattern listed the same field more than once.",
1051 ),
1052 d(
1053 "bynk.event.pattern_type_mismatch",
1054 "A `from Events(E { ... })` subscription pattern field's matched value is not compatible with that field's declared type.",
1055 ),
1056 d(
1057 "bynk.event.pattern_unknown_field",
1058 "A `from Events(E { ... })` subscription pattern named a field that `E` does not declare.",
1059 ),
1060 d(
1061 "bynk.event.pattern_unknown_variant",
1062 "A `from Events(E { ... })` subscription pattern's variant value names a variant that does not exist on the field's declared sum type.",
1063 ),
1064 d(
1065 "bynk.event.pattern_variant_payload",
1066 "A `from Events(E { ... })` subscription pattern's variant value names a variant that carries a payload — only nullary variants are admitted, since testing the tag alone would silently ignore the payload.",
1067 ),
1068 dg(
1069 "bynk.event.return_not_effect_unit",
1070 "An `on event` handler returns an `Effect` of something other than `()`; emission is fire-and-forget, so it returns `Effect[()]`.",
1071 &["event_handler"],
1072 ),
1073 d(
1074 "bynk.event.schema_version_mismatch",
1075 "An event's `@schema(N)` annotation disagrees with the version the schema registry computes from the event's build history.",
1076 ),
1077 d(
1078 "bynk.event.unknown_annotation",
1079 "An `event` declaration carried an `@`-annotation other than `@schema` — event annotations are a closed set.",
1080 ),
1081 d(
1082 "bynk.event.unknown_subscription",
1083 "A `from Events(E)` subscription named `E`, which is not a declared event in this context or any consumed context.",
1084 ),
1085 d(
1086 "bynk.exec.unavailable",
1087 "A call to, or reference to, a function that hands work to the execution context (`~>`, `within` or `race`, directly or through the functions it calls) appears where no execution context exists: an agent handler, a WebSocket handler or a provider operation.",
1088 ),
1089 dg(
1090 "bynk.expect.faults_not_effect",
1091 "A fault claim's subject (`expect <call> faults`) is not an effectful call: a value, or a call whose type is not `Effect[_]`.",
1092 &["faults_expr"],
1093 ),
1094 dg(
1095 "bynk.expect.not_bool",
1096 "`expect` was given a non-`Bool` predicate.",
1097 &["expect_expr"],
1098 ),
1099 dg(
1100 "bynk.expect.outside_case",
1101 "`expect` was used outside a `case` body.",
1102 &["expect_expr"],
1103 ),
1104 dg(
1105 "bynk.exports.capability_not_provided",
1106 "An exported capability has no provider in its context.",
1107 &["exports_decl"],
1108 ),
1109 dg(
1110 "bynk.exports.conflicting_visibility",
1111 "A type is exported with conflicting visibilities.",
1112 &["exports_decl"],
1113 ),
1114 dg(
1115 "bynk.exports.derived_capability",
1116 "`exports capability` names a derived capability, whose instance stays with its context.",
1117 &["exports_decl"],
1118 ),
1119 dg(
1120 "bynk.exports.duplicate_export",
1121 "The same name is exported more than once.",
1122 &["exports_decl"],
1123 ),
1124 dg(
1125 "bynk.exports.duplicate_in_clause",
1126 "A name appears twice in one `exports` clause.",
1127 &["exports_decl"],
1128 ),
1129 dg(
1130 "bynk.exports.undeclared_capability",
1131 "`exports capability` names a capability that is not declared.",
1132 &["exports_decl"],
1133 ),
1134 dg(
1135 "bynk.exports.undeclared_type",
1136 "`exports` names a type that is not declared.",
1137 &["exports_decl"],
1138 ),
1139 warn(d(
1140 "bynk.fault.todo",
1141 "A `todo(message)` placeholder: the code type-checks but faults when it runs. A non-failing warning, so `check --deny-warnings` refuses unfinished code in CI (warning).",
1142 )),
1143 dg(
1144 "bynk.fixture.binary_content",
1145 "A suite's `fixture` names a file that contains a NUL byte, so it is binary, not text.",
1146 &["fixture_decl"],
1147 ),
1148 dg(
1149 "bynk.fixture.duplicate",
1150 "A suite declares two `fixture`s of the same name.",
1151 &["fixture_decl"],
1152 ),
1153 dg(
1154 "bynk.fixture.invalid_encoding",
1155 "A suite's `fixture` names a file that is not valid UTF-8.",
1156 &["fixture_decl"],
1157 ),
1158 dg(
1159 "bynk.fixture.missing_file",
1160 "A suite's `fixture` names a file that is not in the project's `fixtures/` folder.",
1161 &["fixture_decl"],
1162 ),
1163 dg(
1164 "bynk.fixture.outside_fixtures_dir",
1165 "A suite's `fixture` names a file outside the project's `fixtures/` folder.",
1166 &["fixture_decl"],
1167 ),
1168 dg(
1169 "bynk.fixture.too_large",
1170 "A suite's `fixture` names a file over the 4 MiB limit for one fixture file.",
1171 &["fixture_decl"],
1172 ),
1173 dg(
1174 "bynk.fixture.unreadable_file",
1175 "A suite's `fixture` names a listed file that could not be read.",
1176 &["fixture_decl"],
1177 ),
1178 dg(
1179 "bynk.fixture.unsafe_path",
1180 "A suite's `fixture` path is empty, absolute or contains a `..` segment.",
1181 &["fixture_decl"],
1182 ),
1183 warn(dg(
1184 "bynk.fixture.unused",
1185 "A suite declares a `fixture` that none of its cases, properties or helpers uses (warning).",
1186 &["fixture_decl"],
1187 )),
1188 d(
1189 "bynk.fmt.comment_loss",
1190 "The formatter would drop a comment, so it leaves the file unchanged.",
1191 ),
1192 d(
1193 "bynk.fmt.mixed_comment_syntax",
1194 "A file mixes the retired `--` comment or `--|` doc spellings with a line that reads differently under the old and new comment rules (#2203), so the formatter leaves it unchanged.",
1195 ),
1196 d(
1197 "bynk.fmt.roundtrip",
1198 "The formatter's output does not re-parse to the same program, so it leaves the file unchanged.",
1199 ),
1200 dg(
1201 "bynk.generics.ambiguous_instantiation",
1202 "A generic function with an `Ord` bound is used as a value, and its type arguments cannot be determined from the type expected at that reference; annotate the expected type (constrained-generics slice 1).",
1203 &["fn_decl"],
1204 ),
1205 dg(
1206 "bynk.generics.bound_on_capability_op",
1207 "A generic capability operation's type parameter carries a bound other than `Key` or `Codable`; operations take only those two (constrained-generics slices 2 and 3).",
1208 &["capability_op"],
1209 ),
1210 dg(
1211 "bynk.generics.codable_op_return",
1212 "A capability operation\'s `Codable` type parameter appears in its return type. A `Codable` parameter is encoded at the call site; decoding a provider\'s reply raises a question this slice does not answer (what a failed decode of stored data means), so typed reads are deferred (constrained-generics slice 3).",
1213 &["capability_op"],
1214 ),
1215 dg(
1216 "bynk.generics.duplicate_type_param",
1217 "A `type` or `fn` declares the same type-parameter name more than once (v0.157, ADR 0183).",
1218 &[],
1219 ),
1220 dg(
1221 "bynk.generics.generic_non_record",
1222 "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).",
1223 &["type_decl"],
1224 ),
1225 dg(
1226 "bynk.generics.generic_record_at_boundary",
1227 "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.",
1228 &[],
1229 ),
1230 dg(
1231 "bynk.generics.generic_sum_embeds",
1232 "A generic sum type carries an `embeds` clause; embedding into a generic sum is not supported (#593).",
1233 &["type_decl"],
1234 ),
1235 dg(
1236 "bynk.generics.method_on_generic_type",
1237 "A *static* method on a generic type never mentions one of the type's parameters in its parameter or return types, so no call could determine it from the arguments or the expected type. Mention the parameter in the signature, or make the method a free function (constrained-generics slice 4; instance methods are supported, #594).",
1238 &["fn_decl"],
1239 ),
1240 dg(
1241 "bynk.generics.missing_codable_bound",
1242 "A type parameter is encoded or decoded with `Json.encode`/`Json.decode`, or passed to a `Codable`-bounded parameter of another generic or of a capability operation, but is not declared `Codable` (`[T: Codable]`, or `where A: Codable` for a receiver type\'s parameter). The diagnostic carries a machine-applicable fix that declares `Codable`, beside an existing `Eq`, which `Codable` does not imply (constrained-generics slice 3).",
1243 &["fn_decl"],
1244 ),
1245 dg(
1246 "bynk.generics.missing_eq_bound",
1247 "A type parameter is compared with `==`/`!=`, or passed to an `Eq`-bounded parameter of another generic, but is not declared `Eq` (`[T: Eq]`, or `where A: Eq` for a receiver type's parameter). The diagnostic carries a machine-applicable fix (ADR 0430, amended by constrained-generics slice 0).",
1248 &["fn_decl"],
1249 ),
1250 dg(
1251 "bynk.generics.missing_key_bound",
1252 "A type parameter keys a `Map` or `Set` (a `Map` key, a `Set` element, a `distinct`/`groupBy`/join key), or is passed to a `Key`-bounded parameter of another generic, but is not declared `Key` (`[K: Key]`, or `where A: Key` for a receiver type's parameter; on the type for a generic type's own parameter). The diagnostic carries a machine-applicable fix that declares `Key`, replacing an existing `Eq`, which `Key` implies (constrained-generics slice 2).",
1253 &["fn_decl"],
1254 ),
1255 dg(
1256 "bynk.generics.missing_ord_bound",
1257 "A type parameter is ordered (`<`, `<=`, `>`, `>=`, an ordering kernel key), or passed to an `Ord`-bounded parameter of another generic, but is not declared `Ord` (`[T: Ord]`, or `where A: Ord` for a receiver type's parameter). The diagnostic carries a machine-applicable fix that declares `Ord`, replacing an existing `Eq`, which `Ord` implies (constrained-generics slice 1).",
1258 &["fn_decl"],
1259 ),
1260 dg(
1261 "bynk.generics.recursive_generic_at_boundary",
1262 "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).",
1263 &[],
1264 ),
1265 warn(dg(
1266 "bynk.generics.redundant_eq_bound",
1267 "A type parameter is declared both `Eq` and `Ord` (or `Eq` and `Key`); `Ord` and `Key` imply `Eq`, so the `Eq` is redundant. The diagnostic carries a machine-applicable fix that removes it (constrained-generics slices 1 and 2, warning).",
1268 &["fn_decl"],
1269 )),
1270 dg(
1271 "bynk.generics.type_arg_count",
1272 "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).",
1273 &["applied_type_ref"],
1274 ),
1275 dg(
1276 "bynk.generics.type_arg_mismatch",
1277 "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
1278 &["call"],
1279 ),
1280 dg(
1281 "bynk.generics.uninferable_type_arg",
1282 "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.",
1283 &["call"],
1284 ),
1285 dg(
1286 "bynk.generics.unknown_constraint",
1287 "A bound names something that is not a constraint; `Eq` is the only one.",
1288 &["type_param"],
1289 ),
1290 dg(
1291 "bynk.generics.unknown_where_param",
1292 "A method's `where` clause bounds a name that is not a type parameter of the method or of its receiver type.",
1293 &["where_clause"],
1294 ),
1295 dg(
1296 "bynk.given.cross_context_unknown_capability",
1297 "`given B.Cap` names a capability the consumed context does not export.",
1298 &["given_clause"],
1299 ),
1300 dg(
1301 "bynk.given.fn_outside_context",
1302 "A function in a commons (or a suite) declares `given`; only a context function can.",
1303 &["given_clause"],
1304 ),
1305 dg(
1306 "bynk.given.fn_unsupported",
1307 "A `given` clause on a method, on a function that does not return `Effect[T]`, or naming `Events`.",
1308 &["given_clause"],
1309 ),
1310 dg(
1311 "bynk.given.missing_for_call",
1312 "A call to a function that declares `given` from a body that does not declare those capabilities.",
1313 &["given_clause"],
1314 ),
1315 dg(
1316 "bynk.given.undeclared_capability",
1317 "A handler uses a capability it did not declare with `given`.",
1318 &["given_clause"],
1319 ),
1320 dg(
1321 "bynk.given.unknown_capability",
1322 "`given` names a capability that does not exist.",
1323 &["given_clause"],
1324 ),
1325 warn(dg(
1326 "bynk.given.unused_capability",
1327 "A `given` capability is never used (warning).",
1328 &["given_clause"],
1329 )),
1330 d(
1331 "bynk.held.branch_divergence",
1332 "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).",
1333 ),
1334 d(
1335 "bynk.held.consume_on_borrow",
1336 "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).",
1337 ),
1338 d(
1339 "bynk.held.leak",
1340 "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).",
1341 ),
1342 d(
1343 "bynk.held.query_accessor_on_held_map",
1344 "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.",
1345 ),
1346 d(
1347 "bynk.held.unsupported_map_op",
1348 "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).",
1349 ),
1350 d(
1351 "bynk.held.unsupported_storage",
1352 "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).",
1353 ),
1354 d(
1355 "bynk.held.use_after_consume",
1356 "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).",
1357 ),
1358 d(
1359 "bynk.history.not_an_agent",
1360 "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).",
1361 ),
1362 d(
1363 "bynk.history.not_generable",
1364 "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).",
1365 ),
1366 d(
1367 "bynk.history.outside_property",
1368 "`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).",
1369 ),
1370 d(
1371 "bynk.history.restates_invariant",
1372 "A history property merely re-checks a guarantee a declared `invariant`/`transition` already enforces on every reached state (testing track slice 7, ADR 0155).",
1373 ),
1374 dg(
1375 "bynk.http.body_on_get_or_delete",
1376 "A GET or DELETE handler declares a `body` parameter.",
1377 &["http_handler"],
1378 ),
1379 d(
1380 "bynk.http.cache_bad_immutable",
1381 "A `@cache` annotation's `immutable` is not a `Bool` literal.",
1382 ),
1383 d(
1384 "bynk.http.cache_bad_max_age",
1385 "A `@cache` annotation's `maxAge` is missing or not a positive `Duration` literal.",
1386 ),
1387 d(
1388 "bynk.http.cache_bad_scope",
1389 "A `@cache` annotation's `scope` is not `public` or `private`.",
1390 ),
1391 d(
1392 "bynk.http.cache_duplicate",
1393 "A handler carries more than one `@cache` annotation.",
1394 ),
1395 d(
1396 "bynk.http.cache_max_age_fractional_seconds",
1397 "A `@cache` annotation's `maxAge` is positive but does not resolve to a whole number of seconds.",
1398 ),
1399 d(
1400 "bynk.http.cache_on_non_get",
1401 "A `@cache` annotation is placed on a handler that is not `on http GET`.",
1402 ),
1403 d(
1404 "bynk.http.cache_unknown_arg",
1405 "A `@cache` annotation has an argument outside the closed set (`maxAge`/`scope`/`immutable`).",
1406 ),
1407 d(
1408 "bynk.http.cors_invalid_field",
1409 "A `cors` policy field (`headers`/`credentials`/`maxAge`) has the wrong value shape.",
1410 ),
1411 d(
1412 "bynk.http.cors_invalid_origins",
1413 "A `cors` policy's `origins` is missing, empty, or not a list of string literals.",
1414 ),
1415 d(
1416 "bynk.http.cors_not_http",
1417 "A `cors { }` policy appears on a service that is not `from http`.",
1418 ),
1419 d(
1420 "bynk.http.cors_unknown_field",
1421 "A `cors { }` policy declares a field outside the closed set.",
1422 ),
1423 d(
1424 "bynk.http.cors_wildcard_credentials",
1425 "A `cors` policy combines `credentials: true` with the wildcard origin `[\"*\"]`.",
1426 ),
1427 dg(
1428 "bynk.http.duplicate_rejected",
1429 "A `from http` service declares `on rejected` more than once.",
1430 &["rejected_handler"],
1431 ),
1432 dg(
1433 "bynk.http.duplicate_route",
1434 "Two handlers share the same method and route.",
1435 &["http_handler"],
1436 ),
1437 d(
1438 "bynk.http.error_status_position",
1439 "An `ErrorStatus` name is used anywhere but as `RawError`'s first argument.",
1440 ),
1441 dg(
1442 "bynk.http.extra_param",
1443 "A handler parameter is not a path parameter, `body`, `headers` or `query`.",
1444 &["http_handler"],
1445 ),
1446 dg(
1447 "bynk.http.headers_wrong_type",
1448 "An HTTP handler's `headers` parameter is not typed `RequestHeaders`.",
1449 &["http_handler"],
1450 ),
1451 dg(
1452 "bynk.http.invalid_path",
1453 "An HTTP route path is malformed.",
1454 &["http_handler"],
1455 ),
1456 d(
1457 "bynk.http.json_duplicate",
1458 "A handler carries more than one `@json` annotation.",
1459 ),
1460 d(
1461 "bynk.http.json_invalid_arg",
1462 "A `@json` annotation's `options` argument is missing or is not `tagged` or `plain`.",
1463 ),
1464 d(
1465 "bynk.http.json_invalid_field",
1466 "A `json { }` policy's `options` is not `tagged` or `plain`.",
1467 ),
1468 d(
1469 "bynk.http.json_not_http",
1470 "A `json { }` policy appears on a service that is not `from http`.",
1471 ),
1472 d(
1473 "bynk.http.json_on_non_http",
1474 "A `@json` annotation is placed on a handler that is not `on http`.",
1475 ),
1476 d(
1477 "bynk.http.json_unknown_arg",
1478 "A `@json` annotation has an argument outside the closed set (`options`).",
1479 ),
1480 d(
1481 "bynk.http.json_unknown_field",
1482 "A `json { }` policy declares a field outside the closed set (`options`).",
1483 ),
1484 d(
1485 "bynk.http.limit_bad_max_body",
1486 "A `@limit` annotation's `maxBody` is missing or not a positive `Int` literal.",
1487 ),
1488 d(
1489 "bynk.http.limit_duplicate",
1490 "A handler carries more than one `@limit` annotation.",
1491 ),
1492 d(
1493 "bynk.http.limit_on_bodyless",
1494 "A `@limit` annotation is placed on a handler that takes no body (a GET or DELETE).",
1495 ),
1496 d(
1497 "bynk.http.limit_unknown_arg",
1498 "A `@limit` annotation has an argument outside the closed set (`maxBody`).",
1499 ),
1500 d(
1501 "bynk.http.limits_invalid_field",
1502 "A `limits` policy field (`maxBody`) has the wrong value shape.",
1503 ),
1504 d(
1505 "bynk.http.limits_not_http",
1506 "A `limits { }` policy appears on a service that is not `from http`.",
1507 ),
1508 d(
1509 "bynk.http.limits_unknown_field",
1510 "A `limits { }` policy declares a field outside the closed set.",
1511 ),
1512 dg(
1513 "bynk.http.path_param_not_stringy",
1514 "A path parameter's type is not constructible from a string.",
1515 &["http_handler"],
1516 ),
1517 dg(
1518 "bynk.http.query_field_not_stringy",
1519 "A field of an HTTP handler's `query` record has a type a query string cannot carry.",
1520 &["http_handler"],
1521 ),
1522 dg(
1523 "bynk.http.query_not_http",
1524 "A `RequestQuery` appears on a handler that is not an HTTP route.",
1525 &["http_handler"],
1526 ),
1527 dg(
1528 "bynk.http.query_wrong_type",
1529 "An HTTP handler's `query` parameter is neither a record type nor `RequestQuery`.",
1530 &["http_handler"],
1531 ),
1532 d(
1533 "bynk.http.raw_bad_content_type",
1534 "A `@raw` annotation's `contentType` is missing or not a `type/subtype` (or `\"*/*\"`) string literal.",
1535 ),
1536 d(
1537 "bynk.http.raw_body_not_bytes",
1538 "The `body` of a `@raw` handler is not typed `Bytes`.",
1539 ),
1540 d(
1541 "bynk.http.raw_body_unbounded",
1542 "A `@raw` route has no request-body cap (no `@limit` and no service `limits`).",
1543 ),
1544 d(
1545 "bynk.http.raw_duplicate",
1546 "A handler carries more than one `@raw` annotation.",
1547 ),
1548 d(
1549 "bynk.http.raw_error_status",
1550 "`RawError`'s first argument is not an `ErrorStatus` name (a 4xx or 5xx `HttpResult` variant name).",
1551 ),
1552 d(
1553 "bynk.http.raw_on_bodyless",
1554 "A `@raw` annotation is placed on a handler that takes no body.",
1555 ),
1556 d(
1557 "bynk.http.raw_unknown_arg",
1558 "A `@raw` annotation has an argument outside the closed set (`contentType`).",
1559 ),
1560 dg(
1561 "bynk.http.rejected_signature",
1562 "An `on rejected` handler is not `on rejected(why: BoundaryRejection) -> HttpResult[()]` with no `by` and no `given`.",
1563 &["rejected_handler"],
1564 ),
1565 dg(
1566 "bynk.http.reserved_prefix",
1567 "A route uses the reserved `/_bynk/` prefix.",
1568 &["http_handler"],
1569 ),
1570 dg(
1571 "bynk.http.return_not_effect_http_result",
1572 "An HTTP handler does not return `Effect[HttpResult[T]]`.",
1573 &["http_handler"],
1574 ),
1575 d(
1576 "bynk.http.security_invalid_field",
1577 "A `security` policy field (`hsts`/`nosniff`) has the wrong value shape.",
1578 ),
1579 d(
1580 "bynk.http.security_not_http",
1581 "A `security { }` policy appears on a service that is not `from http`.",
1582 ),
1583 d(
1584 "bynk.http.security_unknown_field",
1585 "A `security { }` policy declares a field outside the closed set.",
1586 ),
1587 dg(
1588 "bynk.http.unbound_path_param",
1589 "A `:name` route segment has no matching handler parameter.",
1590 &["http_handler"],
1591 ),
1592 d(
1593 "bynk.http.unknown_handler_annotation",
1594 "A handler carries an annotation outside the closed set (`@cache`/`@limit`).",
1595 ),
1596 d(
1597 "bynk.index.bad_argument",
1598 "An `@indexed` argument is not a `by: <field>` label.",
1599 ),
1600 warn(d(
1601 "bynk.index.missing",
1602 "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
1603 )),
1604 d(
1605 "bynk.index.unkeyable_key",
1606 "An `@indexed(by: k)` field is not value-keyable.",
1607 ),
1608 d(
1609 "bynk.index.unknown_key",
1610 "An `@indexed(by: k)` field is not a field of the map's value type.",
1611 ),
1612 warn(d(
1613 "bynk.index.unused",
1614 "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
1615 )),
1616 d(
1617 "bynk.invariant.cross_agent_reference",
1618 "An invariant predicate references another agent; invariants are per-agent.",
1619 ),
1620 d(
1621 "bynk.invariant.duplicate_name",
1622 "An agent declares two invariants with the same name.",
1623 ),
1624 d(
1625 "bynk.invariant.impure_predicate",
1626 "An invariant predicate uses an effectful or test-only construct.",
1627 ),
1628 d(
1629 "bynk.invariant.not_bool",
1630 "An invariant predicate does not have type `Bool`.",
1631 ),
1632 d(
1633 "bynk.json.nested_option_plain",
1634 "A plain-JSON route's response type contains an `Option[U]` whose payload `U` can itself encode as `null` (`Option[T]` or `()`), so `Some(U)` and `None` would both be written `null`.",
1635 ),
1636 dg(
1637 "bynk.lambda.unannotated_param",
1638 "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
1639 &["lambda_expr"],
1640 ),
1641 dg(
1642 "bynk.lex.bad_escape",
1643 "An invalid escape sequence in a string literal.",
1644 &["string_literal"],
1645 ),
1646 dg(
1647 "bynk.lex.bad_unicode_escape",
1648 "A `\\u{…}` escape names a surrogate or a value above U+10FFFF.",
1649 &["string_literal"],
1650 ),
1651 dg(
1652 "bynk.lex.decimal_literal_too_large",
1653 "A decimal literal has more than 100 fraction digits or more than 1000 characters, the most any `Decimal` may have (#2622).",
1654 &["decimal_literal"],
1655 ),
1656 dg(
1657 "bynk.lex.float_literal_overflow",
1658 "A float literal does not fit a finite 64-bit float.",
1659 &["float_literal"],
1660 ),
1661 dg(
1662 "bynk.lex.integer_overflow",
1663 "An integer literal is outside the `Int` range, the JS safe integers ±(2^53 − 1).",
1664 &["number_literal"],
1665 ),
1666 dg(
1667 "bynk.lex.interpolation_too_deep",
1668 "A string interpolation `\\(…)` nests deeper than the lexer's fixed limit.",
1669 &["string_literal"],
1670 ),
1671 d(
1672 "bynk.lex.legacy_comment",
1673 "A `--` line comment, the spelling before #2203; a comment is `//` (auto-fixable; `bynk fmt` rewrites it).",
1674 ),
1675 d(
1676 "bynk.lex.legacy_doc_line",
1677 "A `--|` one-line doc, the spelling before #2203; a one-line doc is `--- text` (auto-fixable; `bynk fmt` rewrites it).",
1678 ),
1679 dg(
1680 "bynk.lex.multiline_close_not_own_line",
1681 "A `\"\"\"` inside a multi-line string literal is not on a line of its own.",
1682 &["string_literal"],
1683 ),
1684 dg(
1685 "bynk.lex.multiline_in_hole",
1686 "A multi-line string literal appears inside an interpolation hole, which must close on its own line.",
1687 &["string_literal"],
1688 ),
1689 dg(
1690 "bynk.lex.multiline_indent",
1691 "A line of a multi-line string literal is indented less than its closing `\"\"\"`.",
1692 &["string_literal"],
1693 ),
1694 dg(
1695 "bynk.lex.multiline_open",
1696 "The opening `\"\"\"` of a multi-line string literal is not followed by a newline.",
1697 &["string_literal"],
1698 ),
1699 d(
1700 "bynk.lex.slash_doc",
1701 "A `///` doc comment first on its line; a Bynk doc is `--- text` or a `---` block (auto-fixable).",
1702 ),
1703 d(
1704 "bynk.lex.unclosed_doc_block",
1705 "A documentation block is not closed.",
1706 ),
1707 d(
1708 "bynk.lex.unexpected_character",
1709 "An unexpected character in the source.",
1710 ),
1711 dg(
1712 "bynk.lex.unterminated_interpolation",
1713 "An interpolation hole `\\(…)` is not closed on its line.",
1714 &["string_literal"],
1715 ),
1716 dg(
1717 "bynk.lex.unterminated_string",
1718 "A string literal is not terminated.",
1719 &["string_literal"],
1720 ),
1721 warn(d(
1722 "bynk.list.deprecated_function",
1723 "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
1724 )),
1725 d(
1726 "bynk.locale.multiple_message_bundles",
1727 "A context consumes `Locale` but its direct `uses` reaches two or more message-bundle commons — there is no single bundle to negotiate against.",
1728 ),
1729 d(
1730 "bynk.messages.format_mismatch",
1731 "A code's placeholder is formatted as a different ICU kind (plain/plural/select/number/date) across declared locales.",
1732 ),
1733 d(
1734 "bynk.messages.incomplete",
1735 "A locale is missing a code the reference locale declares.",
1736 ),
1737 d(
1738 "bynk.messages.invalid_locale_tag",
1739 "A `messages` block's locale tag is not a valid `LocaleTag` (e.g. `messages \"xx\"` where `xx` doesn't match the tag pattern).",
1740 ),
1741 d(
1742 "bynk.messages.malformed_icu_syntax",
1743 "A message template's ICU placeholder syntax is invalid — unbalanced arm braces, an unknown format keyword, `#` outside a plural arm, a missing mandatory `other` arm, or an explicitly out-of-scope construct (`selectordinal`, `offset:`/`=N`, a CLDR skeleton).",
1744 ),
1745 d(
1746 "bynk.messages.missing_locale_dependency",
1747 "A commons declaring `messages` doesn't `uses bynk.locale` and/or `uses bynk.locale.types`, which its generated `render` and the types its signature names need.",
1748 ),
1749 d(
1750 "bynk.messages.missing_reference",
1751 "A message bundle has no `@reference` block.",
1752 ),
1753 d(
1754 "bynk.messages.multiple_reference",
1755 "A message bundle has more than one `@reference` block.",
1756 ),
1757 d(
1758 "bynk.messages.outside_commons",
1759 "A `messages` declaration appears outside a commons.",
1760 ),
1761 d(
1762 "bynk.messages.placeholder_mismatch",
1763 "A locale's template for a code uses a different set of `{name}` placeholders than the reference locale's.",
1764 ),
1765 d(
1766 "bynk.namespace.reserved",
1767 "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
1768 ),
1769 d(
1770 "bynk.observe.impure_with",
1771 "A `with` predicate uses an effectful or test-only construct; it must be pure.",
1772 ),
1773 d(
1774 "bynk.observe.not_a_seam",
1775 "An observation targets a capability the unit under test does not consume.",
1776 ),
1777 d(
1778 "bynk.observe.trace_outside_test",
1779 "`trace(Cap.op)` appears outside a `case` body.",
1780 ),
1781 d(
1782 "bynk.observe.unknown_op",
1783 "An observation names an operation the capability does not declare.",
1784 ),
1785 d(
1786 "bynk.observe.with_not_bool",
1787 "A `with` predicate does not have type `Bool`.",
1788 ),
1789 d(
1790 "bynk.package.alias_shadows_unit",
1791 "A dependency alias in `[dependencies]` is also the first segment of one of the project's own units, so `<alias>.…` would be ambiguous.",
1792 ),
1793 d(
1794 "bynk.package.checksum_mismatch",
1795 "A git dependency's store entry, or a freshly fetched commit, doesn't hash to the checksum `bynk.lock` records; `bynk` refuses to build it.",
1796 ),
1797 d(
1798 "bynk.package.dependency_cycle",
1799 "The package graph has a cycle: a dependency depends, directly or not, on itself or on the project.",
1800 ),
1801 d(
1802 "bynk.package.dependency_not_found",
1803 "A path dependency's directory has no readable `bynk.toml`, its `bynk.toml` is invalid, or it has no `[package]`.",
1804 ),
1805 d(
1806 "bynk.package.dev_dependency_in_source",
1807 "A commons, context or adapter reaches a `[dev-dependencies]` alias, which only a suite may use.",
1808 ),
1809 d(
1810 "bynk.package.duplicate_source",
1811 "One package is reached from two different directories; a build holds one copy of each package.",
1812 ),
1813 d(
1814 "bynk.package.git_failed",
1815 "`git` couldn't clone, fetch or check out a git dependency, or the revision it names doesn't exist.",
1816 ),
1817 d(
1818 "bynk.package.lock_invalid",
1819 "`bynk.lock` can't be read: it isn't valid TOML, has no `version`, is a version this toolchain doesn't read, or locks a package to something that isn't a commit.",
1820 ),
1821 d(
1822 "bynk.package.lock_out_of_date",
1823 "`--locked` was given, and resolving the manifests would change `bynk.lock`.",
1824 ),
1825 d(
1826 "bynk.package.name_mismatch",
1827 "A path dependency's `package` names a different package than the directory's `[package] name`.",
1828 ),
1829 d(
1830 "bynk.package.not_fetched",
1831 "A git dependency has no `bynk.lock` entry, or its store entry is missing; `bynk fetch` fetches it (refused under `--offline`).",
1832 ),
1833 d(
1834 "bynk.package.unit_not_exported",
1835 "A `uses` or `consumes` reaches a unit its dependency declares but doesn't list in `[package] exports`.",
1836 ),
1837 d(
1838 "bynk.package.unknown_unit",
1839 "A `uses` or `consumes` names, through a dependency alias, a unit the dependency doesn't declare.",
1840 ),
1841 d(
1842 "bynk.package.unsafe_source",
1843 "A git dependency's URL or revision looks like a command-line option, or uses a transport other than `https`, `ssh` (or `file`, from the project's own manifests).",
1844 ),
1845 d(
1846 "bynk.package.unsupported_in_dependency",
1847 "A dependency declares an `asset` or an `embed`, which would resolve against the consuming project's `assets/` or `embeds/`; a per-package namespace for either isn't designed yet.",
1848 ),
1849 d(
1850 "bynk.package.version_conflict",
1851 "One package is reached at two different git revisions (or from git and a path); a build, or a workspace, holds one copy of each package.",
1852 ),
1853 dg(
1854 "bynk.par.invalid_statement",
1855 "A `par { … }` block holds a statement other than `let x <- e` or `do e`: a refutable `let … else`, a plain `let`, `~>`, `:=` or a store write, `expect`, `advance`, a nested `par`, or anything that is not a statement.",
1856 &["par_stmt"],
1857 ),
1858 dg(
1859 "bynk.par.question_in_join",
1860 "A `?` appears inside a `par { … }` binding. `?` takes a `Result` value, not an effect, so a binding's own result is unwrapped after the block (`let user = userR?`), where the `?` lines run in source order; a `?` on an argument is computed before the block.",
1861 &["par_stmt"],
1862 ),
1863 dg(
1864 "bynk.par.sibling_name",
1865 "A `par { … }` binding mentions a name another binding in the same block binds, or binds a name twice. The bindings run together, so none can read a sibling's result; the rule holds even where the name would resolve to an outer binding.",
1866 &["par_stmt"],
1867 ),
1868 warn(dg(
1869 "bynk.par.single_binding",
1870 "A `par { … }` block has a single binding, which is a plain `let x <- e` with extra syntax (warning).",
1871 &["par_stmt"],
1872 )),
1873 dg(
1874 "bynk.parse.const_missing_type",
1875 "A `const` declaration has no type annotation; a constant's type is always written (`const Name: Type = …`).",
1876 &["const_decl"],
1877 ),
1878 dg(
1879 "bynk.parse.consumes_after_decls",
1880 "`consumes` appears after other declarations.",
1881 &["consumes_decl"],
1882 ),
1883 d(
1884 "bynk.parse.dangling_handler_annotation",
1885 "A handler-position annotation (e.g. `@cache`) is not followed by an `on` handler.",
1886 ),
1887 d(
1888 "bynk.parse.doc_block_contains_code",
1889 "A documentation block's content (outside Markdown code fences) parses as declarations, so a pair of dash dividers has turned code into documentation.",
1890 ),
1891 dg(
1892 "bynk.parse.duplicate_cors",
1893 "A service declares more than one `cors { }` policy.",
1894 &["service_decl"],
1895 ),
1896 dg(
1897 "bynk.parse.duplicate_json",
1898 "A service declares more than one `json { }` policy.",
1899 &["service_decl"],
1900 ),
1901 dg(
1902 "bynk.parse.duplicate_limits",
1903 "A service declares more than one `limits { }` policy.",
1904 &["service_decl"],
1905 ),
1906 dg(
1907 "bynk.parse.duplicate_security",
1908 "A service declares more than one `security { }` policy.",
1909 &["service_decl"],
1910 ),
1911 dg(
1912 "bynk.parse.empty_agent",
1913 "An `agent` body is empty.",
1914 &["agent_decl"],
1915 ),
1916 dg(
1917 "bynk.parse.empty_capability",
1918 "A `capability` body is empty.",
1919 &["capability_decl"],
1920 ),
1921 d(
1922 "bynk.parse.empty_interpolation",
1923 "An interpolation hole `\\(…)` contains no expression.",
1924 ),
1925 dg(
1926 "bynk.parse.empty_match",
1927 "A `match` has no arms.",
1928 &["match_expr"],
1929 ),
1930 dg(
1931 "bynk.parse.empty_service",
1932 "A `service` body is empty.",
1933 &["service_decl"],
1934 ),
1935 d(
1936 "bynk.parse.event_pattern_empty",
1937 "A `from Events(E { ... })` subscription pattern listed no fields — use `from Events(E)` (no braces) for an unfiltered subscription.",
1938 ),
1939 dg(
1940 "bynk.parse.expected_agent_key",
1941 "Expected a `key` declaration in an agent.",
1942 &["agent_decl"],
1943 ),
1944 d(
1945 "bynk.parse.expected_agent_storage",
1946 "An agent declares no storage — it has no `store` fields.",
1947 ),
1948 dg(
1949 "bynk.parse.expected_base_type",
1950 "Expected a base type.",
1951 &["base_type"],
1952 ),
1953 dg(
1954 "bynk.parse.expected_capability_op",
1955 "Expected a capability operation.",
1956 &["capability_op"],
1957 ),
1958 d("bynk.parse.expected_expression", "Expected an expression."),
1959 dg(
1960 "bynk.parse.expected_handler",
1961 "Expected a handler.",
1962 &["handler"],
1963 ),
1964 d("bynk.parse.expected_item", "Expected a declaration."),
1965 dg(
1966 "bynk.parse.expected_predicate",
1967 "Expected a refinement predicate.",
1968 &["refinement"],
1969 ),
1970 dg(
1971 "bynk.parse.expected_provider_op",
1972 "Expected a provider operation.",
1973 &["provider_op"],
1974 ),
1975 d("bynk.parse.expected_token", "Expected a specific token."),
1976 d("bynk.parse.expected_type", "Expected a type."),
1977 d(
1978 "bynk.parse.expected_unit_header",
1979 "Expected a `commons` or `context` header.",
1980 ),
1981 dg(
1982 "bynk.parse.expected_visibility",
1983 "Expected a visibility keyword.",
1984 &["exports_decl"],
1985 ),
1986 dg(
1987 "bynk.parse.exports_after_decls",
1988 "`exports` appears after other declarations.",
1989 &["exports_decl"],
1990 ),
1991 d(
1992 "bynk.parse.extra_tokens",
1993 "Unexpected tokens after an otherwise complete construct.",
1994 ),
1995 dg(
1996 "bynk.parse.generic_arg_count",
1997 "Wrong number of generic type arguments.",
1998 &["generic_type_ref"],
1999 ),
2000 dg(
2001 "bynk.parse.handler_in_agent",
2002 "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
2003 &["handler"],
2004 ),
2005 d(
2006 "bynk.parse.invariant_after_handler",
2007 "An `invariant` was declared after a handler; invariants precede handlers.",
2008 ),
2009 dg(
2010 "bynk.parse.keyword_field_shorthand",
2011 "A reserved keyword was used as a field shorthand, which would bind a variable of that name.",
2012 &["identifier"],
2013 ),
2014 dg(
2015 "bynk.parse.lambda_pattern_annotation",
2016 "A lambda parameter with a record pattern carries a type annotation; the pattern's type name already gives the parameter's type.",
2017 &["lambda_param"],
2018 ),
2019 dg(
2020 "bynk.parse.lambda_pattern_not_record",
2021 "A lambda parameter is a pattern other than a record pattern; only an irrefutable record pattern may stand in for a name.",
2022 &["lambda_param"],
2023 ),
2024 dg(
2025 "bynk.parse.lambda_pattern_refutable",
2026 "A lambda parameter's record pattern can fail to match some value of its type, and a lambda has no `else` to fall back on.",
2027 &["lambda_param"],
2028 ),
2029 dg(
2030 "bynk.parse.let_else_on_binding",
2031 "An `else` follows a plain `let name = …` binding, which matches every value, so the `else` could never run.",
2032 &["let_stmt", "effect_let_stmt"],
2033 ),
2034 hint(d(
2035 "bynk.parse.let_else_staircase",
2036 "Nested `match`es on `Option`/`Result` that each carry on in one arm and give up in the other, which `let … else` writes flat. A hint with a machine-applicable rewrite; never fails a build and is hidden from the terminal (hint).",
2037 )),
2038 dg(
2039 "bynk.parse.let_pattern_annotation",
2040 "A `let` with a pattern carries a type annotation; the pattern's names take their types from the value.",
2041 &["let_else_stmt"],
2042 ),
2043 dg(
2044 "bynk.parse.let_pattern_without_else",
2045 "A `let` binds a pattern but has no `else` saying what the block produces when the value does not match; only a record pattern that cannot fail may omit it.",
2046 &["let_else_stmt"],
2047 ),
2048 dg(
2049 "bynk.parse.list_rest_not_last",
2050 "A `..` in a list pattern is not the final element; suffix forms such as `[.., last]` are not available.",
2051 &["list_pattern"],
2052 ),
2053 dg(
2054 "bynk.parse.malformed_float_literal",
2055 "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
2056 &["float_literal"],
2057 ),
2058 dg(
2059 "bynk.parse.match_ends_block",
2060 "A `match` ends the block it is in, because a block has no expression statements; a second `match` straight after it cannot follow.",
2061 &["block"],
2062 ),
2063 d(
2064 "bynk.parse.migrate_after_handler",
2065 "A `migrate` step is declared after an agent handler; migration steps precede the handlers.",
2066 ),
2067 d(
2068 "bynk.parse.migrate_item",
2069 "A `migrate` step's body holds something other than `field := value`, `let` or `drop field`.",
2070 ),
2071 d(
2072 "bynk.parse.multiple_docs",
2073 "A declaration or member has two docs directly above it; a target has one doc, so a doc of more than one line is a `---` block.",
2074 ),
2075 d(
2076 "bynk.parse.nesting_too_deep",
2077 "An expression or type nests deeper than the parser's fixed limit.",
2078 ),
2079 d(
2080 "bynk.parse.no_remainder_operator",
2081 "`%` is not an operator; use `Int.rem` (the dividend's sign) or `Int.mod` (the divisor's).",
2082 ),
2083 dg(
2084 "bynk.parse.non_associative",
2085 "A non-associative operator was chained (e.g. `a == b == c`).",
2086 &["binary_expr"],
2087 ),
2088 warn(d(
2089 "bynk.parse.orphan_doc_block",
2090 "A documentation block is not attached to a declaration (warning).",
2091 )),
2092 dg(
2093 "bynk.parse.policy_order",
2094 "A service's `cors`/`security`/`limits` policy is out of order or follows a handler; they open the body in the order `cors`, `security`, `limits`, `json`.",
2095 &["service_decl"],
2096 ),
2097 dg(
2098 "bynk.parse.record_pattern_in_is_unparenthesised",
2099 "A record pattern after `is` is not parenthesised — write `x is (T { f, .. })`.",
2100 &["record_pattern"],
2101 ),
2102 dg(
2103 "bynk.parse.record_pattern_without_rest",
2104 "A record pattern does not end with `..`; every record pattern is open.",
2105 &["record_pattern"],
2106 ),
2107 dg(
2108 "bynk.parse.refined_pattern_inner",
2109 "A refined pattern's inner form is something other than `_`.",
2110 &["refined_pattern"],
2111 ),
2112 dg(
2113 "bynk.parse.reserved_keyword",
2114 "A reserved keyword was used as an identifier.",
2115 &["identifier"],
2116 ),
2117 dg(
2118 "bynk.parse.self_outside_method",
2119 "`self` used outside a method or handler.",
2120 &["self_expr"],
2121 ),
2122 d(
2123 "bynk.parse.storage_after_phase",
2124 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
2125 ),
2126 d(
2127 "bynk.parse.transition_after_handler",
2128 "A `transition` is declared after an agent handler; step invariants precede the handlers.",
2129 ),
2130 d(
2131 "bynk.parse.unexpected_adapter",
2132 "An `adapter` appeared where it is not allowed.",
2133 ),
2134 dg(
2135 "bynk.parse.unexpected_context",
2136 "A `context` appeared where it is not allowed.",
2137 &["context_decl"],
2138 ),
2139 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
2140 dg(
2141 "bynk.parse.unexpected_suite",
2142 "A `suite` appeared where it is not allowed.",
2143 &["suite_decl"],
2144 ),
2145 d(
2146 "bynk.parse.unknown_effect_method",
2147 "An unknown method on `Effect`.",
2148 ),
2149 dg(
2150 "bynk.parse.unknown_handler_kind",
2151 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
2152 &["handler"],
2153 ),
2154 dg(
2155 "bynk.parse.unknown_predicate",
2156 "An unknown refinement predicate.",
2157 &["predicate_name"],
2158 ),
2159 d(
2160 "bynk.parse.unknown_tier",
2161 "A `case`/`suite` `as <tier>` clause names something other than `unit`, `integration`, or `system`.",
2162 ),
2163 dg(
2164 "bynk.parse.uses_after_decls",
2165 "`uses` appears after other declarations.",
2166 &["uses_decl"],
2167 ),
2168 dg(
2169 "bynk.parse.variant_name_case",
2170 "A sum-type or enum variant name is not capitalised.",
2171 &["sum_variant", "enum_type"],
2172 ),
2173 d(
2174 "bynk.project.contracts_lock_corrupt",
2175 "`bynk.contracts.lock` (the older service contracts a callee still accepts) is missing its version field, empty, truncated, unparseable, or of an unsupported version — restore it from version control rather than deleting it, since a callee that forgets the contracts it accepts refuses its live callers.",
2176 ),
2177 warn(d(
2178 "bynk.project.contracts_lock_oversized",
2179 "`bynk.contracts.lock` has one service accepting more older contracts than the build keeps comfortably (warning).",
2180 )),
2181 warn(d(
2182 "bynk.project.contracts_lock_stale",
2183 "`bynk.contracts.lock` lists an older contract the service no longer accepts, because it is unreadable or no longer compatible with the contract the service has now; the entry is ignored (warning).",
2184 )),
2185 warn(d(
2186 "bynk.project.duplicate_compatibility_flag",
2187 "`bynk.toml`'s `[workers] compatibility_flags` lists a flag twice, or one every Bynk Worker already has; the duplicate is dropped (warning).",
2188 )),
2189 d(
2190 "bynk.project.duplicate_module_doc",
2191 "More than one file of a multi-file unit carries a module doc.",
2192 ),
2193 d(
2194 "bynk.project.export_context",
2195 "`bynk.toml`'s `[package] exports` lists a context: a package shares commons and adapters, never a context, which belongs to the project that deploys it.",
2196 ),
2197 d(
2198 "bynk.project.export_unknown",
2199 "`bynk.toml`'s `[package] exports` lists a name that isn't a commons or adapter the project declares.",
2200 ),
2201 d(
2202 "bynk.project.file_and_directory",
2203 "A unit exists as both a file and a directory.",
2204 ),
2205 d(
2206 "bynk.project.inconsistent_commons_name",
2207 "A source file's path does not match its declared name.",
2208 ),
2209 d(
2210 "bynk.project.kind_conflict",
2211 "A name is declared as both a commons and a context.",
2212 ),
2213 d(
2214 "bynk.project.no_root",
2215 "No project root could be determined.",
2216 ),
2217 d(
2218 "bynk.project.no_sources",
2219 "The project contains no source files.",
2220 ),
2221 d(
2222 "bynk.project.read_failed",
2223 "A source file could not be read.",
2224 ),
2225 d(
2226 "bynk.project.schema_registry_corrupt",
2227 "`bynk.schema.lock` (the schema registry for events and agent state) is missing its version field, empty, truncated, or otherwise unparseable — restore it from version control rather than deleting it, since deleting it would silently re-baseline every event's and agent's history.",
2228 ),
2229 warn(d(
2230 "bynk.project.unstable_not_experimental",
2231 "`bynk.toml`'s `[unstable] allow` lists an item that nothing experimental lies in or under: it is stable now, so the entry can go (warning).",
2232 )),
2233 d(
2234 "bynk.project.unstable_unknown_item",
2235 "`bynk.toml`'s `[unstable] allow` lists a path that names no standard-library unit, exported item or operation.",
2236 ),
2237 dg(
2238 "bynk.property.restates_refinement",
2239 "A `property` merely re-checks a refinement its type already guarantees.",
2240 &["for_all"],
2241 ),
2242 dg(
2243 "bynk.property.where_not_bool",
2244 "A `for all ... where` filter does not type to `Bool`.",
2245 &["for_all"],
2246 ),
2247 dg(
2248 "bynk.provider.agent_call_undeclared_capability",
2249 "A provider calls an agent handler that needs a capability the provider's `given` does not list.",
2250 &["provider_decl"],
2251 ),
2252 dg(
2253 "bynk.provider.dependency_cycle",
2254 "Providers form a capability dependency cycle through `given`.",
2255 &["provider_decl"],
2256 ),
2257 dg(
2258 "bynk.provider.extra_operation",
2259 "A `provides` block implements an operation not in the capability.",
2260 &["provider_decl"],
2261 ),
2262 dg(
2263 "bynk.provider.generic_op_requires_external",
2264 "A Bynk-bodied `provides` implements a capability operation that declares its own type parameter — only an external (bodiless) provider can.",
2265 &["provider_decl"],
2266 ),
2267 dg(
2268 "bynk.provider.missing_operation",
2269 "A `provides` block is missing a capability operation.",
2270 &["provider_decl"],
2271 ),
2272 dg(
2273 "bynk.provider.outside_context",
2274 "`provides` was declared outside a context.",
2275 &["provider_decl"],
2276 ),
2277 dg(
2278 "bynk.provider.signature_mismatch",
2279 "A `provides` operation's signature does not match the capability.",
2280 &["provider_decl"],
2281 ),
2282 dg(
2283 "bynk.provider.unknown_capability",
2284 "`provides` names a capability that does not exist.",
2285 &["provider_decl"],
2286 ),
2287 d(
2288 "bynk.query.join_key_mismatch",
2289 "A `joinOn`/`leftJoin` left and right key function return different types.",
2290 ),
2291 dg(
2292 "bynk.query.sum_needs_numeric",
2293 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
2294 &[],
2295 ),
2296 dg(
2297 "bynk.queue.bad_params",
2298 "An `on message` handler does not take exactly one `message` parameter.",
2299 &["queue_handler"],
2300 ),
2301 dg(
2302 "bynk.queue.duplicate_consumer",
2303 "Two `on message` handlers consume the same queue.",
2304 &["queue_handler"],
2305 ),
2306 dg(
2307 "bynk.queue.invalid_name",
2308 "A `from queue(\"…\")` binding has an empty queue name, or one Cloudflare refuses.",
2309 &["queue_handler"],
2310 ),
2311 dg(
2312 "bynk.queue.return_not_queue_result",
2313 "An `on message` handler does not return `Effect[QueueResult]`.",
2314 &["handler"],
2315 ),
2316 dg(
2317 "bynk.race.in_agent_handler",
2318 "`a.race(b)` was used in an agent handler, which has no execution context to hand the losing effect to.",
2319 &["method_call"],
2320 ),
2321 dg(
2322 "bynk.race.in_pure_context",
2323 "`a.race(b)` was used in a pure (non-effectful) context.",
2324 &["method_call"],
2325 ),
2326 dg(
2327 "bynk.race.outside_handler",
2328 "`a.race(b)` was used outside a service handler's body and outside a function (in a provider operation, a WebSocket handler or a test `case` body), where no execution context exists.",
2329 &["method_call"],
2330 ),
2331 dg(
2332 "bynk.record_spread.field_type_mismatch",
2333 "A record-spread override has the wrong type for the field.",
2334 &["record_spread"],
2335 ),
2336 dg(
2337 "bynk.record_spread.non_record_base",
2338 "The base of a record spread is not a record.",
2339 &["record_spread"],
2340 ),
2341 dg(
2342 "bynk.record_spread.type_mismatch",
2343 "A record spread's base is a different record type.",
2344 &["record_spread"],
2345 ),
2346 dg(
2347 "bynk.record_spread.unknown_field",
2348 "A record spread overrides a field the record does not have.",
2349 &["record_spread"],
2350 ),
2351 dg(
2352 "bynk.refine.literal_violates",
2353 "A literal does not satisfy the refined type's predicate.",
2354 &["refined_type"],
2355 ),
2356 d(
2357 "bynk.registry.account_refused",
2358 "`bynk login`, `bynk logout` or a `bynk org` command didn't go through: you aren't signed in or your session expired, the registry has no account API (or is read through a mirror), the sign-in was declined or its code expired, or the registry refused the request (a taken or reserved name, not the owner, an unknown member or token).",
2359 ),
2360 d(
2361 "bynk.registry.bad_archive",
2362 "A registry archive is malformed or hostile: not a `bynk-tree-v1` stream, a path that is absolute or climbs out of the package, an out-of-order or repeated file, or past the size limits.",
2363 ),
2364 d(
2365 "bynk.registry.bad_signature",
2366 "An index line isn't signed by a key the trusted key's rotation chain reaches, or its signed registry `id` or package `name` isn't the one asked for (a forged or replayed line).",
2367 ),
2368 d(
2369 "bynk.registry.http_failed",
2370 "A registry couldn't be read: unreachable, an error status, a refused or missing token, a redirect from https to http, too many redirects, or a response past the size limit.",
2371 ),
2372 d(
2373 "bynk.registry.key_mismatch",
2374 "A registry's keys don't lead from the key trusted for it (pinned in `[registries]`, or recorded in `bynk.lock`), or it now declares a different `id`.",
2375 ),
2376 d(
2377 "bynk.registry.nonconformant",
2378 "`bynk registry conformance` found a registry breaking the protocol: a check failed (a wrong status, an unsigned or mis-signed line, a checksum that isn't the tree sent, a refusal without its JSON body, …); each failure names the check and the protocol section it holds the registry to.",
2379 ),
2380 d(
2381 "bynk.registry.publish_refused",
2382 "`bynk publish` or `bynk yank` didn't go through: the project isn't a versioned package, it has a path or git dependency, its registry has no publish API (or is read through a mirror), or the registry refused the request (no or wrong token, an existing version, an invalid upload).",
2383 ),
2384 d(
2385 "bynk.registry.source_mismatch",
2386 "`bynk.lock` locks a package to one registry, but its organisation now routes to another; a misrouted organisation fails rather than resolving a same-named package elsewhere.",
2387 ),
2388 d(
2389 "bynk.registry.unavailable",
2390 "No registry serves a package: its organisation isn't listed by any `[registries]` entry (the first-party registry isn't live yet), the registry has no `config.json`, or it has no such package or archive.",
2391 ),
2392 d(
2393 "bynk.registry.withdrawn",
2394 "`bynk.lock` locks a registry version that its registry withdrew (a takedown: yanked, and its archive deleted), and its tree isn't in the store.",
2395 ),
2396 dg(
2397 "bynk.requires.conflicting_range",
2398 "Two adapter `binding … requires { … }` entries give different version ranges for one npm package.",
2399 &["binding_decl"],
2400 ),
2401 dg(
2402 "bynk.requires.unapproved",
2403 "A reached adapter of a git or registry dependency requires an npm package, at a range, that the project hasn't approved in `bynk.lock`; review it and run `bynk approve <package>`.",
2404 &["binding_decl"],
2405 ),
2406 dg(
2407 "bynk.requires.unpinned_dependency",
2408 "An adapter `binding … requires { … }` entry has an unpinned version range.",
2409 &["binding_decl"],
2410 ),
2411 d(
2412 "bynk.resolve.ambiguous_variant",
2413 "A variant name is ambiguous across several sum types.",
2414 ),
2415 dg(
2416 "bynk.resolve.arity_mismatch",
2417 "A function was called with the wrong number of arguments.",
2418 &["call"],
2419 ),
2420 dg(
2421 "bynk.resolve.bad_const_initialiser",
2422 "A `const` initialiser is not a static value of the declared type: only literals, constructors over static values, `T.unsafe(lit)`, `List.empty()`/`Map.empty()`/`Set.empty()`, `Duration` literals and references to other constants are allowed.",
2423 &["const_decl"],
2424 ),
2425 dg(
2426 "bynk.resolve.const_cycle",
2427 "Constants refer to each other in a cycle, so none of them has a value.",
2428 &["const_decl"],
2429 ),
2430 dg(
2431 "bynk.resolve.const_name_case",
2432 "A constant's name is not upper-camel case (`MaxRetries`, not `maxRetries`).",
2433 &["const_decl"],
2434 ),
2435 dg(
2436 "bynk.resolve.const_outside_context_or_commons",
2437 "A `const` declaration appears outside a context or commons.",
2438 &["const_decl"],
2439 ),
2440 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
2441 dg(
2442 "bynk.resolve.duplicate_agent",
2443 "Two agents share a name.",
2444 &["agent_decl"],
2445 ),
2446 dg(
2447 "bynk.resolve.duplicate_capability",
2448 "Two capabilities share a name.",
2449 &["capability_decl"],
2450 ),
2451 dg(
2452 "bynk.resolve.duplicate_const",
2453 "Two constants share a name.",
2454 &["const_decl"],
2455 ),
2456 dg(
2457 "bynk.resolve.duplicate_field",
2458 "A record declares a field twice.",
2459 &["record_type"],
2460 ),
2461 dg(
2462 "bynk.resolve.duplicate_field_init",
2463 "A record construction initialises a field twice.",
2464 &["record_construction"],
2465 ),
2466 dg(
2467 "bynk.resolve.duplicate_fn",
2468 "Two functions share a name.",
2469 &["fn_decl"],
2470 ),
2471 d(
2472 "bynk.resolve.duplicate_message_code",
2473 "A message bundle declares the same code twice in one block.",
2474 ),
2475 d(
2476 "bynk.resolve.duplicate_message_locale",
2477 "Two `messages` blocks in one bundle declare the same locale tag.",
2478 ),
2479 dg(
2480 "bynk.resolve.duplicate_method",
2481 "Two methods share a name.",
2482 &["fn_decl"],
2483 ),
2484 dg(
2485 "bynk.resolve.duplicate_param",
2486 "A parameter name is repeated.",
2487 &["param"],
2488 ),
2489 dg(
2490 "bynk.resolve.duplicate_provider",
2491 "A capability is provided more than once.",
2492 &["provider_decl"],
2493 ),
2494 dg(
2495 "bynk.resolve.duplicate_service",
2496 "Two services share a name.",
2497 &["service_decl"],
2498 ),
2499 dg(
2500 "bynk.resolve.duplicate_type",
2501 "Two types share a name.",
2502 &["type_decl"],
2503 ),
2504 dg(
2505 "bynk.resolve.duplicate_variant",
2506 "A sum type declares a variant twice.",
2507 &["sum_type"],
2508 ),
2509 d(
2510 "bynk.resolve.fn_without_call",
2511 "A function was referenced without being called.",
2512 ),
2513 dg(
2514 "bynk.resolve.let_shadows_fn",
2515 "A `let` binding shadows a function.",
2516 &["let_stmt"],
2517 ),
2518 dg(
2519 "bynk.resolve.let_shadows_type",
2520 "A `let` binding shadows a type.",
2521 &["let_stmt"],
2522 ),
2523 d(
2524 "bynk.resolve.method_unknown_type",
2525 "A method is defined on an unknown type.",
2526 ),
2527 dg(
2528 "bynk.resolve.missing_field",
2529 "A record construction omits a required field.",
2530 &["record_construction"],
2531 ),
2532 d(
2533 "bynk.resolve.name_conflict",
2534 "Two declarations share a name.",
2535 ),
2536 dg(
2537 "bynk.resolve.not_a_record_type",
2538 "Record syntax was used on a non-record type.",
2539 &["record_construction"],
2540 ),
2541 dg(
2542 "bynk.resolve.opaque_record_construction",
2543 "An opaque type was constructed with record syntax.",
2544 &["record_construction"],
2545 ),
2546 dg(
2547 "bynk.resolve.param_as_function",
2548 "A value (such as a parameter) was called as a function.",
2549 &["call"],
2550 ),
2551 dg(
2552 "bynk.resolve.recursive_record_field",
2553 "A record directly contains a field of its own type.",
2554 &["record_type"],
2555 ),
2556 dg(
2557 "bynk.resolve.reserved_builtin_type",
2558 "A type declaration reuses a compiler-known built-in type name.",
2559 &["type_decl"],
2560 ),
2561 dg(
2562 "bynk.resolve.reserved_host_name",
2563 "A declaration is named `globalThis`, which the generated TypeScript uses to reach host globals.",
2564 &["type_decl", "fn_decl", "agent_decl", "provider_decl"],
2565 ),
2566 dg(
2567 "bynk.resolve.reserved_payload_field",
2568 "A sum variant declares a payload field named `kind`, the variant's wire discriminant.",
2569 &["sum_type"],
2570 ),
2571 dg(
2572 "bynk.resolve.self_outside_method",
2573 "`self` referenced outside a method or handler.",
2574 &["self_expr"],
2575 ),
2576 dg(
2577 "bynk.resolve.type_as_function",
2578 "A type name was called as if it were a function.",
2579 &["call"],
2580 ),
2581 d(
2582 "bynk.resolve.type_in_expr",
2583 "A type name was used where a value is expected.",
2584 ),
2585 dg(
2586 "bynk.resolve.unconsumed_context",
2587 "A context's service was called without a `consumes` declaration.",
2588 &["consumes_decl"],
2589 ),
2590 dg(
2591 "bynk.resolve.unknown_field",
2592 "Accessed a field the record does not have.",
2593 &["field_access"],
2594 ),
2595 dg(
2596 "bynk.resolve.unknown_function",
2597 "Called a function that does not exist.",
2598 &["call"],
2599 ),
2600 d(
2601 "bynk.resolve.unknown_name",
2602 "Referenced a name that is not in scope.",
2603 ),
2604 dg(
2605 "bynk.resolve.unknown_static_member",
2606 "Referenced an unknown static member (e.g. `T.x`).",
2607 &["field_access"],
2608 ),
2609 d(
2610 "bynk.resolve.unknown_type",
2611 "Referenced a type that does not exist.",
2612 ),
2613 warn(d(
2614 "bynk.secrets.computed_name",
2615 "A `bynk.Secrets` read names its secret with a computed expression rather than a literal, so `bynk deploy` cannot plan it (warning).",
2616 )),
2617 dg(
2618 "bynk.send.in_agent_handler",
2619 "A `~>` send was used in an agent handler, which has no execution context to keep a fire-and-forget send alive.",
2620 &["effect_send_stmt"],
2621 ),
2622 dg(
2623 "bynk.send.in_pure_context",
2624 "A `~>` send was used in a pure (non-effectful) context.",
2625 &["effect_send_stmt"],
2626 ),
2627 dg(
2628 "bynk.send.non_effect",
2629 "A `~>` send was applied to a non-`Effect` value.",
2630 &["effect_send_stmt"],
2631 ),
2632 dg(
2633 "bynk.send.requires_unit",
2634 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
2635 &["effect_send_stmt"],
2636 ),
2637 dg(
2638 "bynk.send.store_op",
2639 "A `~>` send targets an agent store operation, which is part of the handler's atomic commit and cannot be sent without waiting.",
2640 &["effect_send_stmt"],
2641 ),
2642 dg(
2643 "bynk.service.missing_from",
2644 "A `from`-less service has a handler other than `on call`.",
2645 &["service_decl"],
2646 ),
2647 dg(
2648 "bynk.service.mixed_protocols",
2649 "A service mixes handler forms that do not match its `from <protocol>`.",
2650 &["service_decl"],
2651 ),
2652 dg(
2653 "bynk.service.outside_context",
2654 "A `service` was declared outside a context.",
2655 &["service_decl"],
2656 ),
2657 dg(
2658 "bynk.service.return_not_effect",
2659 "A service handler's return type is not an `Effect`.",
2660 &["service_decl"],
2661 ),
2662 dg(
2663 "bynk.service.unknown_protocol",
2664 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
2665 &["service_decl"],
2666 ),
2667 d(
2668 "bynk.service.unknown_via_clause",
2669 "A `via <name>(...)` clause on a `from Events(...)` header named something other than `schema` — `via` clauses are a closed set, and only `via schema(...)` exists today.",
2670 ),
2671 d(
2672 "bynk.service.websocket_header",
2673 "The `from websocket` header is malformed — it binds frame types as `websocket(in: <type>, out: <type>)` (real-time track slice 3).",
2674 ),
2675 d(
2676 "bynk.service.websocket_multiple",
2677 "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).",
2678 ),
2679 d(
2680 "bynk.service.websocket_open_arity",
2681 "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).",
2682 ),
2683 d(
2684 "bynk.service.websocket_param_not_stringy",
2685 "A `from websocket` service's `on open` parameter has a type not constructible from `String`; it arrives as a query-string value (#1657).",
2686 ),
2687 d(
2688 "bynk.stability.experimental",
2689 "An experimental standard-library item is used without an `[unstable] allow` entry in `bynk.toml` covering it.",
2690 ),
2691 d(
2692 "bynk.store.annotation_kind_mismatch",
2693 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
2694 ),
2695 d(
2696 "bynk.store.annotation_unsupported",
2697 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
2698 ),
2699 d(
2700 "bynk.store.cache_needs_clock",
2701 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
2702 ),
2703 d(
2704 "bynk.store.cache_ttl_required",
2705 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
2706 ),
2707 d(
2708 "bynk.store.kind_arity",
2709 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
2710 ),
2711 d(
2712 "bynk.store.kind_unsupported",
2713 "A known storage kind (`Queue`) is used before the slice that supports it.",
2714 ),
2715 d(
2716 "bynk.store.log_needs_clock",
2717 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
2718 ),
2719 d(
2720 "bynk.store.unkeyable_key",
2721 "A store `Set` element or `Map`/`Cache` key is not value-keyable — it must be `String`, `Int`, or a refined/opaque type over them (#1680).",
2722 ),
2723 d(
2724 "bynk.store.unknown_annotation",
2725 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
2726 ),
2727 d(
2728 "bynk.store.unknown_kind",
2729 "A `store` field's type is not a known storage kind.",
2730 ),
2731 d(
2732 "bynk.store.unknown_map_accessor",
2733 "A `store Map` field access is not one of its query accessors (`entries`/`keys`/`values`).",
2734 ),
2735 d(
2736 "bynk.store.unknown_op",
2737 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
2738 ),
2739 d(
2740 "bynk.stub.after_type",
2741 "A test `stub … returns <value> after <d>` latency is not a `Duration`.",
2742 ),
2743 dg(
2744 "bynk.stub.at_system",
2745 "A test `stub` is in a `system`-tier case, or at the scope of a `suite … as system` (or a suite whose cases run `as system`); each context runs as the Worker it deploys as, which builds its own capability providers, so there is no seam to override.",
2746 &["stub_clause"],
2747 ),
2748 d(
2749 "bynk.stub.bad_sequence",
2750 "A `stub … returns each […]` sequence is malformed (e.g. empty).",
2751 ),
2752 d(
2753 "bynk.stub.generic_op",
2754 "A test `stub` targets a capability operation that declares its own type parameter — not supported at v1.",
2755 ),
2756 d(
2757 "bynk.stub.not_a_seam",
2758 "A test `stub` overrides a capability the unit under test does not consume.",
2759 ),
2760 d(
2761 "bynk.stub.rhs_type",
2762 "A test `stub … returns <value>` right-hand side does not match the operation's return type.",
2763 ),
2764 d(
2765 "bynk.stub.unknown_op",
2766 "A test `stub` names an operation the capability does not declare.",
2767 ),
2768 dg(
2769 "bynk.suite.duplicate_case_name",
2770 "Two `case`s share a description.",
2771 &["case"],
2772 ),
2773 dg(
2774 "bynk.suite.duplicate_env",
2775 "An `env { … }` clause gives the same name twice at one scope (a suite's `env` clauses, or one case's); a case's `env` may override a suite's name, but not repeat its own.",
2776 &["env_clause"],
2777 ),
2778 dg(
2779 "bynk.suite.duplicate_fn",
2780 "A suite declares two helper `fn`s of the same name.",
2781 &["fn_decl"],
2782 ),
2783 dg(
2784 "bynk.suite.env_binding_clash",
2785 "A `system`-tier suite's or case's `env` names a binding a participant's Worker already declares (a Service Binding, KV namespace, or Durable Object namespace), or a key the test harness sets on it (a call-edge key, a `Foreign` caller's secret), so the entry would clash with it on the Worker's `env`.",
2786 &["env_clause"],
2787 ),
2788 dg(
2789 "bynk.suite.env_not_literal",
2790 "An `env { … }` entry's value is not a `String` literal; a Worker's variables and secrets are strings, given verbatim.",
2791 &["env_clause"],
2792 ),
2793 dg(
2794 "bynk.suite.fn_effectful",
2795 "A suite helper `fn` returns an `Effect`; suite helpers are pure.",
2796 &["fn_decl"],
2797 ),
2798 dg(
2799 "bynk.suite.fn_method",
2800 "A suite helper `fn` is a method (`fn Type.name`); suite helpers are free functions.",
2801 &["fn_decl"],
2802 ),
2803 dg(
2804 "bynk.suite.fn_name_clash",
2805 "A suite helper `fn` has the name of a declaration already in scope in the suite's cases.",
2806 &["fn_decl"],
2807 ),
2808 dg(
2809 "bynk.suite.unknown_target",
2810 "A `suite` targets a unit that does not exist.",
2811 &["suite_decl"],
2812 ),
2813 d(
2814 "bynk.target.browser_bundle_only",
2815 "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
2816 ),
2817 dg(
2818 "bynk.target.vendor_conflict",
2819 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
2820 &["consumes_decl"],
2821 ),
2822 dg(
2823 "bynk.target.vendor_required",
2824 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
2825 &["consumes_decl"],
2826 ),
2827 dg(
2828 "bynk.test.actor_identity_required",
2829 "A test omits the identity an identity-carrying actor requires: a bare call-site `by <Actor>`, or no `by` at all on a handler that binds its `Caller`.",
2830 &["case"],
2831 ),
2832 dg(
2833 "bynk.test.actor_no_identity",
2834 "A call-site `by <Actor>(x)` supplies an identity to an actor that takes none — a unit-identity actor (e.g. `Visitor`) or `Nobody`.",
2835 &["case"],
2836 ),
2837 dg(
2838 "bynk.test.advance_not_clock",
2839 "An `advance` statement names a capability other than `Clock`; the test harness owns one time source, the first-party `Clock`.",
2840 &["advance_stmt"],
2841 ),
2842 dg(
2843 "bynk.test.advance_not_duration",
2844 "An `advance Clock by` statement's amount is not a `Duration`.",
2845 &["advance_stmt"],
2846 ),
2847 dg(
2848 "bynk.test.advance_outside_case",
2849 "An `advance Clock by` statement appears outside a test `case` body; only the test harness has a clock to move.",
2850 &["advance_stmt"],
2851 ),
2852 dg(
2853 "bynk.test.asset_address_method",
2854 "A suite fetches an asset with a method other than `GET`; the platform serves assets to `GET` and answers other methods with 405.",
2855 &["case"],
2856 ),
2857 dg(
2858 "bynk.test.call_needs_in_process",
2859 "A `system`-tier case calls an `on call` service with `svc.call(…)`; an `on call` service is internal to a deployment and has no public route for a `system` case to drive, so the case drives an `http` route that reaches it, or calls it at `unit` or `integration`.",
2860 &["case"],
2861 ),
2862 dg(
2863 "bynk.test.credential_needs_system",
2864 "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.",
2865 &["case"],
2866 ),
2867 dg(
2868 "bynk.test.event_needs_in_process",
2869 "A `system`-tier case delivers an event with `svc.event(e)`; at `system` an event reaches a subscriber only through its publisher's fan-out, so the case drives the emitting handler instead, or delivers the event at `unit` or `integration`.",
2870 &["case"],
2871 ),
2872 dg(
2873 "bynk.test.event_not_subscribed",
2874 "A test body's `svc.event(e)` delivers an event the `from Events(E)` service does not subscribe to.",
2875 &["case"],
2876 ),
2877 dg(
2878 "bynk.test.event_publisher_ambiguous",
2879 "A test body's `svc.event(e)` omits the envelope, but the event's publisher, which the default envelope names, is not one context the target declares or consumes.",
2880 &["case"],
2881 ),
2882 dg(
2883 "bynk.test.expired_needs_bearer_route",
2884 "A case drives `by Expired` at an address that is not an http route with a `Bearer` actor (alone, or as a member of an actor sum); it sends a correctly signed token whose `exp` has passed, so only a `Bearer` seam can refuse it.",
2885 &["case"],
2886 ),
2887 dg(
2888 "bynk.test.faults_needs_in_process",
2889 "A `system`-tier case claims a fault with `expect <call> faults`, or a fault claim at any tier is driven `by Nobody`, `by Forged`, `by Stale` or `by Expired`; at `system` a fault reaches the case as an error response from the deployed Worker, never a throw, so the claim belongs at `unit` or `integration`.",
2890 &["case"],
2891 ),
2892 dg(
2893 "bynk.test.forged_needs_signature_route",
2894 "A case drives `by Forged` at an address that is not an http route with a `Signature` or `Bearer` actor, or `by Stale` at one with no `Signature` actor (alone, or as a member of an actor sum); they send a bad credential, so only a `Signature` or `Bearer` seam can refuse them.",
2895 &["case"],
2896 ),
2897 dg(
2898 "bynk.test.forged_needs_system",
2899 "A case drives `by Forged`, `by Stale` or `by Expired` outside a `system`-tier case; only the `system` driver signs a request or mints a token, so only there does the real `Signature` or `Bearer` seam see the bad credential.",
2900 &["case"],
2901 ),
2902 dg(
2903 "bynk.test.nobody_needs_secured_route",
2904 "A case drives `by Nobody` at a route with no Bearer or Signature actor (alone, or as a member of an actor sum) (e.g. a public `Visitor` route) — there is no auth seam to reject the missing credential.",
2905 &["case"],
2906 ),
2907 dg(
2908 "bynk.test.oidc_needs_in_process",
2909 "A `system`-tier case calls an http route whose actor is `Oidc`-secured; the `system` driver has no token issuer yet, so the request without a token could only be refused with a `401`, and the call belongs at `unit` or `integration`.",
2910 &["case"],
2911 ),
2912 d(
2913 "bynk.test.principal_claims_not_oidc",
2914 "A call-site principal passes token claims for an actor that isn't `Oidc`.",
2915 ),
2916 dg(
2917 "bynk.test.principal_identity_mismatch",
2918 "A call-site `by <Actor>` acts as an actor whose identity is incompatible with the addressed handler's actor, or names no member of the handler's actor sum.",
2919 &["case"],
2920 ),
2921 dg(
2922 "bynk.test.principal_on_asset",
2923 "A suite's asset fetch carries a `by` clause; an asset is public and served before the Worker runs.",
2924 &["case"],
2925 ),
2926 dg(
2927 "bynk.test.principal_on_wrong_method",
2928 "A wrong-method `405` test carries a `by <Actor>` clause; it reaches no handler, so a principal is meaningless.",
2929 &["case"],
2930 ),
2931 dg(
2932 "bynk.test.principal_required",
2933 "A test drives an identity-carrying handler, or one guarded by an actor sum, with no call-site `by <Actor>`.",
2934 &["case"],
2935 ),
2936 warn(dg(
2937 "bynk.test.remote_clock_dependent",
2938 "Under `bynk test --against`, a `system` case's `expect` compares an `Instant` that isn't derived from the run (a constant such as `Instant.fromEpochMillis(0)`); in process the clock starts at the epoch, but a real runtime's Workers read wall-clock time.",
2939 &["case"],
2940 )),
2941 dg(
2942 "bynk.test.remote_unsupported_advance",
2943 "A `system` case moves the harness clock with `advance Clock`, which a run against a real runtime (`bynk test --against`) can't honour: the deployed Workers read wall-clock time.",
2944 &["case"],
2945 ),
2946 dg(
2947 "bynk.test.remote_unsupported_asset",
2948 "A `system` case fetches an asset with `svc.GET(asset)`, which a run against a real runtime (`bynk test --against`) can't honour: the fetch is answered in process.",
2949 &["case"],
2950 ),
2951 dg(
2952 "bynk.test.remote_unsupported_call",
2953 "A `system` case addresses an `on call` service, which a run against a real runtime (`bynk test --against`) can't honour: the service is internal, and each call is signed for one caller.",
2954 &["case"],
2955 ),
2956 dg(
2957 "bynk.test.remote_unsupported_env",
2958 "A `system` case's `env` disagrees with the named target it would run against (`bynk test --against`): it sets a secret, sets a name the target doesn't declare under `vars` or declares with another value, or leaves unset a name the target declares.",
2959 &["case"],
2960 ),
2961 dg(
2962 "bynk.test.remote_unsupported_queue",
2963 "A `system` case delivers a queue message with `q.message(m)`, which a run against a real runtime (`bynk test --against`) can't honour: no public wire reaches a queue consumer.",
2964 &["case"],
2965 ),
2966 dg(
2967 "bynk.test.remote_unsupported_schedule",
2968 "A `system` case runs a cron handler with `svc.schedule(…)`, which a run against a real runtime (`bynk test --against`) can't honour: no public wire reaches a cron handler.",
2969 &["case"],
2970 ),
2971 dg(
2972 "bynk.test.service_bad_address",
2973 "A test body addresses a service the wrong way for its protocol (e.g. an http route without a leading path string).",
2974 &["case"],
2975 ),
2976 dg(
2977 "bynk.test.service_call_arity",
2978 "A test body's `svc.call(...)` passes the wrong number of arguments for the service's `on call` handler.",
2979 &["case"],
2980 ),
2981 dg(
2982 "bynk.test.service_no_call_handler",
2983 "A test body invokes `svc.call(...)` on a service with no `on call` handler (a `from http`/`cron`/`queue` service).",
2984 &["case"],
2985 ),
2986 dg(
2987 "bynk.test.service_unknown_route",
2988 "A test body addresses an http route / cron schedule / queue message the service does not declare.",
2989 &["case"],
2990 ),
2991 warn(dg(
2992 "bynk.test.smoke_undeclared_status",
2993 "A smoke case (`bynk test --smoke`) gets a non-5xx answer whose status is not among those its route's handler declares; the case still passes (warning).",
2994 &["case"],
2995 )),
2996 dg(
2997 "bynk.test.snapshot_duplicate_name",
2998 "A case takes two snapshots (`expect v matches snapshot \"name\"`) under one name; a snapshot is keyed by its case and name.",
2999 &["snapshot_expr"],
3000 ),
3001 dg(
3002 "bynk.test.snapshot_in_property",
3003 "A `property` takes a snapshot; its body runs once per generated input, so the snapshot belongs in a `case` over a fixed value.",
3004 &["snapshot_expr"],
3005 ),
3006 dg(
3007 "bynk.test.snapshot_name_not_literal",
3008 "`matches snapshot` is not followed by a string literal; a snapshot is named by a literal so the compiler knows every snapshot a suite takes.",
3009 &["snapshot_expr"],
3010 ),
3011 dg(
3012 "bynk.test.snapshot_needs_unit_suite",
3013 "A snapshot is taken in a `system`-tier case or in an integration or system suite; snapshots are stored per unit suite file and compared in the unit harness.",
3014 &["snapshot_expr"],
3015 ),
3016 dg(
3017 "bynk.test.snapshot_not_codable",
3018 "The value of an `expect … matches snapshot` is not `Codable`: a snapshot stores the value's `Json.encode` text, so it must be in the domain `Json.encode` accepts.",
3019 &["snapshot_expr"],
3020 ),
3021 dg(
3022 "bynk.test.stale_needs_timestamp",
3023 "A case drives `by Stale` at a `Signature` route whose actor declares no `timestamp` header and `tolerance`, so there is no replay window for the seam to refuse a stale signature by.",
3024 &["case"],
3025 ),
3026 dg(
3027 "bynk.test.unknown_actor",
3028 "A call-site `by <Actor>` names an actor the target context does not declare and that is not a prelude actor.",
3029 &["case"],
3030 ),
3031 dg(
3032 "bynk.test.wire_needs_system",
3033 "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.",
3034 &["case"],
3035 ),
3036 dg(
3037 "bynk.tier.cross_context_needs_system",
3038 "A `unit` or `integration` case, or a `property`, reaches another context's service, directly or through a target service or agent handler that calls one; below `system` no other context is stood up to call, so the flow belongs in a `suite … as system`.",
3039 &["case"],
3040 ),
3041 dg(
3042 "bynk.tier.mixed_system_suite",
3043 "A suite mixes `system` cases with `unit` or `integration` ones; a `system` case runs against deployed Workers and addresses services by context path, so it needs a `suite … as system` of its own.",
3044 &["case"],
3045 ),
3046 d(
3047 "bynk.tier.system_needs_wire",
3048 "An `as system` test stands up fewer than two contexts; the system tier wires across contexts.",
3049 ),
3050 d(
3051 "bynk.transition.cross_agent_reference",
3052 "A transition predicate references another agent; step invariants are per-agent.",
3053 ),
3054 d(
3055 "bynk.transition.duplicate_name",
3056 "An agent declares two transitions with the same name.",
3057 ),
3058 d(
3059 "bynk.transition.impure_predicate",
3060 "A transition predicate uses an effectful or test-only construct; a step invariant must be pure.",
3061 ),
3062 warn(d(
3063 "bynk.transition.may_violate",
3064 "A handler can make a move that an agent's `transition` refuses, from a state the agent can be in after a commit; at run time that call faults with `InvariantViolation` (warning). Resolve it in code: refuse the move first, with a `match` arm or an `is` test on the state field that the path can't get past.",
3065 )),
3066 d(
3067 "bynk.transition.no_step_reference",
3068 "A transition references neither `old` nor `new`; it constrains one state, so it is an `invariant`, not a step.",
3069 ),
3070 d(
3071 "bynk.transition.not_bool",
3072 "A transition predicate does not have type `Bool`.",
3073 ),
3074 dg(
3075 "bynk.types.argument_mismatch",
3076 "A call, method, capability, or constructor argument has the wrong type.",
3077 &["call"],
3078 ),
3079 d(
3080 "bynk.types.asset_at_boundary",
3081 "An `Asset` type appears in a record field, boundary or store position; pass its `.url` instead.",
3082 ),
3083 d(
3084 "bynk.types.bad_field_default",
3085 "A record or event field's default expression (`field: T = expr`) is not a static, wire-representable value of the field's declared type — a literal (including one admitted to a refined type), a sum variant, `Some`/`None`/`Ok`/`Err`, a record, a list literal, `Map.empty()`/`Set.empty()`, or `T.unsafe(lit)` for an opaque type whose literal also satisfies the refinement. A field whose type is a generic record's type parameter, or applies a user generic, has no default. (Earlier versions reported this as `bynk.event.bad_field_default`.)",
3086 ),
3087 dg(
3088 "bynk.types.call_arity",
3089 "A function value was applied with the wrong number of arguments.",
3090 &["call"],
3091 ),
3092 dg(
3093 "bynk.types.cannot_infer_option_type_param",
3094 "The value type of `None` could not be inferred.",
3095 &["none_expr"],
3096 ),
3097 d(
3098 "bynk.types.cannot_infer_result_type_params",
3099 "The type parameters of a `Result` could not be inferred.",
3100 ),
3101 dg(
3102 "bynk.types.catastrophic_regex",
3103 "A `Matches` pattern, or a regex method's pattern, can match the same text in exponentially many ways (nested or ambiguous repetition, bounded or not), or cannot be analysed, risking catastrophic backtracking (ReDoS).",
3104 &["refinement"],
3105 ),
3106 d(
3107 "bynk.types.claims_at_boundary",
3108 "`TokenClaims` appears where a value is stored or sent: a field of a type, or a boundary such as a call, a message or an agent.",
3109 ),
3110 dg(
3111 "bynk.types.combinator_return_mismatch",
3112 "A callback passed to a combinator (`map`/`andThen`/`flatMap`/`traverseAll`/…) returns the wrong type.",
3113 &["call"],
3114 ),
3115 d(
3116 "bynk.types.constructor_arity",
3117 "A variant constructor got the wrong number of arguments.",
3118 ),
3119 d(
3120 "bynk.types.constructor_base_mismatch",
3121 "A `.of` constructor was given an argument of the wrong base type.",
3122 ),
3123 d(
3124 "bynk.types.decimal_division_unscaled",
3125 "`/` was used on `Decimal` operands. A quotient has no exact decimal answer, so division states its scale and rounding mode: `a.div(b, 2, RoundingMode.HalfEven)` (#2622).",
3126 ),
3127 d(
3128 "bynk.types.decimal_negation_too_large",
3129 "A negated decimal literal would have more than 1000 characters of canonical text once its sign is counted, the most any `Decimal` may have (#2622).",
3130 ),
3131 dg(
3132 "bynk.types.derives_automatic",
3133 "A `derives` clause names `Eq`, `Key` or `Codable`, which hold for a type automatically; only `Ord` is opted into. The diagnostic carries a machine-applicable fix that removes the name (constrained-generics slice 1).",
3134 &["type_decl"],
3135 ),
3136 dg(
3137 "bynk.types.derives_field_not_orderable",
3138 "A type declares `derives Ord`, but one of its fields or payloads is not `Ord` (for example a `Map`, a `Set`, a `Bool`, a function, or a record that does not itself derive `Ord`); every part must be orderable for the declaration order to be a total order (constrained-generics slice 1).",
3139 &["type_decl"],
3140 ),
3141 dg(
3142 "bynk.types.duplicate_literal_arm",
3143 "A `match` has two arms for the same literal value.",
3144 &["match_arm"],
3145 ),
3146 dg(
3147 "bynk.types.duplicate_pattern_field",
3148 "A record pattern lists the same field twice.",
3149 &["record_pattern"],
3150 ),
3151 dg(
3152 "bynk.types.duplicate_variant_arm",
3153 "A `match` has two arms for the same variant.",
3154 &["match_arm"],
3155 ),
3156 d(
3157 "bynk.types.embeds_ambiguous",
3158 "A type is embedded by more than one variant of a sum, so `?`'s conversion would be ambiguous.",
3159 ),
3160 d(
3161 "bynk.types.embeds_unknown_variant",
3162 "An `embeds … as V` clause names a variant the sum does not declare.",
3163 ),
3164 d(
3165 "bynk.types.embeds_variant_shape",
3166 "An `embeds E as V` target variant must have exactly one payload field, of type `E`.",
3167 ),
3168 dg(
3169 "bynk.types.empty_range_pattern",
3170 "A range pattern or `via schema(...)` range has its bounds inverted (`lo > hi`), so it can never match.",
3171 &["int_range"],
3172 ),
3173 dg(
3174 "bynk.types.empty_refinement",
3175 "A refinement admits no values (contradictory predicates).",
3176 &["refinement"],
3177 ),
3178 dg(
3179 "bynk.types.err_value_mismatch",
3180 "An `Err` payload has the wrong type.",
3181 &["err_expr"],
3182 ),
3183 d(
3184 "bynk.types.extensible_match_needs_wildcard",
3185 "A `match` covers an extensible standard-library enum (`FetchError`, `Method`) without a wildcard; it may gain variants in a minor release.",
3186 ),
3187 dg(
3188 "bynk.types.field_access_on_non_record",
3189 "Field access on a value that is not a record.",
3190 &["field_access"],
3191 ),
3192 d(
3193 "bynk.types.field_default_on_variant",
3194 "A sum variant's payload field declares a default (`field: T = expr`). Only a record's fields may; a variant is built like a call, with every payload field given.",
3195 ),
3196 dg(
3197 "bynk.types.field_refinement_not_base",
3198 "An inline field refinement requires a base or refined type.",
3199 &["record_field"],
3200 ),
3201 dg(
3202 "bynk.types.field_value_mismatch",
3203 "A record field was given a value of the wrong type.",
3204 &["record_construction"],
3205 ),
3206 dg(
3207 "bynk.types.function_at_boundary",
3208 "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.",
3209 &["function_type_ref"],
3210 ),
3211 dg(
3212 "bynk.types.guard_not_bool",
3213 "A match-arm `if` guard is not a `Bool` expression.",
3214 &["match_arm"],
3215 ),
3216 d(
3217 "bynk.types.headers_at_boundary",
3218 "`RequestHeaders` appears where a value is stored or sent: a field of a type, or a boundary such as a call, a message or an agent.",
3219 ),
3220 d(
3221 "bynk.types.held_at_boundary",
3222 "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).",
3223 ),
3224 d(
3225 "bynk.types.held_not_comparable",
3226 "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
3227 ),
3228 dg(
3229 "bynk.types.if_branch_mismatch",
3230 "The branches of an `if` have different types.",
3231 &["if_expr"],
3232 ),
3233 dg(
3234 "bynk.types.if_non_bool_cond",
3235 "An `if` condition is not a `Bool`.",
3236 &["if_expr"],
3237 ),
3238 dg(
3239 "bynk.types.if_without_else_requires_unit",
3240 "An `if` with no `else` branch has a non-unit then-branch; the missing else defaults to `()`, so the branch must be `()` or `Effect[()]`.",
3241 &["if_expr"],
3242 ),
3243 d(
3244 "bynk.types.interpolation_non_scalar",
3245 "An interpolation hole holds a value with no string form.",
3246 ),
3247 dg(
3248 "bynk.types.invalid_regex",
3249 "A `Matches` predicate, or a regex method's pattern (`containsRegex`, …), contains an invalid regular expression or malformed inline flags.",
3250 &["refinement"],
3251 ),
3252 dg(
3253 "bynk.types.inverted_range",
3254 "An `InRange` predicate has its bounds inverted.",
3255 &["refinement"],
3256 ),
3257 dg(
3258 "bynk.types.is_base_mismatch",
3259 "An `is` refinement check is applied to a value of the wrong base type.",
3260 &["is_expr"],
3261 ),
3262 dg(
3263 "bynk.types.is_literal_pattern",
3264 "A literal was used on the right of `is`; `is` tests type/refinement, not value equality (use `==`).",
3265 &["is_expr"],
3266 ),
3267 dg(
3268 "bynk.types.is_non_sum",
3269 "`is` was applied to a value that is not a sum type.",
3270 &["is_expr"],
3271 ),
3272 dg(
3273 "bynk.types.is_range_pattern",
3274 "A range pattern was used directly on the right of `is`; `is` tests type/refinement, not value ranges (use `match`, a guard or `InRange`).",
3275 &["is_expr"],
3276 ),
3277 dg(
3278 "bynk.types.is_refined_pattern",
3279 "A refined (`where`) pattern was used on the right of `is`; refined patterns are `match`-only.",
3280 &["is_expr"],
3281 ),
3282 dg(
3283 "bynk.types.is_unknown_variant",
3284 "`is` names a variant the type does not have.",
3285 &["is_expr"],
3286 ),
3287 dg(
3288 "bynk.types.json_uncodable",
3289 "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, streams or a type that carries one, `bynk.crypto` keys, error builtins).",
3290 &["method_call"],
3291 ),
3292 d(
3293 "bynk.types.key_at_boundary",
3294 "A `bynk.crypto` `SigningKey` or `VerifyKey` appears in a storable or boundary-crossing position — a key is held non-extractable and lives for the call that imported it, never persisted, logged or sent (standard-library K4).",
3295 ),
3296 dg(
3297 "bynk.types.key_not_orderable",
3298 "A `sortBy`/`sortByDescending`/`min`/`max` key function does not return an orderable type. The key must be an `Ord` type, on a `List` and on a storage `Query` alike.",
3299 &[],
3300 ),
3301 dg(
3302 "bynk.types.lambda_mismatch",
3303 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
3304 &["lambda_expr"],
3305 ),
3306 dg(
3307 "bynk.types.let_annotation_mismatch",
3308 "A `let` value does not match its type annotation.",
3309 &["let_stmt"],
3310 ),
3311 dg(
3312 "bynk.types.list_element_mismatch",
3313 "A list-literal element has a different type from the list's element type.",
3314 &["list_literal"],
3315 ),
3316 dg(
3317 "bynk.types.list_pattern_on_non_list",
3318 "A list pattern is matched against a value that is not a `List` (a record, sum, base type, `Set` or `Map`).",
3319 &["list_pattern"],
3320 ),
3321 dg(
3322 "bynk.types.match_arm_mismatch",
3323 "A `match` arm has a different type from the others.",
3324 &["match_arm"],
3325 ),
3326 dg(
3327 "bynk.types.match_non_sum_discriminant",
3328 "`match` was applied to a value that is not a sum type.",
3329 &["match_expr"],
3330 ),
3331 dg(
3332 "bynk.types.method_arity",
3333 "A method was called with the wrong number of arguments.",
3334 &["method_call"],
3335 ),
3336 dg(
3337 "bynk.types.method_not_found",
3338 "Called a method the type does not have.",
3339 &["method_call"],
3340 ),
3341 dg(
3342 "bynk.types.method_on_non_named_type",
3343 "A method was called on a built-in type that has no methods.",
3344 &["method_call"],
3345 ),
3346 dg(
3347 "bynk.types.mixed_pattern_bindings",
3348 "A pattern mixes named and positional bindings.",
3349 &["variant_pattern"],
3350 ),
3351 dg(
3352 "bynk.types.negative_length",
3353 "A length predicate was given a negative value.",
3354 &["refinement"],
3355 ),
3356 dg(
3357 "bynk.types.never_inferred",
3358 "An unannotated `let` or `<-` binding has a type that is, or contains, the bottom type (`never returns`) because its value only faults (a faulting lambda bound this way included); the type cannot be written in source, so an annotation is needed.",
3359 &["let_stmt"],
3360 ),
3361 dg(
3362 "bynk.types.no_numeric_coercion",
3363 "`Int`, `Float` and `Decimal` were mixed without an explicit conversion — in an operation, a comparison or refinement bounds.",
3364 &["binary_expr", "refinement"],
3365 ),
3366 dg(
3367 "bynk.types.non_exhaustive_match",
3368 "A `match` does not cover every value.",
3369 &["match_expr"],
3370 ),
3371 d(
3372 "bynk.types.not_codable",
3373 "A type is instantiated at a `Codable`-bounded parameter (of a generic function, or of a capability operation) but is outside the domain `Json.decode` accepts: top-level `()`, a function, `Effect`, `Query`, a `Stream` or a type that carries one, a connection, the HTTP and queue result types, `Asset`, request headers, token claims, or an actor (constrained-generics slice 3).",
3374 ),
3375 d(
3376 "bynk.types.not_comparable",
3377 "A value compared with `==`/`!=` contains a function, `Effect`, or `Query` somewhere inside it — those have no value equality, so the type is not equality-supporting (type-system §2.3.5, #1652).",
3378 ),
3379 dg(
3380 "bynk.types.not_keyable",
3381 "A `Map` key, `Set` element, or `distinct`/`distinctBy`/`groupBy`/join key, or an argument to a `Key`-bounded parameter, is not `Key`. `String`, `Int`, `Bool`, `Instant`, `Duration`, `Bytes`, `Option`/`List` of a key type, refined and opaque types over them, and records, sums and enums made only of key types are; a `Float` is never one, at any depth, because `NaN` is not equal to itself (constrained-generics slice 2).",
3382 &["generic_type_ref"],
3383 ),
3384 d(
3385 "bynk.types.not_orderable",
3386 "A value is ordered (`<`, `<=`, `>`, `>=`), or passed to an `Ord`-bounded parameter, but its type is not `Ord`. `Int`, `Float`, `String`, `Duration`, `Instant`, `Bytes`, `Option`/`List` of an orderable type, refined types over those, and types that declare `derives Ord` are; adding `derives Ord` is offered as a fix that is never applied automatically, because it makes declaration order significant (constrained-generics slice 1).",
3387 ),
3388 dg(
3389 "bynk.types.ok_value_mismatch",
3390 "An `Ok` payload has the wrong type.",
3391 &["ok_expr"],
3392 ),
3393 dg(
3394 "bynk.types.opaque_raw_outside",
3395 "`.raw` on an opaque type was used outside its defining commons.",
3396 &["field_access"],
3397 ),
3398 dg(
3399 "bynk.types.opaque_unsafe_outside",
3400 "`.unsafe` on an opaque type was used outside its defining context.",
3401 &["field_access"],
3402 ),
3403 dg(
3404 "bynk.types.or_pattern_binding_mismatch",
3405 "An or-pattern's alternatives don't all bind the same set of names.",
3406 &["match_arm", "is_expr"],
3407 ),
3408 dg(
3409 "bynk.types.or_pattern_type_mismatch",
3410 "An or-pattern's alternatives give a shared binding different types (or refinements).",
3411 &["match_arm", "is_expr"],
3412 ),
3413 dg(
3414 "bynk.types.pattern_arity",
3415 "A pattern binds the wrong number of payload fields.",
3416 &["variant_pattern"],
3417 ),
3418 dg(
3419 "bynk.types.pattern_type_mismatch",
3420 "A pattern's type does not match the matched value.",
3421 &["variant_pattern"],
3422 ),
3423 dg(
3424 "bynk.types.polynomial_regex",
3425 "A `Matches` pattern can split the same text between repetitions, so matching time grows polynomially with input length, and no length predicate bounds the input small enough for its degree; a regex method's pattern has no bound to excuse it.",
3426 &["refinement"],
3427 ),
3428 warn(dg(
3429 "bynk.types.polynomial_regex_capped",
3430 "A `Matches` pattern's matching time grows polynomially with input length, but a `MaxLength` or `Length` predicate bounds the input small enough for its degree (warning).",
3431 &["refinement"],
3432 )),
3433 dg(
3434 "bynk.types.predicate_base_mismatch",
3435 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
3436 &["refinement"],
3437 ),
3438 d(
3439 "bynk.types.query_at_boundary",
3440 "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).",
3441 ),
3442 dg(
3443 "bynk.types.question_error_mismatch",
3444 "`?` propagates an error type incompatible with the function's.",
3445 &["question_expr"],
3446 ),
3447 dg(
3448 "bynk.types.question_on_non_result",
3449 "`?` was applied to a non-`Result` value.",
3450 &["question_expr"],
3451 ),
3452 dg(
3453 "bynk.types.question_option_outside_http",
3454 "`?` lifts an `Option` only inside a handler returning `HttpResult` (`None` becomes `NotFound`); elsewhere use `.okOr(err)`.",
3455 &["question_expr"],
3456 ),
3457 dg(
3458 "bynk.types.question_outside_result",
3459 "`?` used in a function that does not return a `Result`.",
3460 &["question_expr"],
3461 ),
3462 dg(
3463 "bynk.types.range_pattern_on_non_int",
3464 "A range pattern (`lo..hi`) was matched against a scrutinee that is not an `Int`.",
3465 &["int_range"],
3466 ),
3467 dg(
3468 "bynk.types.record_pattern_on_non_record",
3469 "A record pattern names a type that is not a record (a sum, enum, refined or opaque type, or a built-in).",
3470 &["record_pattern"],
3471 ),
3472 dg(
3473 "bynk.types.regex_not_literal",
3474 "A regex method's pattern (`matchesRegex`, `containsRegex`, `findRegex`, `findAllRegex`, `replaceRegex`, `splitRegex`) is not a string literal, so its ReDoS check cannot run at compile time.",
3475 &["method_call"],
3476 ),
3477 d(
3478 "bynk.types.rejection_at_boundary",
3479 "`BoundaryRejection` appears where a value is stored or sent: a field of a type, or a boundary such as a call, a message or an agent.",
3480 ),
3481 d(
3482 "bynk.types.request_query_at_boundary",
3483 "`RequestQuery` appears where a value is stored or sent: a field of a type, or a boundary such as a call, a message or an agent.",
3484 ),
3485 d(
3486 "bynk.types.return_mismatch",
3487 "A returned value does not match the declared return type.",
3488 ),
3489 d(
3490 "bynk.types.rounding_mode_position",
3491 "`RoundingMode.<mode>` was used outside the mode argument of a `Decimal`'s `round` or `div`. A mode is read where the rounding happens and is not a first-class value (#2622).",
3492 ),
3493 dg(
3494 "bynk.types.select_tail_has_select",
3495 "A `D1` `select[T]` or `firstAs[T]` statement begins with `SELECT`; the compiler writes the `SELECT` and column list from `T`, so the literal starts at `FROM`.",
3496 &["method_call"],
3497 ),
3498 dg(
3499 "bynk.types.sequence_needs_result",
3500 "`sequenceAll`/`sequenceTry` was called on a list whose elements are not `Result`s. They collect a `List[Result[T, E]]`.",
3501 &["method_call"],
3502 ),
3503 dg(
3504 "bynk.types.some_value_mismatch",
3505 "A `Some` payload has the wrong type.",
3506 &["some_expr"],
3507 ),
3508 dg(
3509 "bynk.types.sql_not_literal",
3510 "A `D1` statement's SQL (the first argument of `all`, `first`, `run`, `select` or `firstAs`, or a `SqlStatement`'s `sql`) is not a string literal, so data could be spliced into it instead of bound as a `SqlValue` parameter (standard-library P4c).",
3511 &["method_call", "record_construction", "record_spread"],
3512 ),
3513 dg(
3514 "bynk.types.sql_row_shape",
3515 "`Json.decodeSql[T]`'s (or `select[T]`'s, `firstAs[T]`'s) `T` is not a SQL row: a record whose fields are `Int`, `Float`, `String`, `Bool` or `Bytes` (or a refined or opaque type over one, or an `Option` of either), or a `List` of such records (standard-library P4c).",
3516 &["method_call"],
3517 ),
3518 d(
3519 "bynk.types.sql_statement_at_boundary",
3520 "A `bynk.cloudflare` `SqlStatement` appears in a storable or boundary-crossing position, or as a `Json` codec target — a statement from outside would carry SQL that was never a literal (standard-library P4c).",
3521 ),
3522 d(
3523 "bynk.types.stream_at_boundary",
3524 "A `Stream` type, or a record or sum carrying one in a field, 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; #2623 admits it in capability signatures and record fields).",
3525 ),
3526 d(
3527 "bynk.types.stream_not_comparable",
3528 "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
3529 ),
3530 d(
3531 "bynk.types.type_mismatch",
3532 "Two types that were required to match did not.",
3533 ),
3534 dg(
3535 "bynk.types.uninferable_element_type",
3536 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
3537 &["list_literal"],
3538 ),
3539 dg(
3540 "bynk.types.unknown_field",
3541 "Referenced a field the record type does not declare.",
3542 &["field_access"],
3543 ),
3544 dg(
3545 "bynk.types.unknown_pattern_field",
3546 "A pattern names a field the variant does not have.",
3547 &["variant_pattern"],
3548 ),
3549 d(
3550 "bynk.types.unknown_rounding_mode",
3551 "A `Decimal` `round` or `div` was not given a rounding mode written `RoundingMode.<mode>`; the modes are `Down`, `Up`, `Floor`, `Ceiling`, `HalfUp`, `HalfDown` and `HalfEven` (#2622).",
3552 ),
3553 dg(
3554 "bynk.types.unknown_static_member",
3555 "Referenced an unknown static member on a type.",
3556 &["field_access"],
3557 ),
3558 dg(
3559 "bynk.types.unknown_variant_in_pattern",
3560 "A pattern names a variant the sum type does not have.",
3561 &["variant_pattern"],
3562 ),
3563 dg(
3564 "bynk.types.unreachable_arm",
3565 "A `match` arm is unreachable.",
3566 &["match_arm"],
3567 ),
3568 d(
3569 "bynk.types.variant_arity",
3570 "A variant constructor got the wrong number of payload values.",
3571 ),
3572 d(
3573 "bynk.types.variant_missing_payload",
3574 "A variant requiring a payload was used without one.",
3575 ),
3576 d(
3577 "bynk.types.variant_payload_mismatch",
3578 "A variant payload has the wrong type.",
3579 ),
3580 dg(
3581 "bynk.uses.name_conflict",
3582 "A `uses` name collides with another name, a value crosses between a unit's code and an imported declaration's position whose type the unit shadows, or a reference names an import the unit's own declaration shadows.",
3583 &["uses_decl"],
3584 ),
3585 dg(
3586 "bynk.uses.self_reference",
3587 "A commons `uses` itself.",
3588 &["uses_decl"],
3589 ),
3590 dg(
3591 "bynk.uses.target_is_context",
3592 "`uses` targets a context instead of a commons.",
3593 &["uses_decl"],
3594 ),
3595 dg(
3596 "bynk.uses.unknown_commons",
3597 "`uses` names a commons that does not exist.",
3598 &["uses_decl"],
3599 ),
3600 dg(
3601 "bynk.val.agent_not_generable",
3602 "A `for all`/`Val` cannot generate an agent — fabricated agent states need not be reachable.",
3603 &["for_all"],
3604 ),
3605 dg(
3606 "bynk.val.arity",
3607 "`Val[T]` was given the wrong number of pin arguments.",
3608 &["val_expr"],
3609 ),
3610 dg(
3611 "bynk.val.literal_violates",
3612 "A pinned `Val[T]` value violates the type's refinement.",
3613 &["val_expr"],
3614 ),
3615 dg(
3616 "bynk.val.needs_pin",
3617 "A bare `Val[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
3618 &["val_expr"],
3619 ),
3620 dg(
3621 "bynk.val.outside_test",
3622 "`Val[T]` was used outside a test case body.",
3623 &["val_expr"],
3624 ),
3625 dg(
3626 "bynk.val.pin_not_literal",
3627 "A `Val[T]` pin argument is not a compile-time literal.",
3628 &["val_expr"],
3629 ),
3630 dg(
3631 "bynk.val.pin_unsupported",
3632 "A pin was given for a type kind that does not support pinning.",
3633 &["val_expr"],
3634 ),
3635 dg(
3636 "bynk.val.unknown_type",
3637 "`Val[T]` names a type that does not resolve.",
3638 &["val_expr"],
3639 ),
3640 dg(
3641 "bynk.val.unsupported_kind",
3642 "`Val[T]` cannot fabricate a value for this kind of type.",
3643 &["val_expr"],
3644 ),
3645 dg(
3646 "bynk.visibility.private_in_public",
3647 "A public declaration's signature names a `private` type of its own unit, which an importer could neither name nor build.",
3648 &["visibility_modifier"],
3649 ),
3650 dg(
3651 "bynk.visibility.private_item",
3652 "A reference from another unit names a `private` declaration, which is visible only within its own unit and that unit's suites.",
3653 &["visibility_modifier"],
3654 ),
3655 warn(dg(
3656 "bynk.visibility.private_messages",
3657 "A `messages` block in a commons is `private`. A bundle whose `@reference` block is private is never negotiated by a context that uses the commons, and `private` on another block of a bundle whose reference is public has no effect (warning).",
3658 &["visibility_modifier"],
3659 )),
3660 dg(
3661 "bynk.visibility.private_not_allowed",
3662 "`private` modifies a declaration it does not apply to: anything but a `fn`, `type`, `messages`, `asset`, `embed` or `const` in a commons or context.",
3663 &["visibility_modifier"],
3664 ),
3665 d(
3666 "bynk.wasm.panic",
3667 "The in-browser compiler panicked internally (a compiler bug, reported as a diagnostic instead of crashing the page).",
3668 ),
3669 d(
3670 "bynk.wasm.strip_failed",
3671 "The in-browser compiler could not strip the emitted TypeScript to JavaScript.",
3672 ),
3673 dg(
3674 "bynk.within.in_agent_handler",
3675 "`e.within(d)` was used in an agent handler, which has no execution context to hand the abandoned effect to.",
3676 &["method_call"],
3677 ),
3678 dg(
3679 "bynk.within.in_pure_context",
3680 "`e.within(d)` was used in a pure (non-effectful) context.",
3681 &["method_call"],
3682 ),
3683 dg(
3684 "bynk.within.outside_handler",
3685 "`e.within(d)` was used outside a service handler's body and outside a function (in a provider operation, a WebSocket handler or a test `case` body), where no execution context exists.",
3686 &["method_call"],
3687 ),
3688 dg(
3689 "bynk.within.timed_out_not_in_scope",
3690 "`e.within(d)` yields `Result[_, TimedOut]`, but the unit does not consume `bynk`, so `TimedOut` is not in scope.",
3691 &["method_call"],
3692 ),
3693 d(
3694 "bynk.ws.message_frame_param",
3695 "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).",
3696 ),
3697 d(
3698 "bynk.ws.open_given_unsupported",
3699 "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).",
3700 ),
3701 d(
3702 "bynk.ws.open_transfer_cross_file",
3703 "On the Workers target, a WebSocket `on open` handler transfers its `connection` to an agent declared in a different file of the same context — the open is hosted in the agent's Durable Object, which is emitted from the agent's own file, so the upgrade would never be handled; the service and the agent must share a file.",
3704 ),
3705 d(
3706 "bynk.ws.open_transfer_shape",
3707 "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).",
3708 ),
3709 d(
3710 "bynk.ws.route_param_mismatch",
3711 "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).",
3712 ),
3713];
3714
3715const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
3717 DiagnosticInfo {
3718 code,
3719 summary,
3720 grammar_symbol: &[],
3721 severity: Severity::Error,
3722 }
3723}
3724
3725const fn dg(
3727 code: &'static str,
3728 summary: &'static str,
3729 grammar_symbol: &'static [&'static str],
3730) -> DiagnosticInfo {
3731 DiagnosticInfo {
3732 code,
3733 summary,
3734 grammar_symbol,
3735 severity: Severity::Error,
3736 }
3737}
3738
3739const fn warn(mut info: DiagnosticInfo) -> DiagnosticInfo {
3743 info.severity = Severity::Warning;
3744 info
3745}
3746
3747const fn hint(mut info: DiagnosticInfo) -> DiagnosticInfo {
3750 info.severity = Severity::Hint;
3751 info
3752}
3753
3754pub fn category(code: &str) -> &str {
3757 code.split('.').nth(1).unwrap_or("")
3758}
3759
3760fn category_title(cat: &str) -> &'static str {
3762 match cat {
3763 "agent" | "agents" => "Agents",
3764 "asset" => "Static assets",
3765 "boundary" => "Boundaries",
3766 "capability" => "Capabilities",
3767 "cloudflare" => "Cloudflare",
3768 "consumes" => "Consumes",
3769 "context" => "Contexts",
3770 "contract" => "Contracts",
3771 "cron" => "Cron",
3772 "doc" => "Doc comments",
3773 "effect" => "Effects",
3774 "embed" => "Embedded text",
3775 "expect" => "Expectations",
3776 "exports" => "Exports",
3777 "given" => "Given capabilities",
3778 "http" => "HTTP",
3779 "lex" => "Lexer",
3780 "messages" => "Message bundles",
3781 "mock" => "Mocks (collaborators)",
3782 "observe" => "Observation",
3783 "parse" => "Parser",
3784 "project" => "Project",
3785 "property" => "Properties (generative tests)",
3786 "provider" => "Providers",
3787 "queue" => "Queue",
3788 "record_spread" => "Record spread",
3789 "refine" => "Refinement",
3790 "resolve" => "Resolution",
3791 "service" => "Services",
3792 "stability" => "Stability",
3793 "suite" => "Suites and cases",
3794 "transition" => "Transitions (step invariants)",
3795 "types" => "Type checking",
3796 "uses" => "Uses",
3797 "val" => "Value fabrication",
3798 _ => "Other",
3799 }
3800}
3801
3802pub fn render_markdown() -> String {
3806 use std::collections::BTreeMap;
3807
3808 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3810 for info in REGISTRY {
3811 by_category
3812 .entry(category_title(category(info.code)))
3813 .or_default()
3814 .push(info);
3815 }
3816
3817 let mut out = String::new();
3818 out.push_str("# Diagnostic index\n\n");
3819 out.push_str(
3820 "<!-- GENERATED FILE — do not edit by hand.\n \
3821 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
3822 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test it diagnostics_registry:: -->\n\n",
3823 );
3824 out.push_str(
3825 "Every diagnostic code the compiler can emit, with a one-line summary of \
3826 the cause, grouped by category. For step-by-step cause-and-fix guidance \
3827 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md). \
3828 For a code with a curated explanation, `bynk explain <code>` prints it in a \
3829 terminal, and in VS Code the diagnostic's **Explain** quick fix (or \
3830 **Bynk: Explain Diagnostic Code…**) shows the same text in a panel, offline.\n\n",
3831 );
3832 out.push_str(&format!(
3833 "There are **{}** codes in total.\n",
3834 REGISTRY.len()
3835 ));
3836
3837 for (title, infos) in &by_category {
3838 out.push_str(&format!("\n## {title}\n\n"));
3839 out.push_str("| Code | Summary | Construct | Severity |\n|---|---|---|---|\n");
3840 for info in infos {
3841 let construct = info
3846 .grammar_symbol
3847 .iter()
3848 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
3849 .collect::<Vec<_>>()
3850 .join(", ");
3851 let code_cell = match explain(info.code) {
3856 Some(e) => format!("[`{}`]({})", info.code, e.in_site_link()),
3857 None => format!("`{}`", info.code),
3858 };
3859 let severity = match info.severity {
3864 Severity::Error => "—",
3865 Severity::Warning => "Warning",
3866 Severity::Hint => "Hint",
3867 };
3868 out.push_str(&format!(
3869 "| {} | {} | {} | {} |\n",
3870 code_cell, info.summary, construct, severity
3871 ));
3872 }
3873 }
3874
3875 out
3876}
3877
3878pub fn render_grammar_semantics_json() -> String {
3884 use std::collections::BTreeMap;
3885
3886 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3889 for info in REGISTRY {
3890 for sym in info.grammar_symbol {
3891 by_symbol.entry(sym).or_default().push(info);
3892 }
3893 }
3894
3895 let mut map = serde_json::Map::new();
3896 map.insert(
3897 "_generated".to_string(),
3898 serde_json::Value::String(
3899 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
3900 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
3901 bynkc --test it diagnostics_registry::"
3902 .to_string(),
3903 ),
3904 );
3905 for (sym, infos) in by_symbol {
3906 let arr: Vec<serde_json::Value> = infos
3907 .iter()
3908 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
3909 .collect();
3910 map.insert(sym.to_string(), serde_json::Value::Array(arr));
3911 }
3912
3913 let mut s =
3914 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
3915 s.push('\n');
3916 s
3917}