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