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.type_alias_capability",
818 "A capability was aliased in `consumes U { Cap as Alias }`; only exported types can be aliased.",
819 &["consumes_decl"],
820 ),
821 dg(
822 "bynk.consumes.type_alias_conflict",
823 "A `consumes U { T as Alias }` alias collides with a type or value in scope, or with another alias.",
824 &["consumes_decl"],
825 ),
826 dg(
827 "bynk.consumes.type_alias_repeated",
828 "An exported type is aliased more than once, or is selected both bare and aliased, in `consumes U { … }`.",
829 &["consumes_decl"],
830 ),
831 dg(
832 "bynk.consumes.type_alias_unknown_export",
833 "`consumes U { T as Alias }` names a type `U` does not export.",
834 &["consumes_decl"],
835 ),
836 dg(
837 "bynk.consumes.unknown_context",
838 "`consumes` names a context that does not exist.",
839 &["consumes_decl"],
840 ),
841 dg(
842 "bynk.consumes.unknown_service",
843 "Called a service the consumed context does not declare.",
844 &["consumes_decl"],
845 ),
846 d(
847 "bynk.context.consumes_cycle",
848 "Contexts form a `consumes` dependency cycle.",
849 ),
850 d(
851 "bynk.context.duplicate_binding",
852 "A Worker would declare two bindings with the same name, such as an agent `Kv` and the `bynk.cloudflare` KV namespace (both `KV`).",
853 ),
854 d(
855 "bynk.context.external_construction",
856 "A context-owned type was constructed from outside that context.",
857 ),
858 d(
859 "bynk.context.external_decode",
860 "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.",
861 ),
862 dg(
863 "bynk.context.external_provider",
864 "A bodiless (external) provider was declared outside an `adapter`.",
865 &["provider_decl"],
866 ),
867 d(
868 "bynk.context.opaque_inspection",
869 "An opaquely-exported type was inspected from outside its context.",
870 ),
871 d(
872 "bynk.context.rebrand_construction",
873 "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.",
874 ),
875 d(
876 "bynk.contract.duplicate_name",
877 "A function declares two contract clauses (`requires`/`ensures`) with the same name.",
878 ),
879 d(
880 "bynk.contract.impure_predicate",
881 "A contract predicate uses an effectful or test-only construct; a contract clause must be pure.",
882 ),
883 d(
884 "bynk.contract.not_bool",
885 "A contract predicate does not have type `Bool`.",
886 ),
887 d(
888 "bynk.contract.restated_by_test",
889 "A `case`/`property` merely restates a contract clause already declared at the function; the test is redundant.",
890 ),
891 d(
892 "bynk.contract.result_in_requires",
893 "A precondition (`requires`) references `result`; the return value is only in scope inside an `ensures`.",
894 ),
895 dg(
896 "bynk.cron.bad_params",
897 "A cron handler declares more than one parameter, or a non-`Int` one.",
898 &["cron_handler"],
899 ),
900 dg(
901 "bynk.cron.duplicate_schedule",
902 "Two cron handlers declare the same schedule.",
903 &["cron_handler"],
904 ),
905 dg(
906 "bynk.cron.invalid_schedule",
907 "A cron expression is not five whitespace-separated fields.",
908 &["cron_handler"],
909 ),
910 dg(
911 "bynk.cron.return_not_effect_result",
912 "A cron handler does not return `Effect[Result[(), E]]`.",
913 &["cron_handler"],
914 ),
915 d(
916 "bynk.d1.migration_name",
917 "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.",
918 ),
919 d(
920 "bynk.d1.migration_unreadable",
921 "A `D1` migration in the project's `migrations/` folder can't be read, or isn't UTF-8 text.",
922 ),
923 warn(d(
924 "bynk.d1.migrations_unused",
925 "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).",
926 )),
927 d(
928 "bynk.dependency.path_outside_root",
929 "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.",
930 ),
931 d(
932 "bynk.deploy.contract_skew",
933 "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.",
934 ),
935 d(
936 "bynk.deploy.foreign_contract_skew",
937 "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.",
938 ),
939 warn(d(
942 "bynk.doc.unresolved_link",
943 "A `[Name]` doc link resolves to nothing in the unit's scope (editor hint only).",
944 )),
945 d(
946 "bynk.duration.literal_overflow",
947 "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
948 ),
949 dg(
950 "bynk.effect.bind_in_pure_context",
951 "An `<-` bind was used in a pure (non-effectful) context.",
952 &["effect_let_stmt"],
953 ),
954 dg(
955 "bynk.effect.bind_on_non_effect",
956 "An `<-` bind was applied to a non-`Effect` value.",
957 &["effect_let_stmt"],
958 ),
959 d(
960 "bynk.effect.capability_in_pure_context",
961 "A capability was used in a pure context.",
962 ),
963 d(
964 "bynk.effect.cross_context_in_pure_context",
965 "A cross-context call was made in a pure context.",
966 ),
967 dg(
968 "bynk.effect.do_in_pure_context",
969 "A `do` statement was used in a pure (non-effectful) context.",
970 &["do_stmt"],
971 ),
972 dg(
973 "bynk.effect.do_on_non_effect",
974 "A `do` statement was applied to a non-`Effect` value.",
975 &["do_stmt"],
976 ),
977 dg(
978 "bynk.effect.do_requires_unit",
979 "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.",
980 &["do_stmt"],
981 ),
982 dg(
983 "bynk.effect.fn_value_in_pure_context",
984 "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
985 &["call"],
986 ),
987 d(
988 "bynk.effect.unbound_effect",
989 "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).",
990 ),
991 d(
992 "bynk.embed.binary_content",
993 "An `embed` names a file with a NUL byte, so it is binary, not text.",
994 ),
995 d(
996 "bynk.embed.duplicate",
997 "An `embed` name is declared more than once in the same unit.",
998 ),
999 d(
1000 "bynk.embed.invalid_encoding",
1001 "An `embed` names a file that is not valid UTF-8.",
1002 ),
1003 d(
1004 "bynk.embed.missing_file",
1005 "An `embed` names a file that is not in the project's `embeds/` folder.",
1006 ),
1007 d(
1008 "bynk.embed.needs_project",
1009 "A single-file build met an `embed` declaration, which needs a project's `embeds/` folder.",
1010 ),
1011 d(
1012 "bynk.embed.outside_context_or_commons",
1013 "An `embed` declaration appears outside a context or commons.",
1014 ),
1015 d(
1016 "bynk.embed.outside_embeds_dir",
1017 "An `embed` names a file outside the project's `embeds/` folder.",
1018 ),
1019 d(
1020 "bynk.embed.too_large",
1021 "An `embed` names a file over 256 KiB, or the project's embedded files total over 1 MiB.",
1022 ),
1023 d(
1024 "bynk.embed.unreadable_file",
1025 "An `embed` names a file in the project's `embeds/` folder that could not be read.",
1026 ),
1027 d(
1028 "bynk.embed.unsafe_path",
1029 "An `embed` path is empty, absolute, or contains a `..` segment.",
1030 ),
1031 d(
1032 "bynk.event.bad_params",
1033 "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.",
1034 ),
1035 d(
1036 "bynk.event.bad_schema_dispatch",
1037 "A `via schema(...)` dispatch clause's argument is malformed — it must be a positive `Int` literal, a range of positive `Int` literals, or `_`.",
1038 ),
1039 d(
1040 "bynk.event.bad_schema_version",
1041 "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.",
1042 ),
1043 dg(
1044 "bynk.event.duplicate_handler",
1045 "A `from Events` service declares more than one `on event` handler; it has exactly one.",
1046 &["event_handler"],
1047 ),
1048 d(
1049 "bynk.event.emit_not_an_event",
1050 "`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.",
1051 ),
1052 d(
1053 "bynk.event.emit_outside_owner",
1054 "`Events.emit[E]` named an event `E` not declared in the emitting context — only an event's declaring context may emit it.",
1055 ),
1056 d(
1057 "bynk.event.handler_param_type_mismatch",
1058 "An `on event(e: T)` handler's declared parameter type does not match its `from Events(E)` header's event type.",
1059 ),
1060 d(
1061 "bynk.event.non_additive_schema_change",
1062 "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.",
1063 ),
1064 d(
1065 "bynk.event.outside_context",
1066 "An `event` was declared outside a context.",
1067 ),
1068 d(
1069 "bynk.event.pattern_duplicate_field",
1070 "A `from Events(E { ... })` subscription pattern listed the same field more than once.",
1071 ),
1072 d(
1073 "bynk.event.pattern_type_mismatch",
1074 "A `from Events(E { ... })` subscription pattern field's matched value is not compatible with that field's declared type.",
1075 ),
1076 d(
1077 "bynk.event.pattern_unknown_field",
1078 "A `from Events(E { ... })` subscription pattern named a field that `E` does not declare.",
1079 ),
1080 d(
1081 "bynk.event.pattern_unknown_variant",
1082 "A `from Events(E { ... })` subscription pattern's variant value names a variant that does not exist on the field's declared sum type.",
1083 ),
1084 d(
1085 "bynk.event.pattern_variant_payload",
1086 "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.",
1087 ),
1088 dg(
1089 "bynk.event.return_not_effect_unit",
1090 "An `on event` handler returns an `Effect` of something other than `()`; emission is fire-and-forget, so it returns `Effect[()]`.",
1091 &["event_handler"],
1092 ),
1093 d(
1094 "bynk.event.schema_version_mismatch",
1095 "An event's `@schema(N)` annotation disagrees with the version the schema registry computes from the event's build history.",
1096 ),
1097 d(
1098 "bynk.event.unknown_annotation",
1099 "An `event` declaration carried an `@`-annotation other than `@schema` — event annotations are a closed set.",
1100 ),
1101 d(
1102 "bynk.event.unknown_subscription",
1103 "A `from Events(E)` subscription named `E`, which is not a declared event in this context or any consumed context.",
1104 ),
1105 d(
1106 "bynk.exec.unavailable",
1107 "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.",
1108 ),
1109 dg(
1110 "bynk.expect.faults_not_effect",
1111 "A fault claim's subject (`expect <call> faults`) is not an effectful call: a value, or a call whose type is not `Effect[_]`.",
1112 &["faults_expr"],
1113 ),
1114 dg(
1115 "bynk.expect.not_bool",
1116 "`expect` was given a non-`Bool` predicate.",
1117 &["expect_expr"],
1118 ),
1119 dg(
1120 "bynk.expect.outside_case",
1121 "`expect` was used outside a `case` body.",
1122 &["expect_expr"],
1123 ),
1124 dg(
1125 "bynk.exports.capability_not_provided",
1126 "An exported capability has no provider in its context.",
1127 &["exports_decl"],
1128 ),
1129 dg(
1130 "bynk.exports.conflicting_visibility",
1131 "A type is exported with conflicting visibilities.",
1132 &["exports_decl"],
1133 ),
1134 dg(
1135 "bynk.exports.derived_capability",
1136 "`exports capability` names a derived capability, whose instance stays with its context.",
1137 &["exports_decl"],
1138 ),
1139 dg(
1140 "bynk.exports.duplicate_export",
1141 "The same name is exported more than once.",
1142 &["exports_decl"],
1143 ),
1144 dg(
1145 "bynk.exports.duplicate_in_clause",
1146 "A name appears twice in one `exports` clause.",
1147 &["exports_decl"],
1148 ),
1149 dg(
1150 "bynk.exports.undeclared_capability",
1151 "`exports capability` names a capability that is not declared.",
1152 &["exports_decl"],
1153 ),
1154 dg(
1155 "bynk.exports.undeclared_type",
1156 "`exports` names a type that is not declared.",
1157 &["exports_decl"],
1158 ),
1159 warn(d(
1160 "bynk.fault.todo",
1161 "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).",
1162 )),
1163 dg(
1164 "bynk.fixture.binary_content",
1165 "A suite's `fixture` names a file that contains a NUL byte, so it is binary, not text.",
1166 &["fixture_decl"],
1167 ),
1168 dg(
1169 "bynk.fixture.duplicate",
1170 "A suite declares two `fixture`s of the same name.",
1171 &["fixture_decl"],
1172 ),
1173 dg(
1174 "bynk.fixture.invalid_encoding",
1175 "A suite's `fixture` names a file that is not valid UTF-8.",
1176 &["fixture_decl"],
1177 ),
1178 dg(
1179 "bynk.fixture.missing_file",
1180 "A suite's `fixture` names a file that is not in the project's `fixtures/` folder.",
1181 &["fixture_decl"],
1182 ),
1183 dg(
1184 "bynk.fixture.outside_fixtures_dir",
1185 "A suite's `fixture` names a file outside the project's `fixtures/` folder.",
1186 &["fixture_decl"],
1187 ),
1188 dg(
1189 "bynk.fixture.too_large",
1190 "A suite's `fixture` names a file over the 4 MiB limit for one fixture file.",
1191 &["fixture_decl"],
1192 ),
1193 dg(
1194 "bynk.fixture.unreadable_file",
1195 "A suite's `fixture` names a listed file that could not be read.",
1196 &["fixture_decl"],
1197 ),
1198 dg(
1199 "bynk.fixture.unsafe_path",
1200 "A suite's `fixture` path is empty, absolute or contains a `..` segment.",
1201 &["fixture_decl"],
1202 ),
1203 warn(dg(
1204 "bynk.fixture.unused",
1205 "A suite declares a `fixture` that none of its cases, properties or helpers uses (warning).",
1206 &["fixture_decl"],
1207 )),
1208 d(
1209 "bynk.fmt.comment_loss",
1210 "The formatter would drop a comment, so it leaves the file unchanged.",
1211 ),
1212 d(
1213 "bynk.fmt.mixed_comment_syntax",
1214 "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.",
1215 ),
1216 d(
1217 "bynk.fmt.roundtrip",
1218 "The formatter's output does not re-parse to the same program, so it leaves the file unchanged.",
1219 ),
1220 dg(
1221 "bynk.generics.ambiguous_instantiation",
1222 "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).",
1223 &["fn_decl"],
1224 ),
1225 dg(
1226 "bynk.generics.bound_on_capability_op",
1227 "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).",
1228 &["capability_op"],
1229 ),
1230 dg(
1231 "bynk.generics.codable_op_return",
1232 "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).",
1233 &["capability_op"],
1234 ),
1235 dg(
1236 "bynk.generics.duplicate_type_param",
1237 "A `type` or `fn` declares the same type-parameter name more than once (v0.157, ADR 0183).",
1238 &[],
1239 ),
1240 dg(
1241 "bynk.generics.generic_non_record",
1242 "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).",
1243 &["type_decl"],
1244 ),
1245 dg(
1246 "bynk.generics.generic_record_at_boundary",
1247 "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.",
1248 &[],
1249 ),
1250 dg(
1251 "bynk.generics.generic_sum_embeds",
1252 "A generic sum type carries an `embeds` clause; embedding into a generic sum is not supported (#593).",
1253 &["type_decl"],
1254 ),
1255 dg(
1256 "bynk.generics.method_on_generic_type",
1257 "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).",
1258 &["fn_decl"],
1259 ),
1260 dg(
1261 "bynk.generics.missing_codable_bound",
1262 "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).",
1263 &["fn_decl"],
1264 ),
1265 dg(
1266 "bynk.generics.missing_eq_bound",
1267 "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).",
1268 &["fn_decl"],
1269 ),
1270 dg(
1271 "bynk.generics.missing_key_bound",
1272 "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).",
1273 &["fn_decl"],
1274 ),
1275 dg(
1276 "bynk.generics.missing_ord_bound",
1277 "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).",
1278 &["fn_decl"],
1279 ),
1280 dg(
1281 "bynk.generics.recursive_generic_at_boundary",
1282 "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).",
1283 &[],
1284 ),
1285 warn(dg(
1286 "bynk.generics.redundant_eq_bound",
1287 "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).",
1288 &["fn_decl"],
1289 )),
1290 dg(
1291 "bynk.generics.type_arg_count",
1292 "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).",
1293 &["applied_type_ref"],
1294 ),
1295 dg(
1296 "bynk.generics.type_arg_mismatch",
1297 "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
1298 &["call"],
1299 ),
1300 dg(
1301 "bynk.generics.uninferable_type_arg",
1302 "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.",
1303 &["call"],
1304 ),
1305 dg(
1306 "bynk.generics.unknown_constraint",
1307 "A bound names something that is not a constraint; `Eq` is the only one.",
1308 &["type_param"],
1309 ),
1310 dg(
1311 "bynk.generics.unknown_where_param",
1312 "A method's `where` clause bounds a name that is not a type parameter of the method or of its receiver type.",
1313 &["where_clause"],
1314 ),
1315 dg(
1316 "bynk.given.cross_context_unknown_capability",
1317 "`given B.Cap` names a capability the consumed context does not export.",
1318 &["given_clause"],
1319 ),
1320 dg(
1321 "bynk.given.fn_outside_context",
1322 "A function in a commons (or a suite) declares `given`; only a context function can.",
1323 &["given_clause"],
1324 ),
1325 dg(
1326 "bynk.given.fn_unsupported",
1327 "A `given` clause on a method, on a function that does not return `Effect[T]`, or naming `Events`.",
1328 &["given_clause"],
1329 ),
1330 dg(
1331 "bynk.given.missing_for_call",
1332 "A call to a function that declares `given` from a body that does not declare those capabilities.",
1333 &["given_clause"],
1334 ),
1335 dg(
1336 "bynk.given.undeclared_capability",
1337 "A handler uses a capability it did not declare with `given`.",
1338 &["given_clause"],
1339 ),
1340 dg(
1341 "bynk.given.unknown_capability",
1342 "`given` names a capability that does not exist.",
1343 &["given_clause"],
1344 ),
1345 warn(dg(
1346 "bynk.given.unused_capability",
1347 "A `given` capability is never used (warning).",
1348 &["given_clause"],
1349 )),
1350 d(
1351 "bynk.held.branch_divergence",
1352 "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).",
1353 ),
1354 d(
1355 "bynk.held.consume_on_borrow",
1356 "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).",
1357 ),
1358 d(
1359 "bynk.held.leak",
1360 "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).",
1361 ),
1362 d(
1363 "bynk.held.query_accessor_on_held_map",
1364 "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.",
1365 ),
1366 d(
1367 "bynk.held.unsupported_map_op",
1368 "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).",
1369 ),
1370 d(
1371 "bynk.held.unsupported_storage",
1372 "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).",
1373 ),
1374 d(
1375 "bynk.held.use_after_consume",
1376 "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).",
1377 ),
1378 d(
1379 "bynk.history.not_an_agent",
1380 "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).",
1381 ),
1382 d(
1383 "bynk.history.not_generable",
1384 "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).",
1385 ),
1386 d(
1387 "bynk.history.outside_property",
1388 "`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).",
1389 ),
1390 d(
1391 "bynk.history.restates_invariant",
1392 "A history property merely re-checks a guarantee a declared `invariant`/`transition` already enforces on every reached state (testing track slice 7, ADR 0155).",
1393 ),
1394 dg(
1395 "bynk.http.body_on_get_or_delete",
1396 "A GET or DELETE handler declares a `body` parameter.",
1397 &["http_handler"],
1398 ),
1399 d(
1400 "bynk.http.cache_bad_immutable",
1401 "A `@cache` annotation's `immutable` is not a `Bool` literal.",
1402 ),
1403 d(
1404 "bynk.http.cache_bad_max_age",
1405 "A `@cache` annotation's `maxAge` is missing or not a positive `Duration` literal.",
1406 ),
1407 d(
1408 "bynk.http.cache_bad_scope",
1409 "A `@cache` annotation's `scope` is not `public` or `private`.",
1410 ),
1411 d(
1412 "bynk.http.cache_duplicate",
1413 "A handler carries more than one `@cache` annotation.",
1414 ),
1415 d(
1416 "bynk.http.cache_max_age_fractional_seconds",
1417 "A `@cache` annotation's `maxAge` is positive but does not resolve to a whole number of seconds.",
1418 ),
1419 d(
1420 "bynk.http.cache_on_non_get",
1421 "A `@cache` annotation is placed on a handler that is not `on http GET`.",
1422 ),
1423 d(
1424 "bynk.http.cache_unknown_arg",
1425 "A `@cache` annotation has an argument outside the closed set (`maxAge`/`scope`/`immutable`).",
1426 ),
1427 d(
1428 "bynk.http.cors_invalid_field",
1429 "A `cors` policy field (`headers`/`credentials`/`maxAge`) has the wrong value shape.",
1430 ),
1431 d(
1432 "bynk.http.cors_invalid_origins",
1433 "A `cors` policy's `origins` is missing, empty, or not a list of string literals.",
1434 ),
1435 d(
1436 "bynk.http.cors_not_http",
1437 "A `cors { }` policy appears on a service that is not `from http`.",
1438 ),
1439 d(
1440 "bynk.http.cors_unknown_field",
1441 "A `cors { }` policy declares a field outside the closed set.",
1442 ),
1443 d(
1444 "bynk.http.cors_wildcard_credentials",
1445 "A `cors` policy combines `credentials: true` with the wildcard origin `[\"*\"]`.",
1446 ),
1447 dg(
1448 "bynk.http.duplicate_rejected",
1449 "A `from http` service declares `on rejected` more than once.",
1450 &["rejected_handler"],
1451 ),
1452 dg(
1453 "bynk.http.duplicate_route",
1454 "Two handlers share the same method and route.",
1455 &["http_handler"],
1456 ),
1457 d(
1458 "bynk.http.error_status_position",
1459 "An `ErrorStatus` name is used anywhere but as `RawError`'s first argument.",
1460 ),
1461 dg(
1462 "bynk.http.extra_param",
1463 "A handler parameter is not a path parameter, `body`, `headers` or `query`.",
1464 &["http_handler"],
1465 ),
1466 dg(
1467 "bynk.http.headers_wrong_type",
1468 "An HTTP handler's `headers` parameter is not typed `RequestHeaders`.",
1469 &["http_handler"],
1470 ),
1471 dg(
1472 "bynk.http.invalid_path",
1473 "An HTTP route path is malformed.",
1474 &["http_handler"],
1475 ),
1476 d(
1477 "bynk.http.json_duplicate",
1478 "A handler carries more than one `@json` annotation.",
1479 ),
1480 d(
1481 "bynk.http.json_invalid_arg",
1482 "A `@json` annotation's `options` argument is missing or is not `tagged` or `plain`.",
1483 ),
1484 d(
1485 "bynk.http.json_invalid_field",
1486 "A `json { }` policy's `options` is not `tagged` or `plain`.",
1487 ),
1488 d(
1489 "bynk.http.json_not_http",
1490 "A `json { }` policy appears on a service that is not `from http`.",
1491 ),
1492 d(
1493 "bynk.http.json_on_non_http",
1494 "A `@json` annotation is placed on a handler that is not `on http`.",
1495 ),
1496 d(
1497 "bynk.http.json_unknown_arg",
1498 "A `@json` annotation has an argument outside the closed set (`options`).",
1499 ),
1500 d(
1501 "bynk.http.json_unknown_field",
1502 "A `json { }` policy declares a field outside the closed set (`options`).",
1503 ),
1504 d(
1505 "bynk.http.limit_bad_max_body",
1506 "A `@limit` annotation's `maxBody` is missing or not a positive `Int` literal.",
1507 ),
1508 d(
1509 "bynk.http.limit_duplicate",
1510 "A handler carries more than one `@limit` annotation.",
1511 ),
1512 d(
1513 "bynk.http.limit_on_bodyless",
1514 "A `@limit` annotation is placed on a handler that takes no body (a GET or DELETE).",
1515 ),
1516 d(
1517 "bynk.http.limit_unknown_arg",
1518 "A `@limit` annotation has an argument outside the closed set (`maxBody`).",
1519 ),
1520 d(
1521 "bynk.http.limits_invalid_field",
1522 "A `limits` policy field (`maxBody`) has the wrong value shape.",
1523 ),
1524 d(
1525 "bynk.http.limits_not_http",
1526 "A `limits { }` policy appears on a service that is not `from http`.",
1527 ),
1528 d(
1529 "bynk.http.limits_unknown_field",
1530 "A `limits { }` policy declares a field outside the closed set.",
1531 ),
1532 dg(
1533 "bynk.http.path_param_not_stringy",
1534 "A path parameter's type is not constructible from a string.",
1535 &["http_handler"],
1536 ),
1537 dg(
1538 "bynk.http.query_field_not_stringy",
1539 "A field of an HTTP handler's `query` record has a type a query string cannot carry.",
1540 &["http_handler"],
1541 ),
1542 dg(
1543 "bynk.http.query_not_http",
1544 "A `RequestQuery` appears on a handler that is not an HTTP route.",
1545 &["http_handler"],
1546 ),
1547 dg(
1548 "bynk.http.query_wrong_type",
1549 "An HTTP handler's `query` parameter is neither a record type nor `RequestQuery`.",
1550 &["http_handler"],
1551 ),
1552 d(
1553 "bynk.http.raw_bad_content_type",
1554 "A `@raw` annotation's `contentType` is missing or not a `type/subtype` (or `\"*/*\"`) string literal.",
1555 ),
1556 d(
1557 "bynk.http.raw_body_not_bytes",
1558 "The `body` of a `@raw` handler is not typed `Bytes`.",
1559 ),
1560 d(
1561 "bynk.http.raw_body_unbounded",
1562 "A `@raw` route has no request-body cap (no `@limit` and no service `limits`).",
1563 ),
1564 d(
1565 "bynk.http.raw_duplicate",
1566 "A handler carries more than one `@raw` annotation.",
1567 ),
1568 d(
1569 "bynk.http.raw_error_status",
1570 "`RawError`'s first argument is not an `ErrorStatus` name (a 4xx or 5xx `HttpResult` variant name).",
1571 ),
1572 d(
1573 "bynk.http.raw_on_bodyless",
1574 "A `@raw` annotation is placed on a handler that takes no body.",
1575 ),
1576 d(
1577 "bynk.http.raw_unknown_arg",
1578 "A `@raw` annotation has an argument outside the closed set (`contentType`).",
1579 ),
1580 dg(
1581 "bynk.http.rejected_signature",
1582 "An `on rejected` handler is not `on rejected(why: BoundaryRejection) -> HttpResult[()]` with no `by` and no `given`.",
1583 &["rejected_handler"],
1584 ),
1585 dg(
1586 "bynk.http.reserved_prefix",
1587 "A route uses the reserved `/_bynk/` prefix.",
1588 &["http_handler"],
1589 ),
1590 dg(
1591 "bynk.http.return_not_effect_http_result",
1592 "An HTTP handler does not return `Effect[HttpResult[T]]`.",
1593 &["http_handler"],
1594 ),
1595 d(
1596 "bynk.http.security_invalid_field",
1597 "A `security` policy field (`hsts`/`nosniff`) has the wrong value shape.",
1598 ),
1599 d(
1600 "bynk.http.security_not_http",
1601 "A `security { }` policy appears on a service that is not `from http`.",
1602 ),
1603 d(
1604 "bynk.http.security_unknown_field",
1605 "A `security { }` policy declares a field outside the closed set.",
1606 ),
1607 dg(
1608 "bynk.http.unbound_path_param",
1609 "A `:name` route segment has no matching handler parameter.",
1610 &["http_handler"],
1611 ),
1612 d(
1613 "bynk.http.unknown_handler_annotation",
1614 "A handler carries an annotation outside the closed set (`@cache`/`@limit`).",
1615 ),
1616 d(
1617 "bynk.index.bad_argument",
1618 "An `@indexed` argument is not a `by: <field>` label.",
1619 ),
1620 warn(d(
1621 "bynk.index.missing",
1622 "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
1623 )),
1624 d(
1625 "bynk.index.unkeyable_key",
1626 "An `@indexed(by: k)` field is not value-keyable.",
1627 ),
1628 d(
1629 "bynk.index.unknown_key",
1630 "An `@indexed(by: k)` field is not a field of the map's value type.",
1631 ),
1632 warn(d(
1633 "bynk.index.unused",
1634 "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
1635 )),
1636 d(
1637 "bynk.invariant.cross_agent_reference",
1638 "An invariant predicate references another agent; invariants are per-agent.",
1639 ),
1640 d(
1641 "bynk.invariant.duplicate_name",
1642 "An agent declares two invariants with the same name.",
1643 ),
1644 d(
1645 "bynk.invariant.impure_predicate",
1646 "An invariant predicate uses an effectful or test-only construct.",
1647 ),
1648 d(
1649 "bynk.invariant.not_bool",
1650 "An invariant predicate does not have type `Bool`.",
1651 ),
1652 d(
1653 "bynk.json.nested_option_plain",
1654 "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`.",
1655 ),
1656 dg(
1657 "bynk.lambda.unannotated_param",
1658 "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
1659 &["lambda_expr"],
1660 ),
1661 dg(
1662 "bynk.lex.bad_escape",
1663 "An invalid escape sequence in a string literal.",
1664 &["string_literal"],
1665 ),
1666 dg(
1667 "bynk.lex.bad_unicode_escape",
1668 "A `\\u{…}` escape names a surrogate or a value above U+10FFFF.",
1669 &["string_literal"],
1670 ),
1671 dg(
1672 "bynk.lex.decimal_literal_too_large",
1673 "A decimal literal has more than 100 fraction digits or more than 1000 characters, the most any `Decimal` may have (#2622).",
1674 &["decimal_literal"],
1675 ),
1676 dg(
1677 "bynk.lex.float_literal_overflow",
1678 "A float literal does not fit a finite 64-bit float.",
1679 &["float_literal"],
1680 ),
1681 dg(
1682 "bynk.lex.integer_overflow",
1683 "An integer literal is outside the `Int` range, the JS safe integers ±(2^53 − 1).",
1684 &["number_literal"],
1685 ),
1686 dg(
1687 "bynk.lex.interpolation_too_deep",
1688 "A string interpolation `\\(…)` nests deeper than the lexer's fixed limit.",
1689 &["string_literal"],
1690 ),
1691 d(
1692 "bynk.lex.legacy_comment",
1693 "A `--` line comment, the spelling before #2203; a comment is `//` (auto-fixable; `bynk fmt` rewrites it).",
1694 ),
1695 d(
1696 "bynk.lex.legacy_doc_line",
1697 "A `--|` one-line doc, the spelling before #2203; a one-line doc is `--- text` (auto-fixable; `bynk fmt` rewrites it).",
1698 ),
1699 dg(
1700 "bynk.lex.multiline_close_not_own_line",
1701 "A `\"\"\"` inside a multi-line string literal is not on a line of its own.",
1702 &["string_literal"],
1703 ),
1704 dg(
1705 "bynk.lex.multiline_in_hole",
1706 "A multi-line string literal appears inside an interpolation hole, which must close on its own line.",
1707 &["string_literal"],
1708 ),
1709 dg(
1710 "bynk.lex.multiline_indent",
1711 "A line of a multi-line string literal is indented less than its closing `\"\"\"`.",
1712 &["string_literal"],
1713 ),
1714 dg(
1715 "bynk.lex.multiline_open",
1716 "The opening `\"\"\"` of a multi-line string literal is not followed by a newline, or by a language tag (`\"\"\"sql`) and a newline.",
1717 &["string_literal"],
1718 ),
1719 d(
1720 "bynk.lex.slash_doc",
1721 "A `///` doc comment first on its line; a Bynk doc is `--- text` or a `---` block (auto-fixable).",
1722 ),
1723 d(
1724 "bynk.lex.unclosed_doc_block",
1725 "A documentation block is not closed.",
1726 ),
1727 d(
1728 "bynk.lex.unexpected_character",
1729 "An unexpected character in the source.",
1730 ),
1731 dg(
1732 "bynk.lex.unterminated_interpolation",
1733 "An interpolation hole `\\(…)` is not closed on its line.",
1734 &["string_literal"],
1735 ),
1736 dg(
1737 "bynk.lex.unterminated_string",
1738 "A string literal is not terminated.",
1739 &["string_literal"],
1740 ),
1741 warn(d(
1742 "bynk.list.deprecated_function",
1743 "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
1744 )),
1745 d(
1746 "bynk.locale.multiple_message_bundles",
1747 "A context consumes `Locale` but its direct `uses` reaches two or more message-bundle commons — there is no single bundle to negotiate against.",
1748 ),
1749 d(
1750 "bynk.messages.format_mismatch",
1751 "A code's placeholder is formatted as a different ICU kind (plain/plural/select/number/date) across declared locales.",
1752 ),
1753 d(
1754 "bynk.messages.incomplete",
1755 "A locale is missing a code the reference locale declares.",
1756 ),
1757 d(
1758 "bynk.messages.invalid_locale_tag",
1759 "A `messages` block's locale tag is not a valid `LocaleTag` (e.g. `messages \"xx\"` where `xx` doesn't match the tag pattern).",
1760 ),
1761 d(
1762 "bynk.messages.malformed_icu_syntax",
1763 "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).",
1764 ),
1765 d(
1766 "bynk.messages.missing_locale_dependency",
1767 "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.",
1768 ),
1769 d(
1770 "bynk.messages.missing_reference",
1771 "A message bundle has no `@reference` block.",
1772 ),
1773 d(
1774 "bynk.messages.multiple_reference",
1775 "A message bundle has more than one `@reference` block.",
1776 ),
1777 d(
1778 "bynk.messages.outside_commons",
1779 "A `messages` declaration appears outside a commons.",
1780 ),
1781 d(
1782 "bynk.messages.placeholder_mismatch",
1783 "A locale's template for a code uses a different set of `{name}` placeholders than the reference locale's.",
1784 ),
1785 d(
1786 "bynk.namespace.reserved",
1787 "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
1788 ),
1789 d(
1790 "bynk.observe.impure_with",
1791 "A `with` predicate uses an effectful or test-only construct; it must be pure.",
1792 ),
1793 d(
1794 "bynk.observe.not_a_seam",
1795 "An observation targets a capability the unit under test does not consume.",
1796 ),
1797 d(
1798 "bynk.observe.trace_outside_test",
1799 "`trace(Cap.op)` appears outside a `case` body.",
1800 ),
1801 d(
1802 "bynk.observe.unknown_op",
1803 "An observation names an operation the capability does not declare.",
1804 ),
1805 d(
1806 "bynk.observe.with_not_bool",
1807 "A `with` predicate does not have type `Bool`.",
1808 ),
1809 d(
1810 "bynk.package.alias_shadows_unit",
1811 "A dependency alias in `[dependencies]` is also the first segment of one of the project's own units, so `<alias>.…` would be ambiguous.",
1812 ),
1813 d(
1814 "bynk.package.checksum_mismatch",
1815 "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.",
1816 ),
1817 d(
1818 "bynk.package.dependency_cycle",
1819 "The package graph has a cycle: a dependency depends, directly or not, on itself or on the project.",
1820 ),
1821 d(
1822 "bynk.package.dependency_not_found",
1823 "A path dependency's directory has no readable `bynk.toml`, its `bynk.toml` is invalid, or it has no `[package]`.",
1824 ),
1825 d(
1826 "bynk.package.dev_dependency_in_source",
1827 "A commons, context or adapter reaches a `[dev-dependencies]` alias, which only a suite may use.",
1828 ),
1829 d(
1830 "bynk.package.duplicate_source",
1831 "One package is reached from two different directories; a build holds one copy of each package.",
1832 ),
1833 d(
1834 "bynk.package.git_failed",
1835 "`git` couldn't clone, fetch or check out a git dependency, or the revision it names doesn't exist.",
1836 ),
1837 d(
1838 "bynk.package.lock_invalid",
1839 "`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.",
1840 ),
1841 d(
1842 "bynk.package.lock_out_of_date",
1843 "`--locked` was given, and resolving the manifests would change `bynk.lock`.",
1844 ),
1845 d(
1846 "bynk.package.name_mismatch",
1847 "A path dependency's `package` names a different package than the directory's `[package] name`.",
1848 ),
1849 d(
1850 "bynk.package.not_fetched",
1851 "A git dependency has no `bynk.lock` entry, or its store entry is missing; `bynk fetch` fetches it (refused under `--offline`).",
1852 ),
1853 d(
1854 "bynk.package.unit_not_exported",
1855 "A `uses` or `consumes` reaches a unit its dependency declares but doesn't list in `[package] exports`.",
1856 ),
1857 d(
1858 "bynk.package.unknown_unit",
1859 "A `uses` or `consumes` names, through a dependency alias, a unit the dependency doesn't declare.",
1860 ),
1861 d(
1862 "bynk.package.unsafe_source",
1863 "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).",
1864 ),
1865 d(
1866 "bynk.package.unsupported_in_dependency",
1867 "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.",
1868 ),
1869 d(
1870 "bynk.package.version_conflict",
1871 "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.",
1872 ),
1873 dg(
1874 "bynk.par.invalid_statement",
1875 "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.",
1876 &["par_stmt"],
1877 ),
1878 dg(
1879 "bynk.par.question_in_join",
1880 "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.",
1881 &["par_stmt"],
1882 ),
1883 dg(
1884 "bynk.par.sibling_name",
1885 "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.",
1886 &["par_stmt"],
1887 ),
1888 warn(dg(
1889 "bynk.par.single_binding",
1890 "A `par { … }` block has a single binding, which is a plain `let x <- e` with extra syntax (warning).",
1891 &["par_stmt"],
1892 )),
1893 d(
1894 "bynk.parse.clause_after_statement",
1895 "A `stub` or `env` clause came after a statement in a test case; they lead the case body.",
1896 ),
1897 dg(
1898 "bynk.parse.const_missing_type",
1899 "A `const` declaration has no type annotation; a constant's type is always written (`const Name: Type = …`).",
1900 &["const_decl"],
1901 ),
1902 dg(
1903 "bynk.parse.consumes_after_decls",
1904 "`consumes` appears after other declarations.",
1905 &["consumes_decl"],
1906 ),
1907 d(
1908 "bynk.parse.dangling_handler_annotation",
1909 "A handler-position annotation (e.g. `@cache`) is not followed by an `on` handler.",
1910 ),
1911 d(
1912 "bynk.parse.doc_block_contains_code",
1913 "A documentation block's content (outside Markdown code fences) parses as declarations, so a pair of dash dividers has turned code into documentation.",
1914 ),
1915 dg(
1916 "bynk.parse.duplicate_cors",
1917 "A service declares more than one `cors { }` policy.",
1918 &["service_decl"],
1919 ),
1920 dg(
1921 "bynk.parse.duplicate_json",
1922 "A service declares more than one `json { }` policy.",
1923 &["service_decl"],
1924 ),
1925 dg(
1926 "bynk.parse.duplicate_limits",
1927 "A service declares more than one `limits { }` policy.",
1928 &["service_decl"],
1929 ),
1930 dg(
1931 "bynk.parse.duplicate_security",
1932 "A service declares more than one `security { }` policy.",
1933 &["service_decl"],
1934 ),
1935 dg(
1936 "bynk.parse.empty_agent",
1937 "An `agent` body is empty.",
1938 &["agent_decl"],
1939 ),
1940 dg(
1941 "bynk.parse.empty_capability",
1942 "A `capability` body is empty.",
1943 &["capability_decl"],
1944 ),
1945 d(
1946 "bynk.parse.empty_interpolation",
1947 "An interpolation hole `\\(…)` contains no expression.",
1948 ),
1949 dg(
1950 "bynk.parse.empty_match",
1951 "A `match` has no arms.",
1952 &["match_expr"],
1953 ),
1954 dg(
1955 "bynk.parse.empty_service",
1956 "A `service` body is empty.",
1957 &["service_decl"],
1958 ),
1959 d(
1960 "bynk.parse.event_pattern_empty",
1961 "A `from Events(E { ... })` subscription pattern listed no fields — use `from Events(E)` (no braces) for an unfiltered subscription.",
1962 ),
1963 dg(
1964 "bynk.parse.expected_agent_key",
1965 "Expected a `key` declaration in an agent.",
1966 &["agent_decl"],
1967 ),
1968 d(
1969 "bynk.parse.expected_agent_storage",
1970 "An agent declares no storage — it has no `store` fields.",
1971 ),
1972 dg(
1973 "bynk.parse.expected_base_type",
1974 "Expected a base type.",
1975 &["base_type"],
1976 ),
1977 dg(
1978 "bynk.parse.expected_capability_op",
1979 "Expected a capability operation.",
1980 &["capability_op"],
1981 ),
1982 d("bynk.parse.expected_expression", "Expected an expression."),
1983 dg(
1984 "bynk.parse.expected_handler",
1985 "Expected a handler.",
1986 &["handler"],
1987 ),
1988 d("bynk.parse.expected_item", "Expected a declaration."),
1989 dg(
1990 "bynk.parse.expected_predicate",
1991 "Expected a refinement predicate.",
1992 &["refinement"],
1993 ),
1994 dg(
1995 "bynk.parse.expected_provider_op",
1996 "Expected a provider operation.",
1997 &["provider_op"],
1998 ),
1999 d("bynk.parse.expected_token", "Expected a specific token."),
2000 d("bynk.parse.expected_type", "Expected a type."),
2001 d(
2002 "bynk.parse.expected_unit_header",
2003 "Expected a `commons` or `context` header.",
2004 ),
2005 dg(
2006 "bynk.parse.expected_visibility",
2007 "Expected a visibility keyword.",
2008 &["exports_decl"],
2009 ),
2010 dg(
2011 "bynk.parse.exports_after_decls",
2012 "`exports` appears after other declarations.",
2013 &["exports_decl"],
2014 ),
2015 d(
2016 "bynk.parse.extra_tokens",
2017 "Unexpected tokens after an otherwise complete construct.",
2018 ),
2019 dg(
2020 "bynk.parse.generic_arg_count",
2021 "Wrong number of generic type arguments.",
2022 &["generic_type_ref"],
2023 ),
2024 dg(
2025 "bynk.parse.handler_in_agent",
2026 "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
2027 &["handler"],
2028 ),
2029 d(
2030 "bynk.parse.invariant_after_handler",
2031 "An `invariant` was declared after a handler; invariants precede handlers.",
2032 ),
2033 dg(
2034 "bynk.parse.keyword_field_shorthand",
2035 "A reserved keyword was used as a field shorthand, which would bind a variable of that name.",
2036 &["identifier"],
2037 ),
2038 dg(
2039 "bynk.parse.lambda_pattern_annotation",
2040 "A lambda parameter with a record pattern carries a type annotation; the pattern's type name already gives the parameter's type.",
2041 &["lambda_param"],
2042 ),
2043 dg(
2044 "bynk.parse.lambda_pattern_not_record",
2045 "A lambda parameter is a pattern other than a record pattern; only an irrefutable record pattern may stand in for a name.",
2046 &["lambda_param"],
2047 ),
2048 dg(
2049 "bynk.parse.lambda_pattern_refutable",
2050 "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.",
2051 &["lambda_param"],
2052 ),
2053 dg(
2054 "bynk.parse.let_else_on_binding",
2055 "An `else` follows a plain `let name = …` binding, which matches every value, so the `else` could never run.",
2056 &["let_stmt", "effect_let_stmt"],
2057 ),
2058 hint(d(
2059 "bynk.parse.let_else_staircase",
2060 "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).",
2061 )),
2062 dg(
2063 "bynk.parse.let_pattern_annotation",
2064 "A `let` with a pattern carries a type annotation; the pattern's names take their types from the value.",
2065 &["let_else_stmt"],
2066 ),
2067 dg(
2068 "bynk.parse.let_pattern_without_else",
2069 "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.",
2070 &["let_else_stmt"],
2071 ),
2072 dg(
2073 "bynk.parse.list_rest_not_last",
2074 "A `..` in a list pattern is not the final element; suffix forms such as `[.., last]` are not available.",
2075 &["list_pattern"],
2076 ),
2077 dg(
2078 "bynk.parse.malformed_float_literal",
2079 "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
2080 &["float_literal"],
2081 ),
2082 dg(
2083 "bynk.parse.match_ends_block",
2084 "A `match` ends the block it is in, because a block has no expression statements; a second `match` straight after it cannot follow.",
2085 &["block"],
2086 ),
2087 d(
2088 "bynk.parse.migrate_after_handler",
2089 "A `migrate` step is declared after an agent handler; migration steps precede the handlers.",
2090 ),
2091 d(
2092 "bynk.parse.migrate_item",
2093 "A `migrate` step's body holds something other than `field := value`, `let` or `drop field`.",
2094 ),
2095 d(
2096 "bynk.parse.multiple_docs",
2097 "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.",
2098 ),
2099 d(
2100 "bynk.parse.nesting_too_deep",
2101 "An expression or type nests deeper than the parser's fixed limit.",
2102 ),
2103 d(
2104 "bynk.parse.no_remainder_operator",
2105 "`%` is not an operator; use `Int.rem` (the dividend's sign) or `Int.mod` (the divisor's).",
2106 ),
2107 dg(
2108 "bynk.parse.non_associative",
2109 "A non-associative operator was chained (e.g. `a == b == c`).",
2110 &["binary_expr"],
2111 ),
2112 warn(d(
2113 "bynk.parse.orphan_doc_block",
2114 "A documentation block is not attached to a declaration (warning).",
2115 )),
2116 dg(
2117 "bynk.parse.policy_order",
2118 "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`.",
2119 &["service_decl"],
2120 ),
2121 dg(
2122 "bynk.parse.record_pattern_in_is_unparenthesised",
2123 "A record pattern after `is` is not parenthesised — write `x is (T { f, .. })`.",
2124 &["record_pattern"],
2125 ),
2126 dg(
2127 "bynk.parse.record_pattern_without_rest",
2128 "A record pattern does not end with `..`; every record pattern is open.",
2129 &["record_pattern"],
2130 ),
2131 dg(
2132 "bynk.parse.refined_pattern_inner",
2133 "A refined pattern's inner form is something other than `_`.",
2134 &["refined_pattern"],
2135 ),
2136 dg(
2137 "bynk.parse.reserved_keyword",
2138 "A reserved keyword was used as an identifier.",
2139 &["identifier"],
2140 ),
2141 dg(
2142 "bynk.parse.self_outside_method",
2143 "`self` used outside a method or handler.",
2144 &["self_expr"],
2145 ),
2146 d(
2147 "bynk.parse.storage_after_phase",
2148 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
2149 ),
2150 d(
2151 "bynk.parse.transition_after_handler",
2152 "A `transition` is declared after an agent handler; step invariants precede the handlers.",
2153 ),
2154 d(
2155 "bynk.parse.unexpected_adapter",
2156 "An `adapter` appeared where it is not allowed.",
2157 ),
2158 dg(
2159 "bynk.parse.unexpected_context",
2160 "A `context` appeared where it is not allowed.",
2161 &["context_decl"],
2162 ),
2163 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
2164 dg(
2165 "bynk.parse.unexpected_suite",
2166 "A `suite` appeared where it is not allowed.",
2167 &["suite_decl"],
2168 ),
2169 d(
2170 "bynk.parse.unknown_effect_method",
2171 "An unknown method on `Effect`.",
2172 ),
2173 dg(
2174 "bynk.parse.unknown_handler_kind",
2175 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
2176 &["handler"],
2177 ),
2178 dg(
2179 "bynk.parse.unknown_predicate",
2180 "An unknown refinement predicate.",
2181 &["predicate_name"],
2182 ),
2183 d(
2184 "bynk.parse.unknown_tier",
2185 "A `case`/`suite` `as <tier>` clause names something other than `unit`, `integration`, or `system`.",
2186 ),
2187 dg(
2188 "bynk.parse.uses_after_decls",
2189 "`uses` appears after other declarations.",
2190 &["uses_decl"],
2191 ),
2192 dg(
2193 "bynk.parse.variant_name_case",
2194 "A sum-type or enum variant name is not capitalised.",
2195 &["sum_variant", "enum_type"],
2196 ),
2197 d(
2198 "bynk.project.contracts_lock_corrupt",
2199 "`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.",
2200 ),
2201 warn(d(
2202 "bynk.project.contracts_lock_oversized",
2203 "`bynk.contracts.lock` has one service accepting more older contracts than the build keeps comfortably (warning).",
2204 )),
2205 warn(d(
2206 "bynk.project.contracts_lock_stale",
2207 "`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).",
2208 )),
2209 warn(d(
2210 "bynk.project.duplicate_compatibility_flag",
2211 "`bynk.toml`'s `[workers] compatibility_flags` lists a flag twice, or one every Bynk Worker already has; the duplicate is dropped (warning).",
2212 )),
2213 d(
2214 "bynk.project.duplicate_module_doc",
2215 "More than one file of a multi-file unit carries a module doc.",
2216 ),
2217 d(
2218 "bynk.project.export_context",
2219 "`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.",
2220 ),
2221 d(
2222 "bynk.project.export_unknown",
2223 "`bynk.toml`'s `[package] exports` lists a name that isn't a commons or adapter the project declares.",
2224 ),
2225 d(
2226 "bynk.project.file_and_directory",
2227 "A unit exists as both a file and a directory.",
2228 ),
2229 d(
2230 "bynk.project.inconsistent_commons_name",
2231 "A source file's path does not match its declared name.",
2232 ),
2233 d(
2234 "bynk.project.kind_conflict",
2235 "A name is declared as both a commons and a context.",
2236 ),
2237 d(
2238 "bynk.project.no_root",
2239 "No project root could be determined.",
2240 ),
2241 d(
2242 "bynk.project.no_sources",
2243 "The project contains no source files.",
2244 ),
2245 d(
2246 "bynk.project.read_failed",
2247 "A source file could not be read.",
2248 ),
2249 d(
2250 "bynk.project.schema_registry_corrupt",
2251 "`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.",
2252 ),
2253 warn(d(
2254 "bynk.project.unstable_not_experimental",
2255 "`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).",
2256 )),
2257 d(
2258 "bynk.project.unstable_unknown_item",
2259 "`bynk.toml`'s `[unstable] allow` lists a path that names no standard-library unit, exported item or operation.",
2260 ),
2261 dg(
2262 "bynk.property.restates_refinement",
2263 "A `property` merely re-checks a refinement its type already guarantees.",
2264 &["for_all"],
2265 ),
2266 dg(
2267 "bynk.property.where_not_bool",
2268 "A `for all ... where` filter does not type to `Bool`.",
2269 &["for_all"],
2270 ),
2271 dg(
2272 "bynk.provider.agent_call_undeclared_capability",
2273 "A provider calls an agent handler that needs a capability the provider's `given` does not list.",
2274 &["provider_decl"],
2275 ),
2276 dg(
2277 "bynk.provider.dependency_cycle",
2278 "Providers form a capability dependency cycle through `given`.",
2279 &["provider_decl"],
2280 ),
2281 dg(
2282 "bynk.provider.extra_operation",
2283 "A `provides` block implements an operation not in the capability.",
2284 &["provider_decl"],
2285 ),
2286 dg(
2287 "bynk.provider.generic_op_requires_external",
2288 "A Bynk-bodied `provides` implements a capability operation that declares its own type parameter — only an external (bodiless) provider can.",
2289 &["provider_decl"],
2290 ),
2291 dg(
2292 "bynk.provider.missing_operation",
2293 "A `provides` block is missing a capability operation.",
2294 &["provider_decl"],
2295 ),
2296 dg(
2297 "bynk.provider.outside_context",
2298 "`provides` was declared outside a context.",
2299 &["provider_decl"],
2300 ),
2301 dg(
2302 "bynk.provider.signature_mismatch",
2303 "A `provides` operation's signature does not match the capability.",
2304 &["provider_decl"],
2305 ),
2306 dg(
2307 "bynk.provider.unknown_capability",
2308 "`provides` names a capability that does not exist.",
2309 &["provider_decl"],
2310 ),
2311 d(
2312 "bynk.query.join_key_mismatch",
2313 "A `joinOn`/`leftJoin` left and right key function return different types.",
2314 ),
2315 dg(
2316 "bynk.query.sum_needs_numeric",
2317 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
2318 &[],
2319 ),
2320 dg(
2321 "bynk.queue.bad_params",
2322 "An `on message` handler does not take exactly one `message` parameter.",
2323 &["queue_handler"],
2324 ),
2325 dg(
2326 "bynk.queue.duplicate_consumer",
2327 "Two `on message` handlers consume the same queue.",
2328 &["queue_handler"],
2329 ),
2330 dg(
2331 "bynk.queue.invalid_name",
2332 "A `from queue(\"…\")` binding has an empty queue name, or one Cloudflare refuses.",
2333 &["queue_handler"],
2334 ),
2335 dg(
2336 "bynk.queue.return_not_queue_result",
2337 "An `on message` handler does not return `Effect[QueueResult]`.",
2338 &["handler"],
2339 ),
2340 dg(
2341 "bynk.race.in_agent_handler",
2342 "`a.race(b)` was used in an agent handler, which has no execution context to hand the losing effect to.",
2343 &["method_call"],
2344 ),
2345 dg(
2346 "bynk.race.in_pure_context",
2347 "`a.race(b)` was used in a pure (non-effectful) context.",
2348 &["method_call"],
2349 ),
2350 dg(
2351 "bynk.race.outside_handler",
2352 "`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.",
2353 &["method_call"],
2354 ),
2355 dg(
2356 "bynk.record_spread.field_type_mismatch",
2357 "A record-spread override has the wrong type for the field.",
2358 &["record_spread"],
2359 ),
2360 dg(
2361 "bynk.record_spread.non_record_base",
2362 "The base of a record spread is not a record.",
2363 &["record_spread"],
2364 ),
2365 dg(
2366 "bynk.record_spread.type_mismatch",
2367 "A record spread's base is a different record type.",
2368 &["record_spread"],
2369 ),
2370 dg(
2371 "bynk.record_spread.unknown_field",
2372 "A record spread overrides a field the record does not have.",
2373 &["record_spread"],
2374 ),
2375 dg(
2376 "bynk.refine.literal_violates",
2377 "A literal does not satisfy the refined type's predicate.",
2378 &["refined_type"],
2379 ),
2380 d(
2381 "bynk.registry.account_refused",
2382 "`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).",
2383 ),
2384 d(
2385 "bynk.registry.bad_archive",
2386 "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.",
2387 ),
2388 d(
2389 "bynk.registry.bad_signature",
2390 "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).",
2391 ),
2392 d(
2393 "bynk.registry.http_failed",
2394 "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.",
2395 ),
2396 d(
2397 "bynk.registry.key_mismatch",
2398 "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`.",
2399 ),
2400 d(
2401 "bynk.registry.nonconformant",
2402 "`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.",
2403 ),
2404 d(
2405 "bynk.registry.publish_refused",
2406 "`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).",
2407 ),
2408 d(
2409 "bynk.registry.source_mismatch",
2410 "`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.",
2411 ),
2412 d(
2413 "bynk.registry.unavailable",
2414 "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.",
2415 ),
2416 d(
2417 "bynk.registry.withdrawn",
2418 "`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.",
2419 ),
2420 dg(
2421 "bynk.requires.conflicting_range",
2422 "Two adapter `binding … requires { … }` entries give different version ranges for one npm package.",
2423 &["binding_decl"],
2424 ),
2425 dg(
2426 "bynk.requires.unapproved",
2427 "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>`.",
2428 &["binding_decl"],
2429 ),
2430 dg(
2431 "bynk.requires.unpinned_dependency",
2432 "An adapter `binding … requires { … }` entry has an unpinned version range.",
2433 &["binding_decl"],
2434 ),
2435 d(
2436 "bynk.resolve.ambiguous_variant",
2437 "A variant name is ambiguous across several sum types.",
2438 ),
2439 dg(
2440 "bynk.resolve.arity_mismatch",
2441 "A function was called with the wrong number of arguments.",
2442 &["call"],
2443 ),
2444 dg(
2445 "bynk.resolve.bad_const_initialiser",
2446 "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.",
2447 &["const_decl"],
2448 ),
2449 dg(
2450 "bynk.resolve.const_cycle",
2451 "Constants refer to each other in a cycle, so none of them has a value.",
2452 &["const_decl"],
2453 ),
2454 dg(
2455 "bynk.resolve.const_name_case",
2456 "A constant's name is not upper-camel case (`MaxRetries`, not `maxRetries`).",
2457 &["const_decl"],
2458 ),
2459 dg(
2460 "bynk.resolve.const_outside_context_or_commons",
2461 "A `const` declaration appears outside a context or commons.",
2462 &["const_decl"],
2463 ),
2464 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
2465 dg(
2466 "bynk.resolve.duplicate_agent",
2467 "Two agents share a name.",
2468 &["agent_decl"],
2469 ),
2470 dg(
2471 "bynk.resolve.duplicate_capability",
2472 "Two capabilities share a name.",
2473 &["capability_decl"],
2474 ),
2475 dg(
2476 "bynk.resolve.duplicate_const",
2477 "Two constants share a name.",
2478 &["const_decl"],
2479 ),
2480 dg(
2481 "bynk.resolve.duplicate_field",
2482 "A record declares a field twice.",
2483 &["record_type"],
2484 ),
2485 dg(
2486 "bynk.resolve.duplicate_field_init",
2487 "A record construction initialises a field twice.",
2488 &["record_construction"],
2489 ),
2490 dg(
2491 "bynk.resolve.duplicate_fn",
2492 "Two functions share a name.",
2493 &["fn_decl"],
2494 ),
2495 d(
2496 "bynk.resolve.duplicate_message_code",
2497 "A message bundle declares the same code twice in one block.",
2498 ),
2499 d(
2500 "bynk.resolve.duplicate_message_locale",
2501 "Two `messages` blocks in one bundle declare the same locale tag.",
2502 ),
2503 dg(
2504 "bynk.resolve.duplicate_method",
2505 "Two methods share a name.",
2506 &["fn_decl"],
2507 ),
2508 dg(
2509 "bynk.resolve.duplicate_param",
2510 "A parameter name is repeated.",
2511 &["param"],
2512 ),
2513 dg(
2514 "bynk.resolve.duplicate_provider",
2515 "A capability is provided more than once.",
2516 &["provider_decl"],
2517 ),
2518 dg(
2519 "bynk.resolve.duplicate_service",
2520 "Two services share a name.",
2521 &["service_decl"],
2522 ),
2523 dg(
2524 "bynk.resolve.duplicate_type",
2525 "Two types share a name.",
2526 &["type_decl"],
2527 ),
2528 dg(
2529 "bynk.resolve.duplicate_variant",
2530 "A sum type declares a variant twice.",
2531 &["sum_type"],
2532 ),
2533 d(
2534 "bynk.resolve.fn_without_call",
2535 "A function was referenced without being called.",
2536 ),
2537 dg(
2538 "bynk.resolve.let_shadows_fn",
2539 "A `let` binding shadows a function.",
2540 &["let_stmt"],
2541 ),
2542 dg(
2543 "bynk.resolve.let_shadows_type",
2544 "A `let` binding shadows a type.",
2545 &["let_stmt"],
2546 ),
2547 d(
2548 "bynk.resolve.method_unknown_type",
2549 "A method is defined on an unknown type.",
2550 ),
2551 dg(
2552 "bynk.resolve.missing_field",
2553 "A record construction omits a required field.",
2554 &["record_construction"],
2555 ),
2556 d(
2557 "bynk.resolve.name_conflict",
2558 "Two declarations share a name.",
2559 ),
2560 dg(
2561 "bynk.resolve.not_a_record_type",
2562 "Record syntax was used on a non-record type.",
2563 &["record_construction"],
2564 ),
2565 dg(
2566 "bynk.resolve.opaque_record_construction",
2567 "An opaque type was constructed with record syntax.",
2568 &["record_construction"],
2569 ),
2570 dg(
2571 "bynk.resolve.param_as_function",
2572 "A value (such as a parameter) was called as a function.",
2573 &["call"],
2574 ),
2575 dg(
2576 "bynk.resolve.recursive_record_field",
2577 "A record directly contains a field of its own type.",
2578 &["record_type"],
2579 ),
2580 dg(
2581 "bynk.resolve.reserved_builtin_type",
2582 "A type declaration reuses a compiler-known built-in type name.",
2583 &["type_decl"],
2584 ),
2585 dg(
2586 "bynk.resolve.reserved_host_name",
2587 "A declaration is named `globalThis`, which the generated TypeScript uses to reach host globals.",
2588 &["type_decl", "fn_decl", "agent_decl", "provider_decl"],
2589 ),
2590 dg(
2591 "bynk.resolve.reserved_payload_field",
2592 "A sum variant declares a payload field named `kind`, the variant's wire discriminant.",
2593 &["sum_type"],
2594 ),
2595 dg(
2596 "bynk.resolve.self_outside_method",
2597 "`self` referenced outside a method or handler.",
2598 &["self_expr"],
2599 ),
2600 dg(
2601 "bynk.resolve.type_as_function",
2602 "A type name was called as if it were a function.",
2603 &["call"],
2604 ),
2605 d(
2606 "bynk.resolve.type_in_expr",
2607 "A type name was used where a value is expected.",
2608 ),
2609 dg(
2610 "bynk.resolve.unconsumed_context",
2611 "A context's service was called without a `consumes` declaration.",
2612 &["consumes_decl"],
2613 ),
2614 dg(
2615 "bynk.resolve.unknown_field",
2616 "Accessed a field the record does not have.",
2617 &["field_access"],
2618 ),
2619 dg(
2620 "bynk.resolve.unknown_function",
2621 "Called a function that does not exist.",
2622 &["call"],
2623 ),
2624 d(
2625 "bynk.resolve.unknown_name",
2626 "Referenced a name that is not in scope.",
2627 ),
2628 dg(
2629 "bynk.resolve.unknown_static_member",
2630 "Referenced an unknown static member (e.g. `T.x`).",
2631 &["field_access"],
2632 ),
2633 d(
2634 "bynk.resolve.unknown_type",
2635 "Referenced a type that does not exist.",
2636 ),
2637 warn(d(
2638 "bynk.secrets.computed_name",
2639 "A `bynk.Secrets` read names its secret with a computed expression rather than a literal, so `bynk deploy` cannot plan it (warning).",
2640 )),
2641 dg(
2642 "bynk.send.in_agent_handler",
2643 "A `~>` send was used in an agent handler, which has no execution context to keep a fire-and-forget send alive.",
2644 &["effect_send_stmt"],
2645 ),
2646 dg(
2647 "bynk.send.in_pure_context",
2648 "A `~>` send was used in a pure (non-effectful) context.",
2649 &["effect_send_stmt"],
2650 ),
2651 dg(
2652 "bynk.send.non_effect",
2653 "A `~>` send was applied to a non-`Effect` value.",
2654 &["effect_send_stmt"],
2655 ),
2656 dg(
2657 "bynk.send.requires_unit",
2658 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
2659 &["effect_send_stmt"],
2660 ),
2661 dg(
2662 "bynk.send.store_op",
2663 "A `~>` send targets an agent store operation, which is part of the handler's atomic commit and cannot be sent without waiting.",
2664 &["effect_send_stmt"],
2665 ),
2666 dg(
2667 "bynk.service.missing_from",
2668 "A `from`-less service has a handler other than `on call`.",
2669 &["service_decl"],
2670 ),
2671 dg(
2672 "bynk.service.mixed_protocols",
2673 "A service mixes handler forms that do not match its `from <protocol>`.",
2674 &["service_decl"],
2675 ),
2676 dg(
2677 "bynk.service.outside_context",
2678 "A `service` was declared outside a context.",
2679 &["service_decl"],
2680 ),
2681 dg(
2682 "bynk.service.return_not_effect",
2683 "A service handler's return type is not an `Effect`.",
2684 &["service_decl"],
2685 ),
2686 dg(
2687 "bynk.service.unknown_protocol",
2688 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
2689 &["service_decl"],
2690 ),
2691 d(
2692 "bynk.service.unknown_via_clause",
2693 "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.",
2694 ),
2695 d(
2696 "bynk.service.websocket_header",
2697 "The `from websocket` header is malformed — it binds frame types as `websocket(in: <type>, out: <type>)` (real-time track slice 3).",
2698 ),
2699 d(
2700 "bynk.service.websocket_multiple",
2701 "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).",
2702 ),
2703 d(
2704 "bynk.service.websocket_open_arity",
2705 "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).",
2706 ),
2707 d(
2708 "bynk.service.websocket_param_not_stringy",
2709 "A `from websocket` service's `on open` parameter has a type not constructible from `String`; it arrives as a query-string value (#1657).",
2710 ),
2711 d(
2712 "bynk.stability.experimental",
2713 "An experimental standard-library item is used without an `[unstable] allow` entry in `bynk.toml` covering it.",
2714 ),
2715 d(
2716 "bynk.store.annotation_kind_mismatch",
2717 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
2718 ),
2719 d(
2720 "bynk.store.annotation_unsupported",
2721 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
2722 ),
2723 d(
2724 "bynk.store.cache_needs_clock",
2725 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
2726 ),
2727 d(
2728 "bynk.store.cache_ttl_required",
2729 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
2730 ),
2731 d(
2732 "bynk.store.kind_arity",
2733 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
2734 ),
2735 d(
2736 "bynk.store.kind_unsupported",
2737 "A known storage kind (`Queue`) is used before the slice that supports it.",
2738 ),
2739 d(
2740 "bynk.store.log_needs_clock",
2741 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
2742 ),
2743 d(
2744 "bynk.store.unkeyable_key",
2745 "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).",
2746 ),
2747 d(
2748 "bynk.store.unknown_annotation",
2749 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
2750 ),
2751 d(
2752 "bynk.store.unknown_kind",
2753 "A `store` field's type is not a known storage kind.",
2754 ),
2755 d(
2756 "bynk.store.unknown_map_accessor",
2757 "A `store Map` field access is not one of its query accessors (`entries`/`keys`/`values`).",
2758 ),
2759 d(
2760 "bynk.store.unknown_op",
2761 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
2762 ),
2763 d(
2764 "bynk.stub.after_type",
2765 "A test `stub … returns <value> after <d>` latency is not a `Duration`.",
2766 ),
2767 dg(
2768 "bynk.stub.at_system",
2769 "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.",
2770 &["stub_clause"],
2771 ),
2772 d(
2773 "bynk.stub.bad_sequence",
2774 "A `stub … returns each […]` sequence is malformed (e.g. empty).",
2775 ),
2776 d(
2777 "bynk.stub.generic_op",
2778 "A test `stub` targets a capability operation that declares its own type parameter — not supported at v1.",
2779 ),
2780 d(
2781 "bynk.stub.not_a_seam",
2782 "A test `stub` overrides a capability the unit under test does not consume.",
2783 ),
2784 d(
2785 "bynk.stub.rhs_type",
2786 "A test `stub … returns <value>` right-hand side does not match the operation's return type.",
2787 ),
2788 d(
2789 "bynk.stub.unknown_op",
2790 "A test `stub` names an operation the capability does not declare.",
2791 ),
2792 dg(
2793 "bynk.suite.duplicate_case_name",
2794 "Two `case`s share a description.",
2795 &["case"],
2796 ),
2797 dg(
2798 "bynk.suite.duplicate_env",
2799 "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.",
2800 &["env_clause"],
2801 ),
2802 dg(
2803 "bynk.suite.duplicate_fn",
2804 "A suite declares two helper `fn`s of the same name.",
2805 &["fn_decl"],
2806 ),
2807 dg(
2808 "bynk.suite.env_binding_clash",
2809 "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`.",
2810 &["env_clause"],
2811 ),
2812 dg(
2813 "bynk.suite.env_not_literal",
2814 "An `env { … }` entry's value is neither a `String` literal nor a `fixture` the same suite declares; a Worker's variables and secrets are strings, given verbatim.",
2815 &["env_clause"],
2816 ),
2817 dg(
2818 "bynk.suite.fn_effectful",
2819 "A suite helper `fn` returns an `Effect`; suite helpers are pure.",
2820 &["fn_decl"],
2821 ),
2822 dg(
2823 "bynk.suite.fn_method",
2824 "A suite helper `fn` is a method (`fn Type.name`); suite helpers are free functions.",
2825 &["fn_decl"],
2826 ),
2827 dg(
2828 "bynk.suite.fn_name_clash",
2829 "A suite helper `fn` has the name of a declaration already in scope in the suite's cases.",
2830 &["fn_decl"],
2831 ),
2832 dg(
2833 "bynk.suite.unknown_target",
2834 "A `suite` targets a unit that does not exist.",
2835 &["suite_decl"],
2836 ),
2837 d(
2838 "bynk.target.browser_bundle_only",
2839 "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
2840 ),
2841 dg(
2842 "bynk.target.vendor_conflict",
2843 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
2844 &["consumes_decl"],
2845 ),
2846 dg(
2847 "bynk.target.vendor_required",
2848 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
2849 &["consumes_decl"],
2850 ),
2851 dg(
2852 "bynk.test.actor_identity_required",
2853 "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`.",
2854 &["case"],
2855 ),
2856 dg(
2857 "bynk.test.actor_no_identity",
2858 "A call-site `by <Actor>(x)` supplies an identity to an actor that takes none — a unit-identity actor (e.g. `Visitor`) or `Nobody`.",
2859 &["case"],
2860 ),
2861 dg(
2862 "bynk.test.advance_not_clock",
2863 "An `advance` statement names a capability other than `Clock`; the test harness owns one time source, the first-party `Clock`.",
2864 &["advance_stmt"],
2865 ),
2866 dg(
2867 "bynk.test.advance_not_duration",
2868 "An `advance Clock by` statement's amount is not a `Duration`.",
2869 &["advance_stmt"],
2870 ),
2871 dg(
2872 "bynk.test.advance_outside_case",
2873 "An `advance Clock by` statement appears outside a test `case` body; only the test harness has a clock to move.",
2874 &["advance_stmt"],
2875 ),
2876 dg(
2877 "bynk.test.asset_address_method",
2878 "A suite fetches an asset with a method other than `GET`; the platform serves assets to `GET` and answers other methods with 405.",
2879 &["case"],
2880 ),
2881 dg(
2882 "bynk.test.call_needs_in_process",
2883 "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`.",
2884 &["case"],
2885 ),
2886 dg(
2887 "bynk.test.credential_needs_system",
2888 "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.",
2889 &["case"],
2890 ),
2891 dg(
2892 "bynk.test.event_needs_in_process",
2893 "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`.",
2894 &["case"],
2895 ),
2896 dg(
2897 "bynk.test.event_not_subscribed",
2898 "A test body's `svc.event(e)` delivers an event the `from Events(E)` service does not subscribe to.",
2899 &["case"],
2900 ),
2901 dg(
2902 "bynk.test.event_publisher_ambiguous",
2903 "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.",
2904 &["case"],
2905 ),
2906 dg(
2907 "bynk.test.expired_needs_bearer_route",
2908 "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.",
2909 &["case"],
2910 ),
2911 dg(
2912 "bynk.test.extra_headers_authorization",
2913 "A `system` case sends `Authorization` as an extra request header to a route that declares no `headers:` parameter; the case's `by <Actor>` owns the credential the driver sends.",
2914 &["case"],
2915 ),
2916 dg(
2917 "bynk.test.faults_needs_in_process",
2918 "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`.",
2919 &["case"],
2920 ),
2921 dg(
2922 "bynk.test.forged_needs_signature_route",
2923 "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.",
2924 &["case"],
2925 ),
2926 dg(
2927 "bynk.test.forged_needs_system",
2928 "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.",
2929 &["case"],
2930 ),
2931 dg(
2932 "bynk.test.nobody_needs_secured_route",
2933 "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.",
2934 &["case"],
2935 ),
2936 dg(
2937 "bynk.test.oidc_needs_in_process",
2938 "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`.",
2939 &["case"],
2940 ),
2941 d(
2942 "bynk.test.principal_claims_not_oidc",
2943 "A call-site principal passes token claims for an actor that isn't `Oidc`.",
2944 ),
2945 dg(
2946 "bynk.test.principal_identity_mismatch",
2947 "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.",
2948 &["case"],
2949 ),
2950 dg(
2951 "bynk.test.principal_on_asset",
2952 "A suite's asset fetch carries a `by` clause; an asset is public and served before the Worker runs.",
2953 &["case"],
2954 ),
2955 dg(
2956 "bynk.test.principal_on_wrong_method",
2957 "A wrong-method `405` test carries a `by <Actor>` clause; it reaches no handler, so a principal is meaningless.",
2958 &["case"],
2959 ),
2960 dg(
2961 "bynk.test.principal_required",
2962 "A test drives an identity-carrying handler, or one guarded by an actor sum, with no call-site `by <Actor>`.",
2963 &["case"],
2964 ),
2965 warn(dg(
2966 "bynk.test.remote_clock_dependent",
2967 "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.",
2968 &["case"],
2969 )),
2970 dg(
2971 "bynk.test.remote_unsupported_advance",
2972 "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.",
2973 &["case"],
2974 ),
2975 dg(
2976 "bynk.test.remote_unsupported_asset",
2977 "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.",
2978 &["case"],
2979 ),
2980 dg(
2981 "bynk.test.remote_unsupported_call",
2982 "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.",
2983 &["case"],
2984 ),
2985 dg(
2986 "bynk.test.remote_unsupported_env",
2987 "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.",
2988 &["case"],
2989 ),
2990 dg(
2991 "bynk.test.remote_unsupported_queue",
2992 "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.",
2993 &["case"],
2994 ),
2995 dg(
2996 "bynk.test.remote_unsupported_schedule",
2997 "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.",
2998 &["case"],
2999 ),
3000 dg(
3001 "bynk.test.service_bad_address",
3002 "A test body addresses a service the wrong way for its protocol (e.g. an http route without a leading path string).",
3003 &["case"],
3004 ),
3005 dg(
3006 "bynk.test.service_call_arity",
3007 "A test body's `svc.call(...)` passes the wrong number of arguments for the service's `on call` handler.",
3008 &["case"],
3009 ),
3010 dg(
3011 "bynk.test.service_no_call_handler",
3012 "A test body invokes `svc.call(...)` on a service with no `on call` handler (a `from http`/`cron`/`queue` service).",
3013 &["case"],
3014 ),
3015 dg(
3016 "bynk.test.service_unknown_route",
3017 "A test body addresses an http route / cron schedule / queue message the service does not declare.",
3018 &["case"],
3019 ),
3020 warn(dg(
3021 "bynk.test.smoke_undeclared_status",
3022 "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).",
3023 &["case"],
3024 )),
3025 dg(
3026 "bynk.test.snapshot_duplicate_name",
3027 "A case takes two snapshots (`expect v matches snapshot \"name\"`) under one name; a snapshot is keyed by its case and name.",
3028 &["snapshot_expr"],
3029 ),
3030 dg(
3031 "bynk.test.snapshot_in_property",
3032 "A `property` takes a snapshot; its body runs once per generated input, so the snapshot belongs in a `case` over a fixed value.",
3033 &["snapshot_expr"],
3034 ),
3035 dg(
3036 "bynk.test.snapshot_name_not_literal",
3037 "`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.",
3038 &["snapshot_expr"],
3039 ),
3040 dg(
3041 "bynk.test.snapshot_needs_unit_suite",
3042 "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.",
3043 &["snapshot_expr"],
3044 ),
3045 dg(
3046 "bynk.test.snapshot_not_codable",
3047 "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.",
3048 &["snapshot_expr"],
3049 ),
3050 dg(
3051 "bynk.test.stale_needs_timestamp",
3052 "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.",
3053 &["case"],
3054 ),
3055 dg(
3056 "bynk.test.unknown_actor",
3057 "A call-site `by <Actor>` names an actor the target context does not declare and that is not a prelude actor.",
3058 &["case"],
3059 ),
3060 dg(
3061 "bynk.test.wire_http_only",
3062 "A `Wire(...)` raw argument is passed to a queue, cron, `on call` or event address; `Wire` drives an http body or path segment only, so a queue message, cron tick or event is passed as a typed value.",
3063 &["case"],
3064 ),
3065 dg(
3066 "bynk.test.wire_needs_system",
3067 "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.",
3068 &["case"],
3069 ),
3070 dg(
3071 "bynk.tier.cross_context_needs_system",
3072 "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`.",
3073 &["case"],
3074 ),
3075 dg(
3076 "bynk.tier.mixed_system_suite",
3077 "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.",
3078 &["case"],
3079 ),
3080 d(
3081 "bynk.tier.system_needs_wire",
3082 "An `as system` test stands up fewer than two contexts; the system tier wires across contexts.",
3083 ),
3084 d(
3085 "bynk.transition.cross_agent_reference",
3086 "A transition predicate references another agent; step invariants are per-agent.",
3087 ),
3088 d(
3089 "bynk.transition.duplicate_name",
3090 "An agent declares two transitions with the same name.",
3091 ),
3092 d(
3093 "bynk.transition.impure_predicate",
3094 "A transition predicate uses an effectful or test-only construct; a step invariant must be pure.",
3095 ),
3096 warn(d(
3097 "bynk.transition.may_violate",
3098 "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.",
3099 )),
3100 d(
3101 "bynk.transition.no_step_reference",
3102 "A transition references neither `old` nor `new`; it constrains one state, so it is an `invariant`, not a step.",
3103 ),
3104 d(
3105 "bynk.transition.not_bool",
3106 "A transition predicate does not have type `Bool`.",
3107 ),
3108 dg(
3109 "bynk.types.argument_mismatch",
3110 "A call, method, capability, or constructor argument has the wrong type.",
3111 &["call"],
3112 ),
3113 d(
3114 "bynk.types.asset_at_boundary",
3115 "An `Asset` type appears in a record field, boundary or store position; pass its `.url` instead.",
3116 ),
3117 d(
3118 "bynk.types.bad_field_default",
3119 "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 of a type this context may construct (not a `uses`-sourced commons sum, which is `bynk.context.rebrand_construction`), `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`.)",
3120 ),
3121 dg(
3122 "bynk.types.call_arity",
3123 "A function value was applied with the wrong number of arguments.",
3124 &["call"],
3125 ),
3126 dg(
3127 "bynk.types.cannot_infer_option_type_param",
3128 "The value type of `None` could not be inferred.",
3129 &["none_expr"],
3130 ),
3131 d(
3132 "bynk.types.cannot_infer_result_type_params",
3133 "The type parameters of a `Result` could not be inferred.",
3134 ),
3135 dg(
3136 "bynk.types.catastrophic_regex",
3137 "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).",
3138 &["refinement"],
3139 ),
3140 d(
3141 "bynk.types.claims_at_boundary",
3142 "`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.",
3143 ),
3144 dg(
3145 "bynk.types.combinator_return_mismatch",
3146 "A callback passed to a combinator (`map`/`andThen`/`flatMap`/`traverseAll`/…) returns the wrong type.",
3147 &["call"],
3148 ),
3149 d(
3150 "bynk.types.constructor_arity",
3151 "A variant constructor got the wrong number of arguments.",
3152 ),
3153 d(
3154 "bynk.types.constructor_base_mismatch",
3155 "A `.of` constructor was given an argument of the wrong base type.",
3156 ),
3157 d(
3158 "bynk.types.decimal_division_unscaled",
3159 "`/` 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).",
3160 ),
3161 d(
3162 "bynk.types.decimal_negation_too_large",
3163 "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).",
3164 ),
3165 dg(
3166 "bynk.types.derives_automatic",
3167 "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).",
3168 &["type_decl"],
3169 ),
3170 dg(
3171 "bynk.types.derives_field_not_orderable",
3172 "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).",
3173 &["type_decl"],
3174 ),
3175 dg(
3176 "bynk.types.duplicate_literal_arm",
3177 "A `match` has two arms for the same literal value.",
3178 &["match_arm"],
3179 ),
3180 dg(
3181 "bynk.types.duplicate_pattern_field",
3182 "A record pattern lists the same field twice.",
3183 &["record_pattern"],
3184 ),
3185 dg(
3186 "bynk.types.duplicate_variant_arm",
3187 "A `match` has two arms for the same variant.",
3188 &["match_arm"],
3189 ),
3190 d(
3191 "bynk.types.embeds_ambiguous",
3192 "A type is embedded by more than one variant of a sum, so `?`'s conversion would be ambiguous.",
3193 ),
3194 d(
3195 "bynk.types.embeds_unknown_variant",
3196 "An `embeds … as V` clause names a variant the sum does not declare.",
3197 ),
3198 d(
3199 "bynk.types.embeds_variant_shape",
3200 "An `embeds E as V` target variant must have exactly one payload field, of type `E`.",
3201 ),
3202 dg(
3203 "bynk.types.empty_range_pattern",
3204 "A range pattern or `via schema(...)` range has its bounds inverted (`lo > hi`), so it can never match.",
3205 &["int_range"],
3206 ),
3207 dg(
3208 "bynk.types.empty_refinement",
3209 "A refinement admits no values (contradictory predicates).",
3210 &["refinement"],
3211 ),
3212 dg(
3213 "bynk.types.err_value_mismatch",
3214 "An `Err` payload has the wrong type.",
3215 &["err_expr"],
3216 ),
3217 d(
3218 "bynk.types.extensible_match_needs_wildcard",
3219 "A `match` covers an extensible standard-library enum (`FetchError`, `Method`) without a wildcard; it may gain variants in a minor release.",
3220 ),
3221 dg(
3222 "bynk.types.field_access_on_non_record",
3223 "Field access on a value that is not a record.",
3224 &["field_access"],
3225 ),
3226 d(
3227 "bynk.types.field_default_on_variant",
3228 "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.",
3229 ),
3230 dg(
3231 "bynk.types.field_refinement_not_base",
3232 "An inline field refinement requires a base or refined type.",
3233 &["record_field"],
3234 ),
3235 dg(
3236 "bynk.types.field_value_mismatch",
3237 "A record field was given a value of the wrong type.",
3238 &["record_construction"],
3239 ),
3240 dg(
3241 "bynk.types.function_at_boundary",
3242 "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.",
3243 &["function_type_ref"],
3244 ),
3245 dg(
3246 "bynk.types.guard_not_bool",
3247 "A match-arm `if` guard is not a `Bool` expression.",
3248 &["match_arm"],
3249 ),
3250 d(
3251 "bynk.types.headers_at_boundary",
3252 "`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.",
3253 ),
3254 d(
3255 "bynk.types.held_at_boundary",
3256 "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).",
3257 ),
3258 d(
3259 "bynk.types.held_not_comparable",
3260 "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
3261 ),
3262 dg(
3263 "bynk.types.if_branch_mismatch",
3264 "The branches of an `if` have different types.",
3265 &["if_expr"],
3266 ),
3267 dg(
3268 "bynk.types.if_non_bool_cond",
3269 "An `if` condition is not a `Bool`.",
3270 &["if_expr"],
3271 ),
3272 dg(
3273 "bynk.types.if_without_else_requires_unit",
3274 "An `if` with no `else` branch has a non-unit then-branch; the missing else defaults to `()`, so the branch must be `()` or `Effect[()]`.",
3275 &["if_expr"],
3276 ),
3277 d(
3278 "bynk.types.interpolation_non_scalar",
3279 "An interpolation hole holds a value with no string form.",
3280 ),
3281 dg(
3282 "bynk.types.invalid_regex",
3283 "A `Matches` predicate, or a regex method's pattern (`containsRegex`, …), contains an invalid regular expression or malformed inline flags.",
3284 &["refinement"],
3285 ),
3286 dg(
3287 "bynk.types.inverted_range",
3288 "An `InRange` predicate has its bounds inverted.",
3289 &["refinement"],
3290 ),
3291 dg(
3292 "bynk.types.is_base_mismatch",
3293 "An `is` refinement check is applied to a value of the wrong base type.",
3294 &["is_expr"],
3295 ),
3296 dg(
3297 "bynk.types.is_literal_pattern",
3298 "A literal was used on the right of `is`; `is` tests type/refinement, not value equality (use `==`).",
3299 &["is_expr"],
3300 ),
3301 dg(
3302 "bynk.types.is_non_sum",
3303 "`is` was applied to a value that is not a sum type.",
3304 &["is_expr"],
3305 ),
3306 dg(
3307 "bynk.types.is_range_pattern",
3308 "A range pattern was used directly on the right of `is`; `is` tests type/refinement, not value ranges (use `match`, a guard or `InRange`).",
3309 &["is_expr"],
3310 ),
3311 dg(
3312 "bynk.types.is_refined_pattern",
3313 "A refined (`where`) pattern was used on the right of `is`; refined patterns are `match`-only.",
3314 &["is_expr"],
3315 ),
3316 dg(
3317 "bynk.types.is_unknown_variant",
3318 "`is` names a variant the type does not have.",
3319 &["is_expr"],
3320 ),
3321 dg(
3322 "bynk.types.json_uncodable",
3323 "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).",
3324 &["method_call"],
3325 ),
3326 d(
3327 "bynk.types.key_at_boundary",
3328 "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).",
3329 ),
3330 dg(
3331 "bynk.types.key_not_orderable",
3332 "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.",
3333 &[],
3334 ),
3335 dg(
3336 "bynk.types.lambda_mismatch",
3337 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
3338 &["lambda_expr"],
3339 ),
3340 dg(
3341 "bynk.types.let_annotation_mismatch",
3342 "A `let` value does not match its type annotation.",
3343 &["let_stmt"],
3344 ),
3345 dg(
3346 "bynk.types.list_element_mismatch",
3347 "A list-literal element has a different type from the list's element type.",
3348 &["list_literal"],
3349 ),
3350 dg(
3351 "bynk.types.list_pattern_on_non_list",
3352 "A list pattern is matched against a value that is not a `List` (a record, sum, base type, `Set` or `Map`).",
3353 &["list_pattern"],
3354 ),
3355 dg(
3356 "bynk.types.match_arm_mismatch",
3357 "A `match` arm has a different type from the others.",
3358 &["match_arm"],
3359 ),
3360 dg(
3361 "bynk.types.match_non_sum_discriminant",
3362 "`match` was applied to a value that is not a sum type.",
3363 &["match_expr"],
3364 ),
3365 dg(
3366 "bynk.types.method_arity",
3367 "A method was called with the wrong number of arguments.",
3368 &["method_call"],
3369 ),
3370 dg(
3371 "bynk.types.method_not_found",
3372 "Called a method the type does not have.",
3373 &["method_call"],
3374 ),
3375 dg(
3376 "bynk.types.method_on_non_named_type",
3377 "A method was called on a built-in type that has no methods.",
3378 &["method_call"],
3379 ),
3380 dg(
3381 "bynk.types.mixed_pattern_bindings",
3382 "A pattern mixes named and positional bindings.",
3383 &["variant_pattern"],
3384 ),
3385 dg(
3386 "bynk.types.negative_length",
3387 "A length predicate was given a negative value.",
3388 &["refinement"],
3389 ),
3390 dg(
3391 "bynk.types.never_inferred",
3392 "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.",
3393 &["let_stmt"],
3394 ),
3395 dg(
3396 "bynk.types.no_numeric_coercion",
3397 "`Int`, `Float` and `Decimal` were mixed without an explicit conversion — in an operation, a comparison or refinement bounds.",
3398 &["binary_expr", "refinement"],
3399 ),
3400 dg(
3401 "bynk.types.non_exhaustive_match",
3402 "A `match` does not cover every value.",
3403 &["match_expr"],
3404 ),
3405 d(
3406 "bynk.types.not_codable",
3407 "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).",
3408 ),
3409 d(
3410 "bynk.types.not_comparable",
3411 "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).",
3412 ),
3413 dg(
3414 "bynk.types.not_keyable",
3415 "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).",
3416 &["generic_type_ref"],
3417 ),
3418 d(
3419 "bynk.types.not_orderable",
3420 "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).",
3421 ),
3422 dg(
3423 "bynk.types.ok_value_mismatch",
3424 "An `Ok` payload has the wrong type.",
3425 &["ok_expr"],
3426 ),
3427 dg(
3428 "bynk.types.opaque_raw_outside",
3429 "`.raw` on an opaque type was used outside its defining commons.",
3430 &["field_access"],
3431 ),
3432 dg(
3433 "bynk.types.opaque_unsafe_outside",
3434 "`.unsafe` on an opaque type was used outside its defining context.",
3435 &["field_access"],
3436 ),
3437 dg(
3438 "bynk.types.or_pattern_binding_mismatch",
3439 "An or-pattern's alternatives don't all bind the same set of names.",
3440 &["match_arm", "is_expr"],
3441 ),
3442 dg(
3443 "bynk.types.or_pattern_type_mismatch",
3444 "An or-pattern's alternatives give a shared binding different types (or refinements).",
3445 &["match_arm", "is_expr"],
3446 ),
3447 dg(
3448 "bynk.types.pattern_arity",
3449 "A pattern binds the wrong number of payload fields.",
3450 &["variant_pattern"],
3451 ),
3452 dg(
3453 "bynk.types.pattern_type_mismatch",
3454 "A pattern's type does not match the matched value.",
3455 &["variant_pattern"],
3456 ),
3457 dg(
3458 "bynk.types.polynomial_regex",
3459 "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.",
3460 &["refinement"],
3461 ),
3462 warn(dg(
3463 "bynk.types.polynomial_regex_capped",
3464 "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).",
3465 &["refinement"],
3466 )),
3467 dg(
3468 "bynk.types.predicate_base_mismatch",
3469 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
3470 &["refinement"],
3471 ),
3472 d(
3473 "bynk.types.query_at_boundary",
3474 "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).",
3475 ),
3476 dg(
3477 "bynk.types.question_error_mismatch",
3478 "`?` propagates an error type incompatible with the function's.",
3479 &["question_expr"],
3480 ),
3481 dg(
3482 "bynk.types.question_on_non_result",
3483 "`?` was applied to a non-`Result` value.",
3484 &["question_expr"],
3485 ),
3486 dg(
3487 "bynk.types.question_option_outside_http",
3488 "`?` lifts an `Option` only inside a handler returning `HttpResult` (`None` becomes `NotFound`); elsewhere use `.okOr(err)`.",
3489 &["question_expr"],
3490 ),
3491 dg(
3492 "bynk.types.question_outside_result",
3493 "`?` used in a function that does not return a `Result`.",
3494 &["question_expr"],
3495 ),
3496 dg(
3497 "bynk.types.range_pattern_on_non_int",
3498 "A range pattern (`lo..hi`) was matched against a scrutinee that is not an `Int`.",
3499 &["int_range"],
3500 ),
3501 dg(
3502 "bynk.types.record_pattern_on_non_record",
3503 "A record pattern names a type that is not a record (a sum, enum, refined or opaque type, or a built-in).",
3504 &["record_pattern"],
3505 ),
3506 dg(
3507 "bynk.types.regex_not_literal",
3508 "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.",
3509 &["method_call"],
3510 ),
3511 d(
3512 "bynk.types.rejection_at_boundary",
3513 "`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.",
3514 ),
3515 d(
3516 "bynk.types.request_query_at_boundary",
3517 "`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.",
3518 ),
3519 d(
3520 "bynk.types.return_mismatch",
3521 "A returned value does not match the declared return type.",
3522 ),
3523 d(
3524 "bynk.types.rounding_mode_position",
3525 "`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).",
3526 ),
3527 dg(
3528 "bynk.types.select_tail_has_select",
3529 "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`.",
3530 &["method_call"],
3531 ),
3532 dg(
3533 "bynk.types.sequence_needs_result",
3534 "`sequenceAll`/`sequenceTry` was called on a list whose elements are not `Result`s. They collect a `List[Result[T, E]]`.",
3535 &["method_call"],
3536 ),
3537 dg(
3538 "bynk.types.some_value_mismatch",
3539 "A `Some` payload has the wrong type.",
3540 &["some_expr"],
3541 ),
3542 dg(
3543 "bynk.types.sql_not_literal",
3544 "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).",
3545 &["method_call", "record_construction", "record_spread"],
3546 ),
3547 dg(
3548 "bynk.types.sql_row_shape",
3549 "`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).",
3550 &["method_call"],
3551 ),
3552 d(
3553 "bynk.types.sql_statement_at_boundary",
3554 "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).",
3555 ),
3556 d(
3557 "bynk.types.stream_at_boundary",
3558 "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).",
3559 ),
3560 d(
3561 "bynk.types.stream_not_comparable",
3562 "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
3563 ),
3564 d(
3565 "bynk.types.type_mismatch",
3566 "Two types that were required to match did not.",
3567 ),
3568 dg(
3569 "bynk.types.uninferable_element_type",
3570 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
3571 &["list_literal"],
3572 ),
3573 dg(
3574 "bynk.types.unknown_field",
3575 "Referenced a field the record type does not declare.",
3576 &["field_access"],
3577 ),
3578 dg(
3579 "bynk.types.unknown_pattern_field",
3580 "A pattern names a field the variant does not have.",
3581 &["variant_pattern"],
3582 ),
3583 d(
3584 "bynk.types.unknown_rounding_mode",
3585 "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).",
3586 ),
3587 dg(
3588 "bynk.types.unknown_static_member",
3589 "Referenced an unknown static member on a type.",
3590 &["field_access"],
3591 ),
3592 dg(
3593 "bynk.types.unknown_variant_in_pattern",
3594 "A pattern names a variant the sum type does not have.",
3595 &["variant_pattern"],
3596 ),
3597 dg(
3598 "bynk.types.unreachable_arm",
3599 "A `match` arm is unreachable.",
3600 &["match_arm"],
3601 ),
3602 d(
3603 "bynk.types.variant_arity",
3604 "A variant constructor got the wrong number of payload values.",
3605 ),
3606 d(
3607 "bynk.types.variant_missing_payload",
3608 "A variant requiring a payload was used without one.",
3609 ),
3610 d(
3611 "bynk.types.variant_payload_mismatch",
3612 "A variant payload has the wrong type.",
3613 ),
3614 dg(
3615 "bynk.uses.name_conflict",
3616 "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.",
3617 &["uses_decl"],
3618 ),
3619 dg(
3620 "bynk.uses.self_reference",
3621 "A commons `uses` itself.",
3622 &["uses_decl"],
3623 ),
3624 dg(
3625 "bynk.uses.target_is_context",
3626 "`uses` targets a context instead of a commons.",
3627 &["uses_decl"],
3628 ),
3629 dg(
3630 "bynk.uses.unknown_commons",
3631 "`uses` names a commons that does not exist.",
3632 &["uses_decl"],
3633 ),
3634 dg(
3635 "bynk.val.agent_not_generable",
3636 "A `for all`/`Val` cannot generate an agent — fabricated agent states need not be reachable.",
3637 &["for_all"],
3638 ),
3639 dg(
3640 "bynk.val.arity",
3641 "`Val[T]` was given the wrong number of pin arguments.",
3642 &["val_expr"],
3643 ),
3644 dg(
3645 "bynk.val.literal_violates",
3646 "A pinned `Val[T]` value violates the type's refinement.",
3647 &["val_expr"],
3648 ),
3649 dg(
3650 "bynk.val.needs_pin",
3651 "A bare `Val[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
3652 &["val_expr"],
3653 ),
3654 dg(
3655 "bynk.val.outside_test",
3656 "`Val[T]` was used outside a test case body.",
3657 &["val_expr"],
3658 ),
3659 dg(
3660 "bynk.val.pin_not_literal",
3661 "A `Val[T]` pin argument is not a compile-time literal.",
3662 &["val_expr"],
3663 ),
3664 dg(
3665 "bynk.val.pin_unsupported",
3666 "A pin was given for a type kind that does not support pinning.",
3667 &["val_expr"],
3668 ),
3669 dg(
3670 "bynk.val.unknown_type",
3671 "`Val[T]` names a type that does not resolve.",
3672 &["val_expr"],
3673 ),
3674 dg(
3675 "bynk.val.unsupported_kind",
3676 "`Val[T]` cannot fabricate a value for this kind of type.",
3677 &["val_expr"],
3678 ),
3679 dg(
3680 "bynk.visibility.private_in_public",
3681 "A public declaration's signature names a `private` type of its own unit, which an importer could neither name nor build.",
3682 &["visibility_modifier"],
3683 ),
3684 dg(
3685 "bynk.visibility.private_item",
3686 "A reference from another unit names a `private` declaration, which is visible only within its own unit and that unit's suites.",
3687 &["visibility_modifier"],
3688 ),
3689 warn(dg(
3690 "bynk.visibility.private_messages",
3691 "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).",
3692 &["visibility_modifier"],
3693 )),
3694 dg(
3695 "bynk.visibility.private_not_allowed",
3696 "`private` modifies a declaration it does not apply to: anything but a `fn`, `type`, `messages`, `asset`, `embed` or `const` in a commons or context.",
3697 &["visibility_modifier"],
3698 ),
3699 d(
3700 "bynk.wasm.panic",
3701 "The in-browser compiler panicked internally (a compiler bug, reported as a diagnostic instead of crashing the page).",
3702 ),
3703 d(
3704 "bynk.wasm.strip_failed",
3705 "The in-browser compiler could not strip the emitted TypeScript to JavaScript.",
3706 ),
3707 dg(
3708 "bynk.within.in_agent_handler",
3709 "`e.within(d)` was used in an agent handler, which has no execution context to hand the abandoned effect to.",
3710 &["method_call"],
3711 ),
3712 dg(
3713 "bynk.within.in_pure_context",
3714 "`e.within(d)` was used in a pure (non-effectful) context.",
3715 &["method_call"],
3716 ),
3717 dg(
3718 "bynk.within.outside_handler",
3719 "`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.",
3720 &["method_call"],
3721 ),
3722 dg(
3723 "bynk.within.timed_out_not_in_scope",
3724 "`e.within(d)` yields `Result[_, TimedOut]`, but the unit does not consume `bynk`, so `TimedOut` is not in scope.",
3725 &["method_call"],
3726 ),
3727 d(
3728 "bynk.ws.message_frame_param",
3729 "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).",
3730 ),
3731 d(
3732 "bynk.ws.open_given_unsupported",
3733 "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).",
3734 ),
3735 d(
3736 "bynk.ws.open_transfer_cross_file",
3737 "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.",
3738 ),
3739 d(
3740 "bynk.ws.open_transfer_key",
3741 "On the Workers target, the key of a WebSocket `on open` handler's connection transfer is not a route parameter, a constant of the context or of a commons it uses, or a literal — the upgrade is routed to the hosting Durable Object before the body runs, so the edge must be able to evaluate the key on its own.",
3742 ),
3743 d(
3744 "bynk.ws.open_transfer_shape",
3745 "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).",
3746 ),
3747 d(
3748 "bynk.ws.route_param_mismatch",
3749 "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).",
3750 ),
3751];
3752
3753const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
3755 DiagnosticInfo {
3756 code,
3757 summary,
3758 grammar_symbol: &[],
3759 severity: Severity::Error,
3760 }
3761}
3762
3763const fn dg(
3765 code: &'static str,
3766 summary: &'static str,
3767 grammar_symbol: &'static [&'static str],
3768) -> DiagnosticInfo {
3769 DiagnosticInfo {
3770 code,
3771 summary,
3772 grammar_symbol,
3773 severity: Severity::Error,
3774 }
3775}
3776
3777const fn warn(mut info: DiagnosticInfo) -> DiagnosticInfo {
3781 info.severity = Severity::Warning;
3782 info
3783}
3784
3785const fn hint(mut info: DiagnosticInfo) -> DiagnosticInfo {
3788 info.severity = Severity::Hint;
3789 info
3790}
3791
3792pub fn category(code: &str) -> &str {
3795 code.split('.').nth(1).unwrap_or("")
3796}
3797
3798fn category_title(cat: &str) -> &'static str {
3800 match cat {
3801 "agent" | "agents" => "Agents",
3802 "asset" => "Static assets",
3803 "boundary" => "Boundaries",
3804 "capability" => "Capabilities",
3805 "cloudflare" => "Cloudflare",
3806 "consumes" => "Consumes",
3807 "context" => "Contexts",
3808 "contract" => "Contracts",
3809 "cron" => "Cron",
3810 "doc" => "Doc comments",
3811 "effect" => "Effects",
3812 "embed" => "Embedded text",
3813 "expect" => "Expectations",
3814 "exports" => "Exports",
3815 "given" => "Given capabilities",
3816 "http" => "HTTP",
3817 "lex" => "Lexer",
3818 "messages" => "Message bundles",
3819 "mock" => "Mocks (collaborators)",
3820 "observe" => "Observation",
3821 "parse" => "Parser",
3822 "project" => "Project",
3823 "property" => "Properties (generative tests)",
3824 "provider" => "Providers",
3825 "queue" => "Queue",
3826 "record_spread" => "Record spread",
3827 "refine" => "Refinement",
3828 "resolve" => "Resolution",
3829 "service" => "Services",
3830 "stability" => "Stability",
3831 "suite" => "Suites and cases",
3832 "transition" => "Transitions (step invariants)",
3833 "types" => "Type checking",
3834 "uses" => "Uses",
3835 "val" => "Value fabrication",
3836 _ => "Other",
3837 }
3838}
3839
3840pub fn render_markdown() -> String {
3844 use std::collections::BTreeMap;
3845
3846 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3848 for info in REGISTRY {
3849 by_category
3850 .entry(category_title(category(info.code)))
3851 .or_default()
3852 .push(info);
3853 }
3854
3855 let mut out = String::new();
3856 out.push_str("# Diagnostic index\n\n");
3857 out.push_str(
3858 "<!-- GENERATED FILE — do not edit by hand.\n \
3859 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
3860 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test it diagnostics_registry:: -->\n\n",
3861 );
3862 out.push_str(
3863 "Every diagnostic code the compiler can emit, with a one-line summary of \
3864 the cause, grouped by category. For step-by-step cause-and-fix guidance \
3865 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md). \
3866 For a code with a curated explanation, `bynk explain <code>` prints it in a \
3867 terminal, and in VS Code the diagnostic's **Explain** quick fix (or \
3868 **Bynk: Explain Diagnostic Code…**) shows the same text in a panel, offline.\n\n",
3869 );
3870 out.push_str(&format!(
3871 "There are **{}** codes in total.\n",
3872 REGISTRY.len()
3873 ));
3874
3875 for (title, infos) in &by_category {
3876 out.push_str(&format!("\n## {title}\n\n"));
3877 out.push_str("| Code | Summary | Construct | Severity |\n|---|---|---|---|\n");
3878 for info in infos {
3879 let construct = info
3884 .grammar_symbol
3885 .iter()
3886 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
3887 .collect::<Vec<_>>()
3888 .join(", ");
3889 let code_cell = match explain(info.code) {
3894 Some(e) => format!("[`{}`]({})", info.code, e.in_site_link()),
3895 None => format!("`{}`", info.code),
3896 };
3897 let severity = match info.severity {
3902 Severity::Error => "—",
3903 Severity::Warning => "Warning",
3904 Severity::Hint => "Hint",
3905 };
3906 out.push_str(&format!(
3907 "| {} | {} | {} | {} |\n",
3908 code_cell, info.summary, construct, severity
3909 ));
3910 }
3911 }
3912
3913 out
3914}
3915
3916pub fn render_grammar_semantics_json() -> String {
3922 use std::collections::BTreeMap;
3923
3924 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3927 for info in REGISTRY {
3928 for sym in info.grammar_symbol {
3929 by_symbol.entry(sym).or_default().push(info);
3930 }
3931 }
3932
3933 let mut map = serde_json::Map::new();
3934 map.insert(
3935 "_generated".to_string(),
3936 serde_json::Value::String(
3937 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
3938 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
3939 bynkc --test it diagnostics_registry::"
3940 .to_string(),
3941 ),
3942 );
3943 for (sym, infos) in by_symbol {
3944 let arr: Vec<serde_json::Value> = infos
3945 .iter()
3946 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
3947 .collect();
3948 map.insert(sym.to_string(), serde_json::Value::Array(arr));
3949 }
3950
3951 let mut s =
3952 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
3953 s.push('\n');
3954 s
3955}