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 fn lookup(code: &str) -> Option<&'static DiagnosticInfo> {
299 REGISTRY.iter().find(|d| d.code == code)
300}
301
302pub const REGISTRY: &[DiagnosticInfo] = &[
304 d(
305 "bynk.actor.bearer_identity_not_string_constructible",
306 "A `Bearer` actor's identity is not a string-constructible type.",
307 ),
308 d(
309 "bynk.actor.bearer_missing_secret",
310 "A `Bearer` actor does not name its signing secret.",
311 ),
312 d(
313 "bynk.actor.binder_shadows_param",
314 "A `by` actor binder collides with a handler parameter of the same name.",
315 ),
316 d(
317 "bynk.actor.by_on_agent",
318 "A `by` actor clause was placed on an agent `on call` handler, which has no actor.",
319 ),
320 d(
321 "bynk.actor.duplicate_sum_scheme",
322 "Two peers in a multi-actor sum share an authentication scheme.",
323 ),
324 d(
325 "bynk.actor.foreign_context_name_unkeyable",
326 "A context declaring a `Foreign` actor has a name no call key can be named from.",
327 ),
328 d(
329 "bynk.actor.foreign_duplicate_secret",
330 "A `Foreign` actor's secret is also another actor's secret in the same context.",
331 ),
332 d(
333 "bynk.actor.foreign_identity_unsupported",
334 "A `Foreign` actor declares an `identity`.",
335 ),
336 d(
337 "bynk.actor.foreign_missing_secret",
338 "A `Foreign` actor does not name the secret its calls are signed with.",
339 ),
340 d(
341 "bynk.actor.foreign_name_is_context_name",
342 "A `Foreign` actor's name could be read as a context's name.",
343 ),
344 d(
345 "bynk.actor.foreign_reserved_secret",
346 "A `Foreign` actor's secret uses a `BYNK_CALL_` edge key's name.",
347 ),
348 d(
349 "bynk.actor.foreign_secret_not_string",
350 "A `Foreign` actor's secret is not a string.",
351 ),
352 d(
353 "bynk.actor.identity_not_sealed",
354 "An actor identity type is not a context-ownable (sealed) value type.",
355 ),
356 d(
357 "bynk.actor.missing_by_on_http",
358 "An HTTP handler lacks the required `by` actor clause.",
359 ),
360 d(
361 "bynk.actor.oidc_identity_not_string_constructible",
362 "An `Oidc` actor's identity is not a string-constructible type.",
363 ),
364 d(
365 "bynk.actor.oidc_missing_audience",
366 "An `Oidc` actor does not name its `audience`.",
367 ),
368 d(
369 "bynk.actor.oidc_missing_issuer",
370 "An `Oidc` actor does not name its `issuer`.",
371 ),
372 d(
373 "bynk.actor.oidc_missing_jwks",
374 "An `Oidc` actor does not name its `jwks` endpoint.",
375 ),
376 d(
377 "bynk.actor.oidc_not_in_sum",
378 "An `Oidc` actor appears as a member of a multi-actor sum.",
379 ),
380 d(
381 "bynk.actor.oidc_trust_from_is_secret",
382 "An `Oidc` actor's `trustFrom` names an environment variable that an actor uses as its `secret`.",
383 ),
384 d(
385 "bynk.actor.oidc_trust_from_not_string",
386 "An `Oidc` actor's `trustFrom` isn't a string naming an environment variable.",
387 ),
388 d(
389 "bynk.actor.outside_context",
390 "An `actor` was declared outside a context (e.g. in a commons).",
391 ),
392 d(
393 "bynk.actor.refinement_base_unsupported",
394 "A refinement actor's base is not a `Bearer` actor (no claims to authorise against).",
395 ),
396 d(
397 "bynk.actor.refinement_in_sum",
398 "A refinement actor appears as a member of a multi-actor sum.",
399 ),
400 d(
401 "bynk.actor.refinement_predicate_unsupported",
402 "A refinement actor's `where` predicate is outside the closed claim-predicate set.",
403 ),
404 d(
405 "bynk.actor.scheme_not_admissible",
406 "An actor's scheme is not admissible on this handler's protocol.",
407 ),
408 d(
409 "bynk.actor.signature_identity_unsupported",
410 "A `Signature` actor declared an `identity`, which is not yet supported.",
411 ),
412 d(
413 "bynk.actor.signature_missing_header",
414 "A `Signature` actor does not name its signature header.",
415 ),
416 d(
417 "bynk.actor.signature_missing_secret",
418 "A `Signature` actor does not name its signing secret.",
419 ),
420 d(
421 "bynk.actor.signature_requires_body",
422 "A `Signature` handler does not take a `body` parameter.",
423 ),
424 d(
425 "bynk.actor.signature_tolerance_without_timestamp",
426 "A `Signature` actor set `tolerance` without a `timestamp` header.",
427 ),
428 d(
429 "bynk.actor.sum_requires_binder",
430 "A multi-actor sum `by` clause has no binder to match the resolved actor.",
431 ),
432 d(
433 "bynk.actor.unknown_actor",
434 "A handler's `by` clause names an actor that is not declared.",
435 ),
436 d(
437 "bynk.actor.unknown_scheme",
438 "An actor declares an authentication scheme that is not compiler-known.",
439 ),
440 d(
441 "bynk.actor.unreachable_sum_arm",
442 "A multi-actor sum has an arm unreachable after a catch-all (`None`) peer.",
443 ),
444 dg(
445 "bynk.adapter.consumes_context",
446 "An `adapter` consumed a context; adapter dependencies are adapter-to-adapter.",
447 &["consumes_decl"],
448 ),
449 dg(
450 "bynk.adapter.consumes_requires_selection",
451 "An `adapter` used a whole-unit or aliased `consumes`; adapters must select capabilities with `consumes U { Cap, … }`.",
452 &["consumes_decl"],
453 ),
454 dg(
455 "bynk.adapter.disallowed_item",
456 "An `adapter` declared a `service`, `agent`, or other item it may not contain.",
457 &["adapter_decl"],
458 ),
459 dg(
460 "bynk.adapter.duplicate_binding",
461 "An `adapter` declared more than one `binding` clause.",
462 &["binding_decl"],
463 ),
464 dg(
465 "bynk.adapter.include_duplicate",
466 "An adapter `binding … includes [ … ]` list names one file more than once.",
467 &["binding_decl"],
468 ),
469 dg(
470 "bynk.adapter.include_kind",
471 "An adapter `binding … includes [ … ]` entry is not a `.wasm` file; only WebAssembly modules can be included.",
472 &["binding_decl"],
473 ),
474 dg(
475 "bynk.adapter.include_missing",
476 "An adapter `binding … includes [ … ]` entry names a file that could not be read.",
477 &["binding_decl"],
478 ),
479 dg(
480 "bynk.adapter.include_outside",
481 "An adapter `binding … includes [ … ]` path is absolute or climbs out of the adapter's directory with `..`.",
482 &["binding_decl"],
483 ),
484 dg(
485 "bynk.adapter.no_binding",
486 "An `adapter` declares an external provider but no `binding` module to supply it.",
487 &["adapter_decl"],
488 ),
489 dg(
490 "bynk.adapter.provider_has_body",
491 "A provider inside an `adapter` has a Bynk body; adapter providers must be external.",
492 &["provider_decl"],
493 ),
494 d(
495 "bynk.agent.class_conflict",
496 "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`.",
497 ),
498 d(
499 "bynk.agent.class_removed",
500 "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.",
501 ),
502 dg(
503 "bynk.agent.construction_arity",
504 "An agent was constructed with the wrong number of key arguments.",
505 &["agent_decl"],
506 ),
507 dg(
508 "bynk.agent.handler_arity",
509 "An agent handler was called with the wrong number of arguments.",
510 &["agent_decl"],
511 ),
512 dg(
513 "bynk.agent.handler_not_found",
514 "Called a handler the agent does not declare.",
515 &["agent_decl"],
516 ),
517 dg(
518 "bynk.agent.key_mismatch",
519 "An agent key argument has the wrong type.",
520 &["agent_decl"],
521 ),
522 warn(d(
523 "bynk.agent.migrate_below_floor",
524 "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).",
525 )),
526 d(
527 "bynk.agent.migrate_duplicate",
528 "Two `migrate` steps in one agent read the same schema version.",
529 ),
530 d(
531 "bynk.agent.migrate_duplicate_assignment",
532 "A `migrate` step assigns the same `store` field more than once; each field takes at most one value per step (record-literal semantics).",
533 ),
534 d(
535 "bynk.agent.migrate_impure",
536 "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.",
537 ),
538 d(
539 "bynk.agent.migrate_incomplete",
540 "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).",
541 ),
542 d(
543 "bynk.agent.migrate_shape_mismatch",
544 "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.",
545 ),
546 d(
547 "bynk.agent.migrate_unknown_version",
548 "A `migrate` step reads a schema version the lock does not record below the agent's current version.",
549 ),
550 d(
551 "bynk.agent.non_additive_state_change",
552 "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.",
553 ),
554 dg(
555 "bynk.agent.outside_context",
556 "An `agent` was declared outside a context.",
557 &["agent_decl"],
558 ),
559 warn(d(
560 "bynk.agent.refinement_changed",
561 "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).",
562 )),
563 d(
564 "bynk.agent.removed_live",
565 "A `removed agent` declaration names a class that is still declared; removing a class deletes its stored data.",
566 ),
567 d(
568 "bynk.agent.replaces_live",
569 "`agent New replaces Old` names an `Old` that is still declared; a rename moves the old class's data to the new one.",
570 ),
571 d(
572 "bynk.agent.replaces_unknown",
573 "`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.",
574 ),
575 dg(
576 "bynk.agent.return_not_effect",
577 "An agent handler's return type is not an `Effect`.",
578 &["agent_decl"],
579 ),
580 d(
581 "bynk.agent.state_name_conflict",
582 "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.",
583 ),
584 warn(d(
585 "bynk.agent.version_without_path",
586 "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).",
587 )),
588 dg(
589 "bynk.agents.bad_state_initialiser",
590 "An agent `store` field initialiser is not a static value of the field's type.",
591 &["store_field"],
592 ),
593 dg(
594 "bynk.agents.non_zeroable_state_field",
595 "An agent `store` field has no initialiser and no implicit zero value.",
596 &["store_field"],
597 ),
598 d(
599 "bynk.asset.duplicate",
600 "An `asset` name is declared more than once in the same unit.",
601 ),
602 d(
603 "bynk.asset.invalid_at_path",
604 "An `asset`'s `at` path is not a URL path naming one file, or lies under `/_assets/` or `/_bynk/`.",
605 ),
606 warn(d(
607 "bynk.asset.may_shadow_route",
608 "A parameterised HTTP route matches a fixed asset path, so it never sees requests for that path (a warning).",
609 )),
610 d(
611 "bynk.asset.missing_file",
612 "An `asset` names a file that is not in the project's `assets/` folder.",
613 ),
614 d(
615 "bynk.asset.needs_project",
616 "A single-file build met an `asset` declaration; assets need a project build.",
617 ),
618 warn(d(
619 "bynk.asset.not_served",
620 "A deployable Bundle build met an `asset`; a Bundle ships no files, so its `.url` would not be served (a warning).",
621 )),
622 d(
623 "bynk.asset.outside_assets_dir",
624 "An `asset` path does not name a file in the project's `assets/` folder.",
625 ),
626 d(
627 "bynk.asset.outside_context_or_commons",
628 "An `asset` declaration appears outside a context or commons.",
629 ),
630 d(
631 "bynk.asset.path_conflict",
632 "Two different asset files would be served at one fixed path by the same Worker.",
633 ),
634 d(
635 "bynk.asset.shadows_route",
636 "A fixed asset path equals a literal HTTP route, which the platform-served asset makes unreachable.",
637 ),
638 d(
639 "bynk.asset.unreadable_file",
640 "An `asset` names a file in the project's `assets/` folder that could not be read.",
641 ),
642 d(
643 "bynk.asset.unsafe_path",
644 "An `asset` path is empty, absolute, or contains a `..` segment.",
645 ),
646 d(
647 "bynk.boundary.ambiguous_type",
648 "A value's type is declared, with different shapes, by more than one consumed context, so its fields cannot be read.",
649 ),
650 d(
651 "bynk.boundary.structural_mismatch",
652 "Data crossing a context boundary did not match the expected shape.",
653 ),
654 dg(
655 "bynk.capability.base_not_instantiable",
656 "A derived capability's base is not a platform resource that can be instantiated.",
657 &["capability_decl"],
658 ),
659 dg(
660 "bynk.capability.derived_outside_context",
661 "A derived capability was declared outside a context.",
662 &["capability_decl"],
663 ),
664 dg(
665 "bynk.capability.instance_only",
666 "A platform capability that is used only through named instances (`Service`, `R2`, `RateLimit`, `EdgeCache`) was used bare, in a `given` clause.",
667 &["given_clause"],
668 ),
669 dg(
670 "bynk.capability.invalid_option",
671 "A derived capability's option is not one string literal, is given twice, or (`@worker`) is not a Worker name outside the project.",
672 &["capability_decl"],
673 ),
674 dg(
675 "bynk.capability.missing_option",
676 "A derived capability lacks an option its base requires, such as a `Service` instance's `@worker`.",
677 &["capability_decl"],
678 ),
679 dg(
680 "bynk.capability.not_provided",
681 "On the Workers target, a capability a context requires has no provider in it.",
682 &["given_clause"],
683 ),
684 dg(
685 "bynk.capability.op_arity",
686 "A capability operation was called with the wrong number of arguments.",
687 &["capability_decl"],
688 ),
689 dg(
690 "bynk.capability.outside_context",
691 "A `capability` was declared outside a context.",
692 &["capability_decl"],
693 ),
694 dg(
695 "bynk.capability.provider_agent_cross_context",
696 "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.",
697 &["given_clause"],
698 ),
699 dg(
700 "bynk.capability.unknown_base",
701 "A derived capability's base is not a capability the context consumes.",
702 &["capability_decl"],
703 ),
704 dg(
705 "bynk.capability.unknown_operation",
706 "Referenced an operation the capability does not declare.",
707 &["capability_decl"],
708 ),
709 dg(
710 "bynk.capability.unknown_option",
711 "A derived capability carries an option its base does not take.",
712 &["capability_decl"],
713 ),
714 d(
715 "bynk.cell.invalid_target",
716 "A `:=` write targets something that is not a `store Cell` field.",
717 ),
718 d(
719 "bynk.cell.self_reference",
720 "A `:=` right-hand side reads the cell being written (a read-modify-write); use `.update`.",
721 ),
722 d(
723 "bynk.cloudflare.edge_cache_duplicate",
724 "A context declares a second `EdgeCache` instance; the edge cache is one setting for the whole Worker.",
725 ),
726 d(
727 "bynk.cloudflare.edge_cache_exported",
728 "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.",
729 ),
730 d(
731 "bynk.cloudflare.edge_cache_in_agent",
732 "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.",
733 ),
734 d(
735 "bynk.cloudflare.edge_cache_in_queue",
736 "A queue consumer reaches an `EdgeCache` instance; purge from a service handler instead.",
737 ),
738 d(
739 "bynk.cloudflare.edge_cache_in_schedule",
740 "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.",
741 ),
742 d(
743 "bynk.cloudflare.edge_cache_public_authenticated",
744 "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.",
745 ),
746 dg(
747 "bynk.consumes.alias_conflict",
748 "Two `consumes` aliases collide.",
749 &["consumes_decl"],
750 ),
751 dg(
752 "bynk.consumes.capability_name_clash",
753 "Two flattened `consumes U { Cap }` capabilities collide, or one clashes with a local capability.",
754 &["consumes_decl"],
755 ),
756 dg(
757 "bynk.consumes.name_conflict",
758 "A `consumes` name collides with another name in scope.",
759 &["consumes_decl"],
760 ),
761 dg(
762 "bynk.consumes.self_reference",
763 "A context `consumes` itself.",
764 &["consumes_decl"],
765 ),
766 dg(
767 "bynk.consumes.service_arity",
768 "A consumed service was called with the wrong number of arguments.",
769 &["consumes_decl"],
770 ),
771 dg(
772 "bynk.consumes.signature_type_unconsumed",
773 "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.",
774 &["consumes_decl"],
775 ),
776 dg(
777 "bynk.consumes.target_is_commons",
778 "`consumes` targets a `commons` instead of a context.",
779 &["consumes_decl"],
780 ),
781 dg(
782 "bynk.consumes.unknown_context",
783 "`consumes` names a context that does not exist.",
784 &["consumes_decl"],
785 ),
786 dg(
787 "bynk.consumes.unknown_service",
788 "Called a service the consumed context does not declare.",
789 &["consumes_decl"],
790 ),
791 d(
792 "bynk.context.consumes_cycle",
793 "Contexts form a `consumes` dependency cycle.",
794 ),
795 d(
796 "bynk.context.duplicate_binding",
797 "A Worker would declare two bindings with the same name, such as an agent `Kv` and the `bynk.cloudflare` KV namespace (both `KV`).",
798 ),
799 d(
800 "bynk.context.external_construction",
801 "A context-owned type was constructed from outside that context.",
802 ),
803 dg(
804 "bynk.context.external_provider",
805 "A bodiless (external) provider was declared outside an `adapter`.",
806 &["provider_decl"],
807 ),
808 d(
809 "bynk.context.opaque_inspection",
810 "An opaquely-exported type was inspected from outside its context.",
811 ),
812 d(
813 "bynk.context.rebrand_construction",
814 "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.",
815 ),
816 d(
817 "bynk.contract.duplicate_name",
818 "A function declares two contract clauses (`requires`/`ensures`) with the same name.",
819 ),
820 d(
821 "bynk.contract.impure_predicate",
822 "A contract predicate uses an effectful or test-only construct; a contract clause must be pure.",
823 ),
824 d(
825 "bynk.contract.not_bool",
826 "A contract predicate does not have type `Bool`.",
827 ),
828 d(
829 "bynk.contract.restated_by_test",
830 "A `case`/`property` merely restates a contract clause already declared at the function; the test is redundant.",
831 ),
832 d(
833 "bynk.contract.result_in_requires",
834 "A precondition (`requires`) references `result`; the return value is only in scope inside an `ensures`.",
835 ),
836 dg(
837 "bynk.cron.bad_params",
838 "A cron handler declares more than one parameter, or a non-`Int` one.",
839 &["cron_handler"],
840 ),
841 dg(
842 "bynk.cron.duplicate_schedule",
843 "Two cron handlers declare the same schedule.",
844 &["cron_handler"],
845 ),
846 dg(
847 "bynk.cron.invalid_schedule",
848 "A cron expression is not five whitespace-separated fields.",
849 &["cron_handler"],
850 ),
851 dg(
852 "bynk.cron.return_not_effect_result",
853 "A cron handler does not return `Effect[Result[(), E]]`.",
854 &["cron_handler"],
855 ),
856 d(
857 "bynk.dependency.path_outside_root",
858 "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.",
859 ),
860 d(
861 "bynk.deploy.contract_skew",
862 "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.",
863 ),
864 d(
865 "bynk.deploy.foreign_contract_skew",
866 "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.",
867 ),
868 d(
869 "bynk.duration.literal_overflow",
870 "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
871 ),
872 dg(
873 "bynk.effect.bind_in_pure_context",
874 "An `<-` bind was used in a pure (non-effectful) context.",
875 &["effect_let_stmt"],
876 ),
877 dg(
878 "bynk.effect.bind_on_non_effect",
879 "An `<-` bind was applied to a non-`Effect` value.",
880 &["effect_let_stmt"],
881 ),
882 d(
883 "bynk.effect.capability_in_pure_context",
884 "A capability was used in a pure context.",
885 ),
886 d(
887 "bynk.effect.cross_context_in_pure_context",
888 "A cross-context call was made in a pure context.",
889 ),
890 dg(
891 "bynk.effect.do_in_pure_context",
892 "A `do` statement was used in a pure (non-effectful) context.",
893 &["do_stmt"],
894 ),
895 dg(
896 "bynk.effect.do_on_non_effect",
897 "A `do` statement was applied to a non-`Effect` value.",
898 &["do_stmt"],
899 ),
900 dg(
901 "bynk.effect.do_requires_unit",
902 "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.",
903 &["do_stmt"],
904 ),
905 dg(
906 "bynk.effect.fn_value_in_pure_context",
907 "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
908 &["call"],
909 ),
910 d(
911 "bynk.effect.unbound_effect",
912 "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).",
913 ),
914 d(
915 "bynk.embed.binary_content",
916 "An `embed` names a file with a NUL byte, so it is binary, not text.",
917 ),
918 d(
919 "bynk.embed.duplicate",
920 "An `embed` name is declared more than once in the same unit.",
921 ),
922 d(
923 "bynk.embed.invalid_encoding",
924 "An `embed` names a file that is not valid UTF-8.",
925 ),
926 d(
927 "bynk.embed.missing_file",
928 "An `embed` names a file that is not in the project's `embeds/` folder.",
929 ),
930 d(
931 "bynk.embed.needs_project",
932 "A single-file build met an `embed` declaration, which needs a project's `embeds/` folder.",
933 ),
934 d(
935 "bynk.embed.outside_context_or_commons",
936 "An `embed` declaration appears outside a context or commons.",
937 ),
938 d(
939 "bynk.embed.outside_embeds_dir",
940 "An `embed` names a file outside the project's `embeds/` folder.",
941 ),
942 d(
943 "bynk.embed.too_large",
944 "An `embed` names a file over 256 KiB, or the project's embedded files total over 1 MiB.",
945 ),
946 d(
947 "bynk.embed.unreadable_file",
948 "An `embed` names a file in the project's `embeds/` folder that could not be read.",
949 ),
950 d(
951 "bynk.embed.unsafe_path",
952 "An `embed` path is empty, absolute, or contains a `..` segment.",
953 ),
954 d(
955 "bynk.event.bad_field_default",
956 "An event field's default expression (`field: T = expr`) is not a static, wire-representable value of the field's declared type — a literal (including one admitted to a refined type), a sum variant, `Some`/`None`/`Ok`/`Err`, a record, or `T.unsafe(lit)` for an opaque type whose literal also satisfies the refinement.",
957 ),
958 d(
959 "bynk.event.bad_params",
960 "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.",
961 ),
962 d(
963 "bynk.event.bad_schema_dispatch",
964 "A `via schema(...)` dispatch clause's argument is malformed — it must be a single, positive, positional `Int` literal.",
965 ),
966 d(
967 "bynk.event.bad_schema_version",
968 "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.",
969 ),
970 d(
971 "bynk.event.default_outside_event",
972 "A field default (`field: T = expr`) was written on a record field outside an `event` declaration — a default is only meaningful on an event's own field, since it exists to let an older wire event missing this key still deserialise.",
973 ),
974 dg(
975 "bynk.event.duplicate_handler",
976 "A `from Events` service declares more than one `on event` handler; it has exactly one.",
977 &["event_handler"],
978 ),
979 d(
980 "bynk.event.emit_not_an_event",
981 "`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.",
982 ),
983 d(
984 "bynk.event.emit_outside_owner",
985 "`Events.emit[E]` named an event `E` not declared in the emitting context — only an event's declaring context may emit it.",
986 ),
987 d(
988 "bynk.event.handler_param_type_mismatch",
989 "An `on event(e: T)` handler's declared parameter type does not match its `from Events(E)` header's event type.",
990 ),
991 d(
992 "bynk.event.non_additive_schema_change",
993 "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.",
994 ),
995 d(
996 "bynk.event.outside_context",
997 "An `event` was declared outside a context.",
998 ),
999 d(
1000 "bynk.event.pattern_duplicate_field",
1001 "A `from Events(E { ... })` subscription pattern listed the same field more than once.",
1002 ),
1003 d(
1004 "bynk.event.pattern_type_mismatch",
1005 "A `from Events(E { ... })` subscription pattern field's matched value is not compatible with that field's declared type.",
1006 ),
1007 d(
1008 "bynk.event.pattern_unknown_field",
1009 "A `from Events(E { ... })` subscription pattern named a field that `E` does not declare.",
1010 ),
1011 d(
1012 "bynk.event.pattern_unknown_variant",
1013 "A `from Events(E { ... })` subscription pattern's variant value names a variant that does not exist on the field's declared sum type.",
1014 ),
1015 d(
1016 "bynk.event.pattern_variant_payload",
1017 "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.",
1018 ),
1019 dg(
1020 "bynk.event.return_not_effect_unit",
1021 "An `on event` handler returns an `Effect` of something other than `()`; emission is fire-and-forget, so it returns `Effect[()]`.",
1022 &["event_handler"],
1023 ),
1024 d(
1025 "bynk.event.schema_version_mismatch",
1026 "An event's `@schema(N)` annotation disagrees with the version the schema registry computes from the event's build history.",
1027 ),
1028 d(
1029 "bynk.event.unknown_annotation",
1030 "An `event` declaration carried an `@`-annotation other than `@schema` — event annotations are a closed set.",
1031 ),
1032 d(
1033 "bynk.event.unknown_subscription",
1034 "A `from Events(E)` subscription named `E`, which is not a declared event in this context or any consumed context.",
1035 ),
1036 dg(
1037 "bynk.expect.faults_not_effect",
1038 "A fault claim's subject (`expect <call> faults`) is not an effectful call: a value, or a call whose type is not `Effect[_]`.",
1039 &["faults_expr"],
1040 ),
1041 dg(
1042 "bynk.expect.not_bool",
1043 "`expect` was given a non-`Bool` predicate.",
1044 &["expect_expr"],
1045 ),
1046 dg(
1047 "bynk.expect.outside_case",
1048 "`expect` was used outside a `case` body.",
1049 &["expect_expr"],
1050 ),
1051 dg(
1052 "bynk.exports.capability_not_provided",
1053 "An exported capability has no provider in its context.",
1054 &["exports_decl"],
1055 ),
1056 dg(
1057 "bynk.exports.conflicting_visibility",
1058 "A type is exported with conflicting visibilities.",
1059 &["exports_decl"],
1060 ),
1061 dg(
1062 "bynk.exports.derived_capability",
1063 "`exports capability` names a derived capability, whose instance stays with its context.",
1064 &["exports_decl"],
1065 ),
1066 dg(
1067 "bynk.exports.duplicate_export",
1068 "The same name is exported more than once.",
1069 &["exports_decl"],
1070 ),
1071 dg(
1072 "bynk.exports.duplicate_in_clause",
1073 "A name appears twice in one `exports` clause.",
1074 &["exports_decl"],
1075 ),
1076 dg(
1077 "bynk.exports.undeclared_capability",
1078 "`exports capability` names a capability that is not declared.",
1079 &["exports_decl"],
1080 ),
1081 dg(
1082 "bynk.exports.undeclared_type",
1083 "`exports` names a type that is not declared.",
1084 &["exports_decl"],
1085 ),
1086 d(
1087 "bynk.fmt.comment_loss",
1088 "The formatter would drop a comment, so it leaves the file unchanged.",
1089 ),
1090 d(
1091 "bynk.fmt.mixed_comment_syntax",
1092 "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.",
1093 ),
1094 d(
1095 "bynk.fmt.roundtrip",
1096 "The formatter's output does not re-parse to the same program, so it leaves the file unchanged.",
1097 ),
1098 dg(
1099 "bynk.generics.duplicate_type_param",
1100 "A `type` or `fn` declares the same type-parameter name more than once (v0.157, ADR 0183).",
1101 &[],
1102 ),
1103 dg(
1104 "bynk.generics.generic_non_record",
1105 "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).",
1106 &["type_decl"],
1107 ),
1108 dg(
1109 "bynk.generics.generic_record_at_boundary",
1110 "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.",
1111 &[],
1112 ),
1113 dg(
1114 "bynk.generics.generic_sum_embeds",
1115 "A generic sum type carries an `embeds` clause; embedding into a generic sum is not supported (#593).",
1116 &["type_decl"],
1117 ),
1118 dg(
1119 "bynk.generics.method_on_generic_type",
1120 "A *static* method is attached to a generic type; static methods on generic types are deferred (they have no receiver to supply the type's parameters). Instance methods on generic types are supported (#594).",
1121 &["fn_decl"],
1122 ),
1123 dg(
1124 "bynk.generics.no_bounds",
1125 "A type parameter carries a bound (`[A: …]`); bounded generics are not in v0.20a.",
1126 &["fn_decl"],
1127 ),
1128 dg(
1129 "bynk.generics.recursive_generic_at_boundary",
1130 "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).",
1131 &[],
1132 ),
1133 dg(
1134 "bynk.generics.type_arg_count",
1135 "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).",
1136 &["applied_type_ref"],
1137 ),
1138 dg(
1139 "bynk.generics.type_arg_mismatch",
1140 "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
1141 &["call"],
1142 ),
1143 dg(
1144 "bynk.generics.uninferable_type_arg",
1145 "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.",
1146 &["call"],
1147 ),
1148 dg(
1149 "bynk.given.cross_context_unknown_capability",
1150 "`given B.Cap` names a capability the consumed context does not export.",
1151 &["given_clause"],
1152 ),
1153 dg(
1154 "bynk.given.undeclared_capability",
1155 "A handler uses a capability it did not declare with `given`.",
1156 &["given_clause"],
1157 ),
1158 dg(
1159 "bynk.given.unknown_capability",
1160 "`given` names a capability that does not exist.",
1161 &["given_clause"],
1162 ),
1163 warn(dg(
1164 "bynk.given.unused_capability",
1165 "A `given` capability is never used (warning).",
1166 &["given_clause"],
1167 )),
1168 d(
1169 "bynk.held.branch_divergence",
1170 "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).",
1171 ),
1172 d(
1173 "bynk.held.consume_on_borrow",
1174 "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).",
1175 ),
1176 d(
1177 "bynk.held.leak",
1178 "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).",
1179 ),
1180 d(
1181 "bynk.held.query_accessor_on_held_map",
1182 "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.",
1183 ),
1184 d(
1185 "bynk.held.unsupported_map_op",
1186 "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).",
1187 ),
1188 d(
1189 "bynk.held.unsupported_storage",
1190 "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).",
1191 ),
1192 d(
1193 "bynk.held.use_after_consume",
1194 "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).",
1195 ),
1196 d(
1197 "bynk.history.not_an_agent",
1198 "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).",
1199 ),
1200 d(
1201 "bynk.history.not_generable",
1202 "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).",
1203 ),
1204 d(
1205 "bynk.history.outside_property",
1206 "`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).",
1207 ),
1208 d(
1209 "bynk.history.restates_invariant",
1210 "A history property merely re-checks a guarantee a declared `invariant`/`transition` already enforces on every reached state (testing track slice 7, ADR 0155).",
1211 ),
1212 dg(
1213 "bynk.http.body_on_get_or_delete",
1214 "A GET or DELETE handler declares a `body` parameter.",
1215 &["http_handler"],
1216 ),
1217 d(
1218 "bynk.http.cache_bad_immutable",
1219 "A `@cache` annotation's `immutable` is not a `Bool` literal.",
1220 ),
1221 d(
1222 "bynk.http.cache_bad_max_age",
1223 "A `@cache` annotation's `maxAge` is missing or not a positive `Duration` literal.",
1224 ),
1225 d(
1226 "bynk.http.cache_bad_scope",
1227 "A `@cache` annotation's `scope` is not `public` or `private`.",
1228 ),
1229 d(
1230 "bynk.http.cache_duplicate",
1231 "A handler carries more than one `@cache` annotation.",
1232 ),
1233 d(
1234 "bynk.http.cache_max_age_fractional_seconds",
1235 "A `@cache` annotation's `maxAge` is positive but does not resolve to a whole number of seconds.",
1236 ),
1237 d(
1238 "bynk.http.cache_on_non_get",
1239 "A `@cache` annotation is placed on a handler that is not `on http GET`.",
1240 ),
1241 d(
1242 "bynk.http.cache_unknown_arg",
1243 "A `@cache` annotation has an argument outside the closed set (`maxAge`/`scope`/`immutable`).",
1244 ),
1245 d(
1246 "bynk.http.cors_invalid_field",
1247 "A `cors` policy field (`headers`/`credentials`/`maxAge`) has the wrong value shape.",
1248 ),
1249 d(
1250 "bynk.http.cors_invalid_origins",
1251 "A `cors` policy's `origins` is missing, empty, or not a list of string literals.",
1252 ),
1253 d(
1254 "bynk.http.cors_not_http",
1255 "A `cors { }` policy appears on a service that is not `from http`.",
1256 ),
1257 d(
1258 "bynk.http.cors_unknown_field",
1259 "A `cors { }` policy declares a field outside the closed set.",
1260 ),
1261 d(
1262 "bynk.http.cors_wildcard_credentials",
1263 "A `cors` policy combines `credentials: true` with the wildcard origin `[\"*\"]`.",
1264 ),
1265 dg(
1266 "bynk.http.duplicate_rejected",
1267 "A `from http` service declares `on rejected` more than once.",
1268 &["rejected_handler"],
1269 ),
1270 dg(
1271 "bynk.http.duplicate_route",
1272 "Two handlers share the same method and route.",
1273 &["http_handler"],
1274 ),
1275 d(
1276 "bynk.http.error_status_position",
1277 "An `ErrorStatus` name is used anywhere but as `RawError`'s first argument.",
1278 ),
1279 dg(
1280 "bynk.http.extra_param",
1281 "A handler parameter is not a path parameter, `body` or `headers`.",
1282 &["http_handler"],
1283 ),
1284 dg(
1285 "bynk.http.headers_wrong_type",
1286 "An HTTP handler's `headers` parameter is not typed `RequestHeaders`.",
1287 &["http_handler"],
1288 ),
1289 dg(
1290 "bynk.http.invalid_path",
1291 "An HTTP route path is malformed.",
1292 &["http_handler"],
1293 ),
1294 d(
1295 "bynk.http.limit_bad_max_body",
1296 "A `@limit` annotation's `maxBody` is missing or not a positive `Int` literal.",
1297 ),
1298 d(
1299 "bynk.http.limit_duplicate",
1300 "A handler carries more than one `@limit` annotation.",
1301 ),
1302 d(
1303 "bynk.http.limit_on_bodyless",
1304 "A `@limit` annotation is placed on a handler that takes no body (a GET or DELETE).",
1305 ),
1306 d(
1307 "bynk.http.limit_unknown_arg",
1308 "A `@limit` annotation has an argument outside the closed set (`maxBody`).",
1309 ),
1310 d(
1311 "bynk.http.limits_invalid_field",
1312 "A `limits` policy field (`maxBody`) has the wrong value shape.",
1313 ),
1314 d(
1315 "bynk.http.limits_not_http",
1316 "A `limits { }` policy appears on a service that is not `from http`.",
1317 ),
1318 d(
1319 "bynk.http.limits_unknown_field",
1320 "A `limits { }` policy declares a field outside the closed set.",
1321 ),
1322 dg(
1323 "bynk.http.path_param_not_stringy",
1324 "A path parameter's type is not constructible from a string.",
1325 &["http_handler"],
1326 ),
1327 d(
1328 "bynk.http.raw_bad_content_type",
1329 "A `@raw` annotation's `contentType` is missing or not a `type/subtype` (or `\"*/*\"`) string literal.",
1330 ),
1331 d(
1332 "bynk.http.raw_body_not_bytes",
1333 "The `body` of a `@raw` handler is not typed `Bytes`.",
1334 ),
1335 d(
1336 "bynk.http.raw_body_unbounded",
1337 "A `@raw` route has no request-body cap (no `@limit` and no service `limits`).",
1338 ),
1339 d(
1340 "bynk.http.raw_duplicate",
1341 "A handler carries more than one `@raw` annotation.",
1342 ),
1343 d(
1344 "bynk.http.raw_error_status",
1345 "`RawError`'s first argument is not an `ErrorStatus` name (a 4xx or 5xx `HttpResult` variant name).",
1346 ),
1347 d(
1348 "bynk.http.raw_on_bodyless",
1349 "A `@raw` annotation is placed on a handler that takes no body.",
1350 ),
1351 d(
1352 "bynk.http.raw_unknown_arg",
1353 "A `@raw` annotation has an argument outside the closed set (`contentType`).",
1354 ),
1355 dg(
1356 "bynk.http.rejected_signature",
1357 "An `on rejected` handler is not `on rejected(why: BoundaryRejection) -> HttpResult[()]` with no `by` and no `given`.",
1358 &["rejected_handler"],
1359 ),
1360 dg(
1361 "bynk.http.reserved_prefix",
1362 "A route uses the reserved `/_bynk/` prefix.",
1363 &["http_handler"],
1364 ),
1365 dg(
1366 "bynk.http.return_not_effect_http_result",
1367 "An HTTP handler does not return `Effect[HttpResult[T]]`.",
1368 &["http_handler"],
1369 ),
1370 d(
1371 "bynk.http.security_invalid_field",
1372 "A `security` policy field (`hsts`/`nosniff`) has the wrong value shape.",
1373 ),
1374 d(
1375 "bynk.http.security_not_http",
1376 "A `security { }` policy appears on a service that is not `from http`.",
1377 ),
1378 d(
1379 "bynk.http.security_unknown_field",
1380 "A `security { }` policy declares a field outside the closed set.",
1381 ),
1382 dg(
1383 "bynk.http.unbound_path_param",
1384 "A `:name` route segment has no matching handler parameter.",
1385 &["http_handler"],
1386 ),
1387 d(
1388 "bynk.http.unknown_handler_annotation",
1389 "A handler carries an annotation outside the closed set (`@cache`/`@limit`).",
1390 ),
1391 d(
1392 "bynk.index.bad_argument",
1393 "An `@indexed` argument is not a `by: <field>` label.",
1394 ),
1395 warn(d(
1396 "bynk.index.missing",
1397 "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
1398 )),
1399 d(
1400 "bynk.index.unkeyable_key",
1401 "An `@indexed(by: k)` field is not value-keyable.",
1402 ),
1403 d(
1404 "bynk.index.unknown_key",
1405 "An `@indexed(by: k)` field is not a field of the map's value type.",
1406 ),
1407 warn(d(
1408 "bynk.index.unused",
1409 "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
1410 )),
1411 d(
1412 "bynk.invariant.cross_agent_reference",
1413 "An invariant predicate references another agent; invariants are per-agent.",
1414 ),
1415 d(
1416 "bynk.invariant.duplicate_name",
1417 "An agent declares two invariants with the same name.",
1418 ),
1419 d(
1420 "bynk.invariant.impure_predicate",
1421 "An invariant predicate uses an effectful or test-only construct.",
1422 ),
1423 d(
1424 "bynk.invariant.not_bool",
1425 "An invariant predicate does not have type `Bool`.",
1426 ),
1427 dg(
1428 "bynk.lambda.unannotated_param",
1429 "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
1430 &["lambda_expr"],
1431 ),
1432 dg(
1433 "bynk.lex.bad_escape",
1434 "An invalid escape sequence in a string literal.",
1435 &["string_literal"],
1436 ),
1437 dg(
1438 "bynk.lex.float_literal_overflow",
1439 "A float literal does not fit a finite 64-bit float.",
1440 &["float_literal"],
1441 ),
1442 dg(
1443 "bynk.lex.integer_overflow",
1444 "An integer literal is outside the `Int` range, the JS safe integers ±(2^53 − 1).",
1445 &["number_literal"],
1446 ),
1447 dg(
1448 "bynk.lex.interpolation_too_deep",
1449 "A string interpolation `\\(…)` nests deeper than the lexer's fixed limit.",
1450 &["string_literal"],
1451 ),
1452 d(
1453 "bynk.lex.legacy_comment",
1454 "A `--` line comment, the spelling before #2203; a comment is `//` (auto-fixable; `bynk fmt` rewrites it).",
1455 ),
1456 d(
1457 "bynk.lex.legacy_doc_line",
1458 "A `--|` one-line doc, the spelling before #2203; a one-line doc is `--- text` (auto-fixable; `bynk fmt` rewrites it).",
1459 ),
1460 d(
1461 "bynk.lex.slash_doc",
1462 "A `///` doc comment first on its line; a Bynk doc is `--- text` or a `---` block (auto-fixable).",
1463 ),
1464 d(
1465 "bynk.lex.unclosed_doc_block",
1466 "A documentation block is not closed.",
1467 ),
1468 d(
1469 "bynk.lex.unexpected_character",
1470 "An unexpected character in the source.",
1471 ),
1472 dg(
1473 "bynk.lex.unterminated_interpolation",
1474 "An interpolation hole `\\(…)` is not closed on its line.",
1475 &["string_literal"],
1476 ),
1477 dg(
1478 "bynk.lex.unterminated_string",
1479 "A string literal is not terminated.",
1480 &["string_literal"],
1481 ),
1482 warn(d(
1483 "bynk.list.deprecated_function",
1484 "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
1485 )),
1486 d(
1487 "bynk.locale.multiple_message_bundles",
1488 "A context consumes `Locale` but its direct `uses` reaches two or more message-bundle commons — there is no single bundle to negotiate against.",
1489 ),
1490 d(
1491 "bynk.messages.format_mismatch",
1492 "A code's placeholder is formatted as a different ICU kind (plain/plural/select/number/date) across declared locales.",
1493 ),
1494 d(
1495 "bynk.messages.incomplete",
1496 "A locale is missing a code the reference locale declares.",
1497 ),
1498 d(
1499 "bynk.messages.invalid_locale_tag",
1500 "A `messages` block's locale tag is not a valid `LocaleTag` (e.g. `messages \"xx\"` where `xx` doesn't match the tag pattern).",
1501 ),
1502 d(
1503 "bynk.messages.malformed_icu_syntax",
1504 "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).",
1505 ),
1506 d(
1507 "bynk.messages.missing_locale_dependency",
1508 "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.",
1509 ),
1510 d(
1511 "bynk.messages.missing_reference",
1512 "A message bundle has no `@reference` block.",
1513 ),
1514 d(
1515 "bynk.messages.multiple_reference",
1516 "A message bundle has more than one `@reference` block.",
1517 ),
1518 d(
1519 "bynk.messages.outside_commons",
1520 "A `messages` declaration appears outside a commons.",
1521 ),
1522 d(
1523 "bynk.messages.placeholder_mismatch",
1524 "A locale's template for a code uses a different set of `{name}` placeholders than the reference locale's.",
1525 ),
1526 d(
1527 "bynk.namespace.reserved",
1528 "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
1529 ),
1530 d(
1531 "bynk.observe.impure_with",
1532 "A `with` predicate uses an effectful or test-only construct; it must be pure.",
1533 ),
1534 d(
1535 "bynk.observe.not_a_seam",
1536 "An observation targets a capability the unit under test does not consume.",
1537 ),
1538 d(
1539 "bynk.observe.trace_outside_test",
1540 "`trace(Cap.op)` appears outside a `case` body.",
1541 ),
1542 d(
1543 "bynk.observe.unknown_op",
1544 "An observation names an operation the capability does not declare.",
1545 ),
1546 d(
1547 "bynk.observe.with_not_bool",
1548 "A `with` predicate does not have type `Bool`.",
1549 ),
1550 d(
1551 "bynk.package.alias_shadows_unit",
1552 "A dependency alias in `[dependencies]` is also the first segment of one of the project's own units, so `<alias>.…` would be ambiguous.",
1553 ),
1554 d(
1555 "bynk.package.checksum_mismatch",
1556 "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.",
1557 ),
1558 d(
1559 "bynk.package.dependency_cycle",
1560 "The package graph has a cycle: a dependency depends, directly or not, on itself or on the project.",
1561 ),
1562 d(
1563 "bynk.package.dependency_not_found",
1564 "A path dependency's directory has no readable `bynk.toml`, its `bynk.toml` is invalid, or it has no `[package]`.",
1565 ),
1566 d(
1567 "bynk.package.dev_dependency_in_source",
1568 "A commons, context or adapter reaches a `[dev-dependencies]` alias, which only a suite may use.",
1569 ),
1570 d(
1571 "bynk.package.duplicate_source",
1572 "One package is reached from two different directories; a build holds one copy of each package.",
1573 ),
1574 d(
1575 "bynk.package.git_failed",
1576 "`git` couldn't clone, fetch or check out a git dependency, or the revision it names doesn't exist.",
1577 ),
1578 d(
1579 "bynk.package.lock_invalid",
1580 "`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.",
1581 ),
1582 d(
1583 "bynk.package.lock_out_of_date",
1584 "`--locked` was given, and resolving the manifests would change `bynk.lock`.",
1585 ),
1586 d(
1587 "bynk.package.name_mismatch",
1588 "A path dependency's `package` names a different package than the directory's `[package] name`.",
1589 ),
1590 d(
1591 "bynk.package.not_fetched",
1592 "A git dependency has no `bynk.lock` entry, or its store entry is missing; `bynk fetch` fetches it (refused under `--offline`).",
1593 ),
1594 d(
1595 "bynk.package.unit_not_exported",
1596 "A `uses` or `consumes` reaches a unit its dependency declares but doesn't list in `[package] exports`.",
1597 ),
1598 d(
1599 "bynk.package.unknown_unit",
1600 "A `uses` or `consumes` names, through a dependency alias, a unit the dependency doesn't declare.",
1601 ),
1602 d(
1603 "bynk.package.unsafe_source",
1604 "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).",
1605 ),
1606 d(
1607 "bynk.package.unsupported_in_dependency",
1608 "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.",
1609 ),
1610 d(
1611 "bynk.package.version_conflict",
1612 "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.",
1613 ),
1614 dg(
1615 "bynk.parse.consumes_after_decls",
1616 "`consumes` appears after other declarations.",
1617 &["consumes_decl"],
1618 ),
1619 d(
1620 "bynk.parse.dangling_handler_annotation",
1621 "A handler-position annotation (e.g. `@cache`) is not followed by an `on` handler.",
1622 ),
1623 d(
1624 "bynk.parse.doc_block_contains_code",
1625 "A documentation block's content (outside Markdown code fences) parses as declarations, so a pair of dash dividers has turned code into documentation.",
1626 ),
1627 dg(
1628 "bynk.parse.duplicate_cors",
1629 "A service declares more than one `cors { }` policy.",
1630 &["service_decl"],
1631 ),
1632 dg(
1633 "bynk.parse.duplicate_limits",
1634 "A service declares more than one `limits { }` policy.",
1635 &["service_decl"],
1636 ),
1637 dg(
1638 "bynk.parse.duplicate_security",
1639 "A service declares more than one `security { }` policy.",
1640 &["service_decl"],
1641 ),
1642 dg(
1643 "bynk.parse.empty_agent",
1644 "An `agent` body is empty.",
1645 &["agent_decl"],
1646 ),
1647 dg(
1648 "bynk.parse.empty_capability",
1649 "A `capability` body is empty.",
1650 &["capability_decl"],
1651 ),
1652 d(
1653 "bynk.parse.empty_interpolation",
1654 "An interpolation hole `\\(…)` contains no expression.",
1655 ),
1656 dg(
1657 "bynk.parse.empty_match",
1658 "A `match` has no arms.",
1659 &["match_expr"],
1660 ),
1661 dg(
1662 "bynk.parse.empty_service",
1663 "A `service` body is empty.",
1664 &["service_decl"],
1665 ),
1666 d(
1667 "bynk.parse.event_pattern_empty",
1668 "A `from Events(E { ... })` subscription pattern listed no fields — use `from Events(E)` (no braces) for an unfiltered subscription.",
1669 ),
1670 dg(
1671 "bynk.parse.expected_agent_key",
1672 "Expected a `key` declaration in an agent.",
1673 &["agent_decl"],
1674 ),
1675 d(
1676 "bynk.parse.expected_agent_storage",
1677 "An agent declares no storage — it has no `store` fields.",
1678 ),
1679 dg(
1680 "bynk.parse.expected_base_type",
1681 "Expected a base type.",
1682 &["base_type"],
1683 ),
1684 dg(
1685 "bynk.parse.expected_capability_op",
1686 "Expected a capability operation.",
1687 &["capability_op"],
1688 ),
1689 d("bynk.parse.expected_expression", "Expected an expression."),
1690 dg(
1691 "bynk.parse.expected_handler",
1692 "Expected a handler.",
1693 &["handler"],
1694 ),
1695 d("bynk.parse.expected_item", "Expected a declaration."),
1696 dg(
1697 "bynk.parse.expected_predicate",
1698 "Expected a refinement predicate.",
1699 &["refinement"],
1700 ),
1701 dg(
1702 "bynk.parse.expected_provider_op",
1703 "Expected a provider operation.",
1704 &["provider_op"],
1705 ),
1706 d("bynk.parse.expected_token", "Expected a specific token."),
1707 d("bynk.parse.expected_type", "Expected a type."),
1708 d(
1709 "bynk.parse.expected_unit_header",
1710 "Expected a `commons` or `context` header.",
1711 ),
1712 dg(
1713 "bynk.parse.expected_visibility",
1714 "Expected a visibility keyword.",
1715 &["exports_decl"],
1716 ),
1717 dg(
1718 "bynk.parse.exports_after_decls",
1719 "`exports` appears after other declarations.",
1720 &["exports_decl"],
1721 ),
1722 d(
1723 "bynk.parse.extra_tokens",
1724 "Unexpected tokens after an otherwise complete construct.",
1725 ),
1726 dg(
1727 "bynk.parse.generic_arg_count",
1728 "Wrong number of generic type arguments.",
1729 &["generic_type_ref"],
1730 ),
1731 dg(
1732 "bynk.parse.handler_in_agent",
1733 "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
1734 &["handler"],
1735 ),
1736 d(
1737 "bynk.parse.invariant_after_handler",
1738 "An `invariant` was declared after a handler; invariants precede handlers.",
1739 ),
1740 dg(
1741 "bynk.parse.let_else_on_binding",
1742 "An `else` follows a plain `let name = …` binding, which matches every value, so the `else` could never run.",
1743 &["let_stmt", "effect_let_stmt"],
1744 ),
1745 dg(
1746 "bynk.parse.let_pattern_annotation",
1747 "A `let` with a pattern carries a type annotation; the pattern's names take their types from the value.",
1748 &["let_else_stmt"],
1749 ),
1750 dg(
1751 "bynk.parse.let_pattern_without_else",
1752 "A `let` binds a pattern but has no `else` saying what the block produces when the value does not match.",
1753 &["let_else_stmt"],
1754 ),
1755 dg(
1756 "bynk.parse.malformed_float_literal",
1757 "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
1758 &["float_literal"],
1759 ),
1760 d(
1761 "bynk.parse.migrate_after_handler",
1762 "A `migrate` step is declared after an agent handler; migration steps precede the handlers.",
1763 ),
1764 d(
1765 "bynk.parse.migrate_item",
1766 "A `migrate` step's body holds something other than `field := value`, `let` or `drop field`.",
1767 ),
1768 d(
1769 "bynk.parse.multiple_docs",
1770 "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.",
1771 ),
1772 d(
1773 "bynk.parse.nesting_too_deep",
1774 "An expression or type nests deeper than the parser's fixed limit.",
1775 ),
1776 dg(
1777 "bynk.parse.non_associative",
1778 "A non-associative operator was chained (e.g. `a == b == c`).",
1779 &["binary_expr"],
1780 ),
1781 warn(d(
1782 "bynk.parse.orphan_doc_block",
1783 "A documentation block is not attached to a declaration (warning).",
1784 )),
1785 dg(
1786 "bynk.parse.policy_order",
1787 "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`.",
1788 &["service_decl"],
1789 ),
1790 dg(
1791 "bynk.parse.refined_pattern_inner",
1792 "A refined pattern's inner form is something other than `_`.",
1793 &["refined_pattern"],
1794 ),
1795 dg(
1796 "bynk.parse.reserved_keyword",
1797 "A reserved keyword was used as an identifier.",
1798 &["identifier"],
1799 ),
1800 dg(
1801 "bynk.parse.self_outside_method",
1802 "`self` used outside a method or handler.",
1803 &["self_expr"],
1804 ),
1805 d(
1806 "bynk.parse.storage_after_phase",
1807 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
1808 ),
1809 d(
1810 "bynk.parse.transition_after_handler",
1811 "A `transition` is declared after an agent handler; step invariants precede the handlers.",
1812 ),
1813 d(
1814 "bynk.parse.unexpected_adapter",
1815 "An `adapter` appeared where it is not allowed.",
1816 ),
1817 dg(
1818 "bynk.parse.unexpected_context",
1819 "A `context` appeared where it is not allowed.",
1820 &["context_decl"],
1821 ),
1822 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
1823 dg(
1824 "bynk.parse.unexpected_suite",
1825 "A `suite` appeared where it is not allowed.",
1826 &["suite_decl"],
1827 ),
1828 d(
1829 "bynk.parse.unknown_effect_method",
1830 "An unknown method on `Effect`.",
1831 ),
1832 dg(
1833 "bynk.parse.unknown_handler_kind",
1834 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
1835 &["handler"],
1836 ),
1837 dg(
1838 "bynk.parse.unknown_predicate",
1839 "An unknown refinement predicate.",
1840 &["predicate_name"],
1841 ),
1842 d(
1843 "bynk.parse.unknown_tier",
1844 "A `case`/`suite` `as <tier>` clause names something other than `unit`, `integration`, or `system`.",
1845 ),
1846 dg(
1847 "bynk.parse.uses_after_decls",
1848 "`uses` appears after other declarations.",
1849 &["uses_decl"],
1850 ),
1851 dg(
1852 "bynk.parse.variant_name_case",
1853 "A sum-type or enum variant name is not capitalised.",
1854 &["sum_variant", "enum_type"],
1855 ),
1856 warn(d(
1857 "bynk.project.duplicate_compatibility_flag",
1858 "`bynk.toml`'s `[workers] compatibility_flags` lists a flag twice, or one every Bynk Worker already has; the duplicate is dropped (warning).",
1859 )),
1860 d(
1861 "bynk.project.duplicate_module_doc",
1862 "More than one file of a multi-file unit carries a module doc.",
1863 ),
1864 d(
1865 "bynk.project.export_context",
1866 "`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.",
1867 ),
1868 d(
1869 "bynk.project.export_unknown",
1870 "`bynk.toml`'s `[package] exports` lists a name that isn't a commons or adapter the project declares.",
1871 ),
1872 d(
1873 "bynk.project.file_and_directory",
1874 "A unit exists as both a file and a directory.",
1875 ),
1876 d(
1877 "bynk.project.inconsistent_commons_name",
1878 "A source file's path does not match its declared name.",
1879 ),
1880 d(
1881 "bynk.project.kind_conflict",
1882 "A name is declared as both a commons and a context.",
1883 ),
1884 d(
1885 "bynk.project.no_root",
1886 "No project root could be determined.",
1887 ),
1888 d(
1889 "bynk.project.no_sources",
1890 "The project contains no source files.",
1891 ),
1892 d(
1893 "bynk.project.read_failed",
1894 "A source file could not be read.",
1895 ),
1896 d(
1897 "bynk.project.schema_registry_corrupt",
1898 "`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.",
1899 ),
1900 warn(d(
1901 "bynk.project.unstable_not_experimental",
1902 "`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).",
1903 )),
1904 d(
1905 "bynk.project.unstable_unknown_item",
1906 "`bynk.toml`'s `[unstable] allow` lists a path that names no standard-library unit, exported item or operation.",
1907 ),
1908 dg(
1909 "bynk.property.restates_refinement",
1910 "A `property` merely re-checks a refinement its type already guarantees.",
1911 &["for_all"],
1912 ),
1913 dg(
1914 "bynk.property.where_not_bool",
1915 "A `for all ... where` filter does not type to `Bool`.",
1916 &["for_all"],
1917 ),
1918 dg(
1919 "bynk.provider.agent_call_undeclared_capability",
1920 "A provider calls an agent handler that needs a capability the provider's `given` does not list.",
1921 &["provider_decl"],
1922 ),
1923 dg(
1924 "bynk.provider.dependency_cycle",
1925 "Providers form a capability dependency cycle through `given`.",
1926 &["provider_decl"],
1927 ),
1928 dg(
1929 "bynk.provider.extra_operation",
1930 "A `provides` block implements an operation not in the capability.",
1931 &["provider_decl"],
1932 ),
1933 dg(
1934 "bynk.provider.generic_op_requires_external",
1935 "A Bynk-bodied `provides` implements a capability operation that declares its own type parameter — only an external (bodiless) provider can.",
1936 &["provider_decl"],
1937 ),
1938 dg(
1939 "bynk.provider.missing_operation",
1940 "A `provides` block is missing a capability operation.",
1941 &["provider_decl"],
1942 ),
1943 dg(
1944 "bynk.provider.outside_context",
1945 "`provides` was declared outside a context.",
1946 &["provider_decl"],
1947 ),
1948 dg(
1949 "bynk.provider.signature_mismatch",
1950 "A `provides` operation's signature does not match the capability.",
1951 &["provider_decl"],
1952 ),
1953 dg(
1954 "bynk.provider.unknown_capability",
1955 "`provides` names a capability that does not exist.",
1956 &["provider_decl"],
1957 ),
1958 d(
1959 "bynk.query.join_key_mismatch",
1960 "A `joinOn`/`leftJoin` left and right key function return different types.",
1961 ),
1962 dg(
1963 "bynk.query.sum_needs_numeric",
1964 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
1965 &[],
1966 ),
1967 dg(
1968 "bynk.queue.bad_params",
1969 "An `on message` handler does not take exactly one `message` parameter.",
1970 &["queue_handler"],
1971 ),
1972 dg(
1973 "bynk.queue.duplicate_consumer",
1974 "Two `on message` handlers consume the same queue.",
1975 &["queue_handler"],
1976 ),
1977 dg(
1978 "bynk.queue.invalid_name",
1979 "A `from queue(\"…\")` binding has an empty queue name.",
1980 &["queue_handler"],
1981 ),
1982 dg(
1983 "bynk.queue.return_not_queue_result",
1984 "An `on message` handler does not return `Effect[QueueResult]`.",
1985 &["handler"],
1986 ),
1987 dg(
1988 "bynk.record_spread.field_type_mismatch",
1989 "A record-spread override has the wrong type for the field.",
1990 &["record_spread"],
1991 ),
1992 dg(
1993 "bynk.record_spread.non_record_base",
1994 "The base of a record spread is not a record.",
1995 &["record_spread"],
1996 ),
1997 dg(
1998 "bynk.record_spread.type_mismatch",
1999 "A record spread's base is a different record type.",
2000 &["record_spread"],
2001 ),
2002 dg(
2003 "bynk.record_spread.unknown_field",
2004 "A record spread overrides a field the record does not have.",
2005 &["record_spread"],
2006 ),
2007 dg(
2008 "bynk.refine.literal_violates",
2009 "A literal does not satisfy the refined type's predicate.",
2010 &["refined_type"],
2011 ),
2012 d(
2013 "bynk.registry.account_refused",
2014 "`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).",
2015 ),
2016 d(
2017 "bynk.registry.bad_archive",
2018 "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.",
2019 ),
2020 d(
2021 "bynk.registry.bad_signature",
2022 "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).",
2023 ),
2024 d(
2025 "bynk.registry.http_failed",
2026 "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.",
2027 ),
2028 d(
2029 "bynk.registry.key_mismatch",
2030 "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`.",
2031 ),
2032 d(
2033 "bynk.registry.nonconformant",
2034 "`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.",
2035 ),
2036 d(
2037 "bynk.registry.publish_refused",
2038 "`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).",
2039 ),
2040 d(
2041 "bynk.registry.source_mismatch",
2042 "`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.",
2043 ),
2044 d(
2045 "bynk.registry.unavailable",
2046 "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.",
2047 ),
2048 d(
2049 "bynk.registry.withdrawn",
2050 "`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.",
2051 ),
2052 dg(
2053 "bynk.requires.conflicting_range",
2054 "Two adapter `binding … requires { … }` entries give different version ranges for one npm package.",
2055 &["binding_decl"],
2056 ),
2057 dg(
2058 "bynk.requires.unapproved",
2059 "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>`.",
2060 &["binding_decl"],
2061 ),
2062 dg(
2063 "bynk.requires.unpinned_dependency",
2064 "An adapter `binding … requires { … }` entry has an unpinned version range.",
2065 &["binding_decl"],
2066 ),
2067 d(
2068 "bynk.resolve.ambiguous_variant",
2069 "A variant name is ambiguous across several sum types.",
2070 ),
2071 dg(
2072 "bynk.resolve.arity_mismatch",
2073 "A function was called with the wrong number of arguments.",
2074 &["call"],
2075 ),
2076 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
2077 dg(
2078 "bynk.resolve.duplicate_agent",
2079 "Two agents share a name.",
2080 &["agent_decl"],
2081 ),
2082 dg(
2083 "bynk.resolve.duplicate_capability",
2084 "Two capabilities share a name.",
2085 &["capability_decl"],
2086 ),
2087 dg(
2088 "bynk.resolve.duplicate_field",
2089 "A record declares a field twice.",
2090 &["record_type"],
2091 ),
2092 dg(
2093 "bynk.resolve.duplicate_field_init",
2094 "A record construction initialises a field twice.",
2095 &["record_construction"],
2096 ),
2097 dg(
2098 "bynk.resolve.duplicate_fn",
2099 "Two functions share a name.",
2100 &["fn_decl"],
2101 ),
2102 d(
2103 "bynk.resolve.duplicate_message_code",
2104 "A message bundle declares the same code twice in one block.",
2105 ),
2106 d(
2107 "bynk.resolve.duplicate_message_locale",
2108 "Two `messages` blocks in one bundle declare the same locale tag.",
2109 ),
2110 dg(
2111 "bynk.resolve.duplicate_method",
2112 "Two methods share a name.",
2113 &["fn_decl"],
2114 ),
2115 dg(
2116 "bynk.resolve.duplicate_param",
2117 "A parameter name is repeated.",
2118 &["param"],
2119 ),
2120 dg(
2121 "bynk.resolve.duplicate_provider",
2122 "A capability is provided more than once.",
2123 &["provider_decl"],
2124 ),
2125 dg(
2126 "bynk.resolve.duplicate_service",
2127 "Two services share a name.",
2128 &["service_decl"],
2129 ),
2130 dg(
2131 "bynk.resolve.duplicate_type",
2132 "Two types share a name.",
2133 &["type_decl"],
2134 ),
2135 dg(
2136 "bynk.resolve.duplicate_variant",
2137 "A sum type declares a variant twice.",
2138 &["sum_type"],
2139 ),
2140 d(
2141 "bynk.resolve.fn_without_call",
2142 "A function was referenced without being called.",
2143 ),
2144 dg(
2145 "bynk.resolve.let_shadows_fn",
2146 "A `let` binding shadows a function.",
2147 &["let_stmt"],
2148 ),
2149 dg(
2150 "bynk.resolve.let_shadows_type",
2151 "A `let` binding shadows a type.",
2152 &["let_stmt"],
2153 ),
2154 d(
2155 "bynk.resolve.method_unknown_type",
2156 "A method is defined on an unknown type.",
2157 ),
2158 dg(
2159 "bynk.resolve.missing_field",
2160 "A record construction omits a required field.",
2161 &["record_construction"],
2162 ),
2163 d(
2164 "bynk.resolve.name_conflict",
2165 "Two declarations share a name.",
2166 ),
2167 dg(
2168 "bynk.resolve.not_a_record_type",
2169 "Record syntax was used on a non-record type.",
2170 &["record_construction"],
2171 ),
2172 dg(
2173 "bynk.resolve.opaque_record_construction",
2174 "An opaque type was constructed with record syntax.",
2175 &["record_construction"],
2176 ),
2177 dg(
2178 "bynk.resolve.param_as_function",
2179 "A value (such as a parameter) was called as a function.",
2180 &["call"],
2181 ),
2182 dg(
2183 "bynk.resolve.recursive_record_field",
2184 "A record directly contains a field of its own type.",
2185 &["record_type"],
2186 ),
2187 dg(
2188 "bynk.resolve.reserved_builtin_type",
2189 "A type declaration reuses a compiler-known built-in type name.",
2190 &["type_decl"],
2191 ),
2192 dg(
2193 "bynk.resolve.reserved_host_name",
2194 "A declaration is named `globalThis`, which the generated TypeScript uses to reach host globals.",
2195 &["type_decl", "fn_decl", "agent_decl", "provider_decl"],
2196 ),
2197 dg(
2198 "bynk.resolve.reserved_payload_field",
2199 "A sum variant declares a payload field named `kind`, the variant's wire discriminant.",
2200 &["sum_type"],
2201 ),
2202 dg(
2203 "bynk.resolve.self_outside_method",
2204 "`self` referenced outside a method or handler.",
2205 &["self_expr"],
2206 ),
2207 dg(
2208 "bynk.resolve.type_as_function",
2209 "A type name was called as if it were a function.",
2210 &["call"],
2211 ),
2212 d(
2213 "bynk.resolve.type_in_expr",
2214 "A type name was used where a value is expected.",
2215 ),
2216 dg(
2217 "bynk.resolve.unconsumed_context",
2218 "A context's service was called without a `consumes` declaration.",
2219 &["consumes_decl"],
2220 ),
2221 dg(
2222 "bynk.resolve.unknown_field",
2223 "Accessed a field the record does not have.",
2224 &["field_access"],
2225 ),
2226 dg(
2227 "bynk.resolve.unknown_function",
2228 "Called a function that does not exist.",
2229 &["call"],
2230 ),
2231 d(
2232 "bynk.resolve.unknown_name",
2233 "Referenced a name that is not in scope.",
2234 ),
2235 dg(
2236 "bynk.resolve.unknown_static_member",
2237 "Referenced an unknown static member (e.g. `T.x`).",
2238 &["field_access"],
2239 ),
2240 d(
2241 "bynk.resolve.unknown_type",
2242 "Referenced a type that does not exist.",
2243 ),
2244 warn(d(
2245 "bynk.secrets.computed_name",
2246 "A `bynk.Secrets` read names its secret with a computed expression rather than a literal, so `bynk deploy` cannot plan it (warning).",
2247 )),
2248 dg(
2249 "bynk.send.in_agent_handler",
2250 "A `~>` send was used in an agent handler, which has no execution context to keep a fire-and-forget send alive.",
2251 &["effect_send_stmt"],
2252 ),
2253 dg(
2254 "bynk.send.in_pure_context",
2255 "A `~>` send was used in a pure (non-effectful) context.",
2256 &["effect_send_stmt"],
2257 ),
2258 dg(
2259 "bynk.send.non_effect",
2260 "A `~>` send was applied to a non-`Effect` value.",
2261 &["effect_send_stmt"],
2262 ),
2263 dg(
2264 "bynk.send.requires_unit",
2265 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
2266 &["effect_send_stmt"],
2267 ),
2268 dg(
2269 "bynk.send.store_op",
2270 "A `~>` send targets an agent store operation, which is part of the handler's atomic commit and cannot be sent without waiting.",
2271 &["effect_send_stmt"],
2272 ),
2273 dg(
2274 "bynk.service.missing_from",
2275 "A `from`-less service has a handler other than `on call`.",
2276 &["service_decl"],
2277 ),
2278 dg(
2279 "bynk.service.mixed_protocols",
2280 "A service mixes handler forms that do not match its `from <protocol>`.",
2281 &["service_decl"],
2282 ),
2283 dg(
2284 "bynk.service.outside_context",
2285 "A `service` was declared outside a context.",
2286 &["service_decl"],
2287 ),
2288 dg(
2289 "bynk.service.return_not_effect",
2290 "A service handler's return type is not an `Effect`.",
2291 &["service_decl"],
2292 ),
2293 dg(
2294 "bynk.service.unknown_protocol",
2295 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
2296 &["service_decl"],
2297 ),
2298 d(
2299 "bynk.service.unknown_via_clause",
2300 "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.",
2301 ),
2302 d(
2303 "bynk.service.websocket_header",
2304 "The `from websocket` header is malformed — it binds frame types as `websocket(in: <type>, out: <type>)` (real-time track slice 3).",
2305 ),
2306 d(
2307 "bynk.service.websocket_multiple",
2308 "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).",
2309 ),
2310 d(
2311 "bynk.service.websocket_open_arity",
2312 "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).",
2313 ),
2314 d(
2315 "bynk.service.websocket_param_not_stringy",
2316 "A `from websocket` service's `on open` parameter has a type not constructible from `String`; it arrives as a query-string value (#1657).",
2317 ),
2318 d(
2319 "bynk.stability.experimental",
2320 "An experimental standard-library item is used without an `[unstable] allow` entry in `bynk.toml` covering it.",
2321 ),
2322 d(
2323 "bynk.store.annotation_kind_mismatch",
2324 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
2325 ),
2326 d(
2327 "bynk.store.annotation_unsupported",
2328 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
2329 ),
2330 d(
2331 "bynk.store.cache_needs_clock",
2332 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
2333 ),
2334 d(
2335 "bynk.store.cache_ttl_required",
2336 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
2337 ),
2338 d(
2339 "bynk.store.kind_arity",
2340 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
2341 ),
2342 d(
2343 "bynk.store.kind_unsupported",
2344 "A known storage kind (`Queue`) is used before the slice that supports it.",
2345 ),
2346 d(
2347 "bynk.store.log_needs_clock",
2348 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
2349 ),
2350 d(
2351 "bynk.store.unkeyable_key",
2352 "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).",
2353 ),
2354 d(
2355 "bynk.store.unknown_annotation",
2356 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
2357 ),
2358 d(
2359 "bynk.store.unknown_kind",
2360 "A `store` field's type is not a known storage kind.",
2361 ),
2362 d(
2363 "bynk.store.unknown_map_accessor",
2364 "A `store Map` field access is not one of its query accessors (`entries`/`keys`/`values`).",
2365 ),
2366 d(
2367 "bynk.store.unknown_op",
2368 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
2369 ),
2370 dg(
2371 "bynk.stub.at_system",
2372 "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.",
2373 &["stub_clause"],
2374 ),
2375 d(
2376 "bynk.stub.bad_sequence",
2377 "A `stub … returns each […]` sequence is malformed (e.g. empty).",
2378 ),
2379 d(
2380 "bynk.stub.generic_op",
2381 "A test `stub` targets a capability operation that declares its own type parameter — not supported at v1.",
2382 ),
2383 d(
2384 "bynk.stub.not_a_seam",
2385 "A test `stub` overrides a capability the unit under test does not consume.",
2386 ),
2387 d(
2388 "bynk.stub.rhs_type",
2389 "A test `stub … returns <value>` right-hand side does not match the operation's return type.",
2390 ),
2391 d(
2392 "bynk.stub.unknown_op",
2393 "A test `stub` names an operation the capability does not declare.",
2394 ),
2395 dg(
2396 "bynk.suite.duplicate_case_name",
2397 "Two `case`s share a description.",
2398 &["case"],
2399 ),
2400 dg(
2401 "bynk.suite.duplicate_env",
2402 "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.",
2403 &["env_clause"],
2404 ),
2405 dg(
2406 "bynk.suite.env_binding_clash",
2407 "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`.",
2408 &["env_clause"],
2409 ),
2410 dg(
2411 "bynk.suite.env_not_literal",
2412 "An `env { … }` entry's value is not a `String` literal; a Worker's variables and secrets are strings, given verbatim.",
2413 &["env_clause"],
2414 ),
2415 dg(
2416 "bynk.suite.unknown_target",
2417 "A `suite` targets a unit that does not exist.",
2418 &["suite_decl"],
2419 ),
2420 d(
2421 "bynk.target.browser_bundle_only",
2422 "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
2423 ),
2424 dg(
2425 "bynk.target.vendor_conflict",
2426 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
2427 &["consumes_decl"],
2428 ),
2429 dg(
2430 "bynk.target.vendor_required",
2431 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
2432 &["consumes_decl"],
2433 ),
2434 dg(
2435 "bynk.test.actor_identity_required",
2436 "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`.",
2437 &["case"],
2438 ),
2439 dg(
2440 "bynk.test.actor_no_identity",
2441 "A call-site `by <Actor>(x)` supplies an identity to an actor that takes none — a unit-identity actor (e.g. `Visitor`) or `Nobody`.",
2442 &["case"],
2443 ),
2444 dg(
2445 "bynk.test.advance_not_clock",
2446 "An `advance` statement names a capability other than `Clock`; the test harness owns one time source, the first-party `Clock`.",
2447 &["advance_stmt"],
2448 ),
2449 dg(
2450 "bynk.test.advance_not_duration",
2451 "An `advance Clock by` statement's amount is not a `Duration`.",
2452 &["advance_stmt"],
2453 ),
2454 dg(
2455 "bynk.test.advance_outside_case",
2456 "An `advance Clock by` statement appears outside a test `case` body; only the test harness has a clock to move.",
2457 &["advance_stmt"],
2458 ),
2459 dg(
2460 "bynk.test.asset_address_method",
2461 "A suite fetches an asset with a method other than `GET`; the platform serves assets to `GET` and answers other methods with 405.",
2462 &["case"],
2463 ),
2464 dg(
2465 "bynk.test.credential_needs_system",
2466 "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.",
2467 &["case"],
2468 ),
2469 dg(
2470 "bynk.test.event_needs_in_process",
2471 "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`.",
2472 &["case"],
2473 ),
2474 dg(
2475 "bynk.test.event_not_subscribed",
2476 "A test body's `svc.event(e)` delivers an event the `from Events(E)` service does not subscribe to.",
2477 &["case"],
2478 ),
2479 dg(
2480 "bynk.test.event_publisher_ambiguous",
2481 "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.",
2482 &["case"],
2483 ),
2484 dg(
2485 "bynk.test.faults_needs_in_process",
2486 "A `system`-tier case claims a fault with `expect <call> faults`, or a fault claim at any tier is driven `by Nobody`, `by Forged` or `by Stale`; 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`.",
2487 &["case"],
2488 ),
2489 dg(
2490 "bynk.test.forged_needs_signature_route",
2491 "A case drives `by Forged` or `by Stale` at an address that is not an http route with a `Signature` actor (alone, or as a member of an actor sum); they send a bad signature, so only a `Signature` seam can refuse them.",
2492 &["case"],
2493 ),
2494 dg(
2495 "bynk.test.forged_needs_system",
2496 "A case drives `by Forged` or `by Stale` outside a `system`-tier case; only the `system` driver signs a request, so only there does the real `Signature` seam see the bad signature.",
2497 &["case"],
2498 ),
2499 dg(
2500 "bynk.test.nobody_needs_secured_route",
2501 "A case drives `by Nobody` at a route with no Bearer or Signature actor (alone, or as a member of an actor sum) (e.g. a public `Visitor` route) — there is no auth seam to reject the missing credential.",
2502 &["case"],
2503 ),
2504 dg(
2505 "bynk.test.oidc_needs_in_process",
2506 "A `system`-tier case calls an http route whose actor is `Oidc`-secured; the `system` driver has no token issuer yet, so the request without a token could only be refused with a `401`, and the call belongs at `unit` or `integration`.",
2507 &["case"],
2508 ),
2509 d(
2510 "bynk.test.principal_claims_not_oidc",
2511 "A call-site principal passes token claims for an actor that isn't `Oidc`.",
2512 ),
2513 dg(
2514 "bynk.test.principal_identity_mismatch",
2515 "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.",
2516 &["case"],
2517 ),
2518 dg(
2519 "bynk.test.principal_on_asset",
2520 "A suite's asset fetch carries a `by` clause; an asset is public and served before the Worker runs.",
2521 &["case"],
2522 ),
2523 dg(
2524 "bynk.test.principal_on_wrong_method",
2525 "A wrong-method `405` test carries a `by <Actor>` clause; it reaches no handler, so a principal is meaningless.",
2526 &["case"],
2527 ),
2528 dg(
2529 "bynk.test.principal_required",
2530 "A test drives an identity-carrying handler, or one guarded by an actor sum, with no call-site `by <Actor>`.",
2531 &["case"],
2532 ),
2533 warn(dg(
2534 "bynk.test.remote_clock_dependent",
2535 "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.",
2536 &["case"],
2537 )),
2538 dg(
2539 "bynk.test.remote_unsupported_advance",
2540 "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.",
2541 &["case"],
2542 ),
2543 dg(
2544 "bynk.test.remote_unsupported_asset",
2545 "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.",
2546 &["case"],
2547 ),
2548 dg(
2549 "bynk.test.remote_unsupported_call",
2550 "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.",
2551 &["case"],
2552 ),
2553 dg(
2554 "bynk.test.remote_unsupported_env",
2555 "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.",
2556 &["case"],
2557 ),
2558 dg(
2559 "bynk.test.remote_unsupported_queue",
2560 "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.",
2561 &["case"],
2562 ),
2563 dg(
2564 "bynk.test.remote_unsupported_schedule",
2565 "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.",
2566 &["case"],
2567 ),
2568 dg(
2569 "bynk.test.service_bad_address",
2570 "A test body addresses a service the wrong way for its protocol (e.g. an http route without a leading path string).",
2571 &["case"],
2572 ),
2573 dg(
2574 "bynk.test.service_call_arity",
2575 "A test body's `svc.call(...)` passes the wrong number of arguments for the service's `on call` handler.",
2576 &["case"],
2577 ),
2578 dg(
2579 "bynk.test.service_no_call_handler",
2580 "A test body invokes `svc.call(...)` on a service with no `on call` handler (a `from http`/`cron`/`queue` service).",
2581 &["case"],
2582 ),
2583 dg(
2584 "bynk.test.service_unknown_route",
2585 "A test body addresses an http route / cron schedule / queue message the service does not declare.",
2586 &["case"],
2587 ),
2588 dg(
2589 "bynk.test.stale_needs_timestamp",
2590 "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.",
2591 &["case"],
2592 ),
2593 dg(
2594 "bynk.test.unknown_actor",
2595 "A call-site `by <Actor>` names an actor the target context does not declare and that is not a prelude actor.",
2596 &["case"],
2597 ),
2598 dg(
2599 "bynk.test.wire_needs_system",
2600 "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.",
2601 &["case"],
2602 ),
2603 dg(
2604 "bynk.tier.cross_context_needs_system",
2605 "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`.",
2606 &["case"],
2607 ),
2608 dg(
2609 "bynk.tier.mixed_system_suite",
2610 "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.",
2611 &["case"],
2612 ),
2613 d(
2614 "bynk.tier.system_needs_wire",
2615 "An `as system` test stands up fewer than two contexts; the system tier wires across contexts.",
2616 ),
2617 d(
2618 "bynk.transition.cross_agent_reference",
2619 "A transition predicate references another agent; step invariants are per-agent.",
2620 ),
2621 d(
2622 "bynk.transition.duplicate_name",
2623 "An agent declares two transitions with the same name.",
2624 ),
2625 d(
2626 "bynk.transition.impure_predicate",
2627 "A transition predicate uses an effectful or test-only construct; a step invariant must be pure.",
2628 ),
2629 warn(d(
2630 "bynk.transition.may_violate",
2631 "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.",
2632 )),
2633 d(
2634 "bynk.transition.no_step_reference",
2635 "A transition references neither `old` nor `new`; it constrains one state, so it is an `invariant`, not a step.",
2636 ),
2637 d(
2638 "bynk.transition.not_bool",
2639 "A transition predicate does not have type `Bool`.",
2640 ),
2641 dg(
2642 "bynk.types.argument_mismatch",
2643 "A call, method, capability, or constructor argument has the wrong type.",
2644 &["call"],
2645 ),
2646 d(
2647 "bynk.types.asset_at_boundary",
2648 "An `Asset` type appears in a record field, boundary or store position; pass its `.url` instead.",
2649 ),
2650 dg(
2651 "bynk.types.call_arity",
2652 "A function value was applied with the wrong number of arguments.",
2653 &["call"],
2654 ),
2655 dg(
2656 "bynk.types.cannot_infer_option_type_param",
2657 "The value type of `None` could not be inferred.",
2658 &["none_expr"],
2659 ),
2660 d(
2661 "bynk.types.cannot_infer_result_type_params",
2662 "The type parameters of a `Result` could not be inferred.",
2663 ),
2664 dg(
2665 "bynk.types.catastrophic_regex",
2666 "A `Matches` 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).",
2667 &["refinement"],
2668 ),
2669 d(
2670 "bynk.types.claims_at_boundary",
2671 "`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.",
2672 ),
2673 dg(
2674 "bynk.types.combinator_return_mismatch",
2675 "A callback passed to a combinator (`map`/`andThen`/`flatMap`/`traverseAll`/…) returns the wrong type.",
2676 &["call"],
2677 ),
2678 d(
2679 "bynk.types.constructor_arity",
2680 "A variant constructor got the wrong number of arguments.",
2681 ),
2682 d(
2683 "bynk.types.constructor_base_mismatch",
2684 "A `.of` constructor was given an argument of the wrong base type.",
2685 ),
2686 dg(
2687 "bynk.types.duplicate_literal_arm",
2688 "A `match` has two arms for the same literal value.",
2689 &["match_arm"],
2690 ),
2691 dg(
2692 "bynk.types.duplicate_variant_arm",
2693 "A `match` has two arms for the same variant.",
2694 &["match_arm"],
2695 ),
2696 d(
2697 "bynk.types.embeds_ambiguous",
2698 "A type is embedded by more than one variant of a sum, so `?`'s conversion would be ambiguous.",
2699 ),
2700 d(
2701 "bynk.types.embeds_unknown_variant",
2702 "An `embeds … as V` clause names a variant the sum does not declare.",
2703 ),
2704 d(
2705 "bynk.types.embeds_variant_shape",
2706 "An `embeds E as V` target variant must have exactly one payload field, of type `E`.",
2707 ),
2708 dg(
2709 "bynk.types.empty_refinement",
2710 "A refinement admits no values (contradictory predicates).",
2711 &["refinement"],
2712 ),
2713 dg(
2714 "bynk.types.err_value_mismatch",
2715 "An `Err` payload has the wrong type.",
2716 &["err_expr"],
2717 ),
2718 d(
2719 "bynk.types.extensible_match_needs_wildcard",
2720 "A `match` covers an extensible standard-library enum (`FetchError`, `Method`) without a wildcard; it may gain variants in a minor release.",
2721 ),
2722 dg(
2723 "bynk.types.field_access_on_non_record",
2724 "Field access on a value that is not a record.",
2725 &["field_access"],
2726 ),
2727 dg(
2728 "bynk.types.field_refinement_not_base",
2729 "An inline field refinement requires a base or refined type.",
2730 &["record_field"],
2731 ),
2732 dg(
2733 "bynk.types.field_value_mismatch",
2734 "A record field was given a value of the wrong type.",
2735 &["record_construction"],
2736 ),
2737 dg(
2738 "bynk.types.function_at_boundary",
2739 "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.",
2740 &["function_type_ref"],
2741 ),
2742 dg(
2743 "bynk.types.guard_not_bool",
2744 "A match-arm `if` guard is not a `Bool` expression.",
2745 &["match_arm"],
2746 ),
2747 d(
2748 "bynk.types.headers_at_boundary",
2749 "`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.",
2750 ),
2751 d(
2752 "bynk.types.held_at_boundary",
2753 "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).",
2754 ),
2755 d(
2756 "bynk.types.held_not_comparable",
2757 "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
2758 ),
2759 dg(
2760 "bynk.types.if_branch_mismatch",
2761 "The branches of an `if` have different types.",
2762 &["if_expr"],
2763 ),
2764 dg(
2765 "bynk.types.if_non_bool_cond",
2766 "An `if` condition is not a `Bool`.",
2767 &["if_expr"],
2768 ),
2769 dg(
2770 "bynk.types.if_without_else_requires_unit",
2771 "An `if` with no `else` branch has a non-unit then-branch; the missing else defaults to `()`, so the branch must be `()` or `Effect[()]`.",
2772 &["if_expr"],
2773 ),
2774 d(
2775 "bynk.types.interpolation_non_scalar",
2776 "An interpolation hole holds a value with no string form.",
2777 ),
2778 dg(
2779 "bynk.types.invalid_regex",
2780 "A `Matches` predicate contains an invalid regular expression.",
2781 &["refinement"],
2782 ),
2783 dg(
2784 "bynk.types.inverted_range",
2785 "An `InRange` predicate has its bounds inverted.",
2786 &["refinement"],
2787 ),
2788 dg(
2789 "bynk.types.is_base_mismatch",
2790 "An `is` refinement check is applied to a value of the wrong base type.",
2791 &["is_expr"],
2792 ),
2793 dg(
2794 "bynk.types.is_literal_pattern",
2795 "A literal was used on the right of `is`; `is` tests type/refinement, not value equality (use `==`).",
2796 &["is_expr"],
2797 ),
2798 dg(
2799 "bynk.types.is_non_sum",
2800 "`is` was applied to a value that is not a sum type.",
2801 &["is_expr"],
2802 ),
2803 dg(
2804 "bynk.types.is_refined_pattern",
2805 "A refined (`where`) pattern was used on the right of `is`; refined patterns are `match`-only.",
2806 &["is_expr"],
2807 ),
2808 dg(
2809 "bynk.types.is_unknown_variant",
2810 "`is` names a variant the type does not have.",
2811 &["is_expr"],
2812 ),
2813 dg(
2814 "bynk.types.json_uncodable",
2815 "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, error builtins).",
2816 &["method_call"],
2817 ),
2818 d(
2819 "bynk.types.key_at_boundary",
2820 "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).",
2821 ),
2822 dg(
2823 "bynk.types.key_not_orderable",
2824 "A `sortBy`/`min`/`max` key function does not return an orderable type (`Int`, `Float`, `String`, `Duration`, or `Instant`).",
2825 &[],
2826 ),
2827 dg(
2828 "bynk.types.lambda_mismatch",
2829 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
2830 &["lambda_expr"],
2831 ),
2832 dg(
2833 "bynk.types.let_annotation_mismatch",
2834 "A `let` value does not match its type annotation.",
2835 &["let_stmt"],
2836 ),
2837 dg(
2838 "bynk.types.list_element_mismatch",
2839 "A list-literal element has a different type from the list's element type.",
2840 &["list_literal"],
2841 ),
2842 dg(
2843 "bynk.types.match_arm_mismatch",
2844 "A `match` arm has a different type from the others.",
2845 &["match_arm"],
2846 ),
2847 dg(
2848 "bynk.types.match_non_sum_discriminant",
2849 "`match` was applied to a value that is not a sum type.",
2850 &["match_expr"],
2851 ),
2852 dg(
2853 "bynk.types.method_arity",
2854 "A method was called with the wrong number of arguments.",
2855 &["method_call"],
2856 ),
2857 dg(
2858 "bynk.types.method_not_found",
2859 "Called a method the type does not have.",
2860 &["method_call"],
2861 ),
2862 dg(
2863 "bynk.types.method_on_non_named_type",
2864 "A method was called on a built-in type that has no methods.",
2865 &["method_call"],
2866 ),
2867 dg(
2868 "bynk.types.mixed_pattern_bindings",
2869 "A pattern mixes named and positional bindings.",
2870 &["variant_pattern"],
2871 ),
2872 dg(
2873 "bynk.types.negative_length",
2874 "A length predicate was given a negative value.",
2875 &["refinement"],
2876 ),
2877 dg(
2878 "bynk.types.no_numeric_coercion",
2879 "`Int` and `Float` were mixed without an explicit conversion — in an operation or in refinement bounds.",
2880 &["binary_expr", "refinement"],
2881 ),
2882 dg(
2883 "bynk.types.non_exhaustive_match",
2884 "A `match` does not cover every variant.",
2885 &["match_expr"],
2886 ),
2887 d(
2888 "bynk.types.not_comparable",
2889 "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).",
2890 ),
2891 dg(
2892 "bynk.types.ok_value_mismatch",
2893 "An `Ok` payload has the wrong type.",
2894 &["ok_expr"],
2895 ),
2896 dg(
2897 "bynk.types.opaque_raw_outside",
2898 "`.raw` on an opaque type was used outside its defining commons.",
2899 &["field_access"],
2900 ),
2901 dg(
2902 "bynk.types.opaque_unsafe_outside",
2903 "`.unsafe` on an opaque type was used outside its defining context.",
2904 &["field_access"],
2905 ),
2906 dg(
2907 "bynk.types.or_pattern_binding_mismatch",
2908 "An or-pattern's alternatives don't all bind the same set of names.",
2909 &["match_arm", "is_expr"],
2910 ),
2911 dg(
2912 "bynk.types.or_pattern_type_mismatch",
2913 "An or-pattern's alternatives give a shared binding different types (or refinements).",
2914 &["match_arm", "is_expr"],
2915 ),
2916 dg(
2917 "bynk.types.pattern_arity",
2918 "A pattern binds the wrong number of payload fields.",
2919 &["variant_pattern"],
2920 ),
2921 dg(
2922 "bynk.types.pattern_type_mismatch",
2923 "A pattern's type does not match the matched value.",
2924 &["variant_pattern"],
2925 ),
2926 dg(
2927 "bynk.types.polynomial_regex",
2928 "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.",
2929 &["refinement"],
2930 ),
2931 warn(dg(
2932 "bynk.types.polynomial_regex_capped",
2933 "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).",
2934 &["refinement"],
2935 )),
2936 dg(
2937 "bynk.types.predicate_base_mismatch",
2938 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
2939 &["refinement"],
2940 ),
2941 d(
2942 "bynk.types.query_at_boundary",
2943 "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).",
2944 ),
2945 dg(
2946 "bynk.types.question_error_mismatch",
2947 "`?` propagates an error type incompatible with the function's.",
2948 &["question_expr"],
2949 ),
2950 dg(
2951 "bynk.types.question_on_non_result",
2952 "`?` was applied to a non-`Result` value.",
2953 &["question_expr"],
2954 ),
2955 dg(
2956 "bynk.types.question_option_outside_http",
2957 "`?` lifts an `Option` only inside a handler returning `HttpResult` (`None` becomes `NotFound`); elsewhere use `.okOr(err)`.",
2958 &["question_expr"],
2959 ),
2960 dg(
2961 "bynk.types.question_outside_result",
2962 "`?` used in a function that does not return a `Result`.",
2963 &["question_expr"],
2964 ),
2965 d(
2966 "bynk.types.rejection_at_boundary",
2967 "`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.",
2968 ),
2969 d(
2970 "bynk.types.return_mismatch",
2971 "A returned value does not match the declared return type.",
2972 ),
2973 dg(
2974 "bynk.types.some_value_mismatch",
2975 "A `Some` payload has the wrong type.",
2976 &["some_expr"],
2977 ),
2978 d(
2979 "bynk.types.stream_at_boundary",
2980 "A `Stream` type appears in a storable or boundary-crossing position — a stream is a live value-over-time source, never persisted or sent across a boundary (real-time track slice 0).",
2981 ),
2982 d(
2983 "bynk.types.stream_not_comparable",
2984 "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
2985 ),
2986 d(
2987 "bynk.types.type_mismatch",
2988 "Two types that were required to match did not.",
2989 ),
2990 dg(
2991 "bynk.types.uninferable_element_type",
2992 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
2993 &["list_literal"],
2994 ),
2995 dg(
2996 "bynk.types.unkeyable_distinct",
2997 "A `distinct`/`distinctBy` element or key is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
2998 &[],
2999 ),
3000 dg(
3001 "bynk.types.unkeyable_map_key",
3002 "A `Map` key type is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
3003 &["generic_type_ref"],
3004 ),
3005 dg(
3006 "bynk.types.unknown_field",
3007 "Referenced a field the record type does not declare.",
3008 &["field_access"],
3009 ),
3010 dg(
3011 "bynk.types.unknown_pattern_field",
3012 "A pattern names a field the variant does not have.",
3013 &["variant_pattern"],
3014 ),
3015 dg(
3016 "bynk.types.unknown_static_member",
3017 "Referenced an unknown static member on a type.",
3018 &["field_access"],
3019 ),
3020 dg(
3021 "bynk.types.unknown_variant_in_pattern",
3022 "A pattern names a variant the sum type does not have.",
3023 &["variant_pattern"],
3024 ),
3025 dg(
3026 "bynk.types.unreachable_arm",
3027 "A `match` arm is unreachable.",
3028 &["match_arm"],
3029 ),
3030 d(
3031 "bynk.types.variant_arity",
3032 "A variant constructor got the wrong number of payload values.",
3033 ),
3034 d(
3035 "bynk.types.variant_missing_payload",
3036 "A variant requiring a payload was used without one.",
3037 ),
3038 d(
3039 "bynk.types.variant_payload_mismatch",
3040 "A variant payload has the wrong type.",
3041 ),
3042 dg(
3043 "bynk.uses.name_conflict",
3044 "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.",
3045 &["uses_decl"],
3046 ),
3047 dg(
3048 "bynk.uses.self_reference",
3049 "A commons `uses` itself.",
3050 &["uses_decl"],
3051 ),
3052 dg(
3053 "bynk.uses.target_is_context",
3054 "`uses` targets a context instead of a commons.",
3055 &["uses_decl"],
3056 ),
3057 dg(
3058 "bynk.uses.unknown_commons",
3059 "`uses` names a commons that does not exist.",
3060 &["uses_decl"],
3061 ),
3062 dg(
3063 "bynk.val.agent_not_generable",
3064 "A `for all`/`Val` cannot generate an agent — fabricated agent states need not be reachable.",
3065 &["for_all"],
3066 ),
3067 dg(
3068 "bynk.val.arity",
3069 "`Val[T]` was given the wrong number of pin arguments.",
3070 &["val_expr"],
3071 ),
3072 dg(
3073 "bynk.val.literal_violates",
3074 "A pinned `Val[T]` value violates the type's refinement.",
3075 &["val_expr"],
3076 ),
3077 dg(
3078 "bynk.val.needs_pin",
3079 "A bare `Val[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
3080 &["val_expr"],
3081 ),
3082 dg(
3083 "bynk.val.outside_test",
3084 "`Val[T]` was used outside a test case body.",
3085 &["val_expr"],
3086 ),
3087 dg(
3088 "bynk.val.pin_not_literal",
3089 "A `Val[T]` pin argument is not a compile-time literal.",
3090 &["val_expr"],
3091 ),
3092 dg(
3093 "bynk.val.pin_unsupported",
3094 "A pin was given for a type kind that does not support pinning.",
3095 &["val_expr"],
3096 ),
3097 dg(
3098 "bynk.val.unknown_type",
3099 "`Val[T]` names a type that does not resolve.",
3100 &["val_expr"],
3101 ),
3102 dg(
3103 "bynk.val.unsupported_kind",
3104 "`Val[T]` cannot fabricate a value for this kind of type.",
3105 &["val_expr"],
3106 ),
3107 d(
3108 "bynk.wasm.panic",
3109 "The in-browser compiler panicked internally (a compiler bug, reported as a diagnostic instead of crashing the page).",
3110 ),
3111 d(
3112 "bynk.wasm.strip_failed",
3113 "The in-browser compiler could not strip the emitted TypeScript to JavaScript.",
3114 ),
3115 d(
3116 "bynk.ws.message_frame_param",
3117 "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).",
3118 ),
3119 d(
3120 "bynk.ws.open_given_unsupported",
3121 "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).",
3122 ),
3123 d(
3124 "bynk.ws.open_transfer_cross_file",
3125 "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.",
3126 ),
3127 d(
3128 "bynk.ws.open_transfer_shape",
3129 "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).",
3130 ),
3131 d(
3132 "bynk.ws.route_param_mismatch",
3133 "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).",
3134 ),
3135];
3136
3137const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
3139 DiagnosticInfo {
3140 code,
3141 summary,
3142 grammar_symbol: &[],
3143 severity: Severity::Error,
3144 }
3145}
3146
3147const fn dg(
3149 code: &'static str,
3150 summary: &'static str,
3151 grammar_symbol: &'static [&'static str],
3152) -> DiagnosticInfo {
3153 DiagnosticInfo {
3154 code,
3155 summary,
3156 grammar_symbol,
3157 severity: Severity::Error,
3158 }
3159}
3160
3161const fn warn(mut info: DiagnosticInfo) -> DiagnosticInfo {
3165 info.severity = Severity::Warning;
3166 info
3167}
3168
3169pub fn category(code: &str) -> &str {
3172 code.split('.').nth(1).unwrap_or("")
3173}
3174
3175fn category_title(cat: &str) -> &'static str {
3177 match cat {
3178 "agent" | "agents" => "Agents",
3179 "asset" => "Static assets",
3180 "boundary" => "Boundaries",
3181 "capability" => "Capabilities",
3182 "cloudflare" => "Cloudflare",
3183 "consumes" => "Consumes",
3184 "context" => "Contexts",
3185 "contract" => "Contracts",
3186 "cron" => "Cron",
3187 "effect" => "Effects",
3188 "embed" => "Embedded text",
3189 "expect" => "Expectations",
3190 "exports" => "Exports",
3191 "given" => "Given capabilities",
3192 "http" => "HTTP",
3193 "lex" => "Lexer",
3194 "messages" => "Message bundles",
3195 "mock" => "Mocks (collaborators)",
3196 "observe" => "Observation",
3197 "parse" => "Parser",
3198 "project" => "Project",
3199 "property" => "Properties (generative tests)",
3200 "provider" => "Providers",
3201 "queue" => "Queue",
3202 "record_spread" => "Record spread",
3203 "refine" => "Refinement",
3204 "resolve" => "Resolution",
3205 "service" => "Services",
3206 "stability" => "Stability",
3207 "suite" => "Suites and cases",
3208 "transition" => "Transitions (step invariants)",
3209 "types" => "Type checking",
3210 "uses" => "Uses",
3211 "val" => "Value fabrication",
3212 _ => "Other",
3213 }
3214}
3215
3216pub fn render_markdown() -> String {
3220 use std::collections::BTreeMap;
3221
3222 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3224 for info in REGISTRY {
3225 by_category
3226 .entry(category_title(category(info.code)))
3227 .or_default()
3228 .push(info);
3229 }
3230
3231 let mut out = String::new();
3232 out.push_str("# Diagnostic index\n\n");
3233 out.push_str(
3234 "<!-- GENERATED FILE — do not edit by hand.\n \
3235 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
3236 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test it diagnostics_registry:: -->\n\n",
3237 );
3238 out.push_str(
3239 "Every diagnostic code the compiler can emit, with a one-line summary of \
3240 the cause, grouped by category. For step-by-step cause-and-fix guidance \
3241 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md). \
3242 For a code with a curated explanation, `bynk explain <code>` prints it in a \
3243 terminal, and in VS Code the diagnostic's **Explain** quick fix (or \
3244 **Bynk: Explain Diagnostic Code…**) shows the same text in a panel, offline.\n\n",
3245 );
3246 out.push_str(&format!(
3247 "There are **{}** codes in total.\n",
3248 REGISTRY.len()
3249 ));
3250
3251 for (title, infos) in &by_category {
3252 out.push_str(&format!("\n## {title}\n\n"));
3253 out.push_str("| Code | Summary | Construct | Severity |\n|---|---|---|---|\n");
3254 for info in infos {
3255 let construct = info
3260 .grammar_symbol
3261 .iter()
3262 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
3263 .collect::<Vec<_>>()
3264 .join(", ");
3265 let code_cell = match explain(info.code) {
3270 Some(e) => format!("[`{}`]({})", info.code, e.in_site_link()),
3271 None => format!("`{}`", info.code),
3272 };
3273 let severity = match info.severity {
3278 Severity::Error => "—",
3279 Severity::Warning => "Warning",
3280 };
3281 out.push_str(&format!(
3282 "| {} | {} | {} | {} |\n",
3283 code_cell, info.summary, construct, severity
3284 ));
3285 }
3286 }
3287
3288 out
3289}
3290
3291pub fn render_grammar_semantics_json() -> String {
3297 use std::collections::BTreeMap;
3298
3299 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
3302 for info in REGISTRY {
3303 for sym in info.grammar_symbol {
3304 by_symbol.entry(sym).or_default().push(info);
3305 }
3306 }
3307
3308 let mut map = serde_json::Map::new();
3309 map.insert(
3310 "_generated".to_string(),
3311 serde_json::Value::String(
3312 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
3313 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
3314 bynkc --test it diagnostics_registry::"
3315 .to_string(),
3316 ),
3317 );
3318 for (sym, infos) in by_symbol {
3319 let arr: Vec<serde_json::Value> = infos
3320 .iter()
3321 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
3322 .collect();
3323 map.insert(sym.to_string(), serde_json::Value::Array(arr));
3324 }
3325
3326 let mut s =
3327 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
3328 s.push('\n');
3329 s
3330}