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