This document defines the normative error-class contract. The vault and magic-context mirror it by reference; subconscious preserves it on results.
Classification is PRODUCED by the error source, never INFERRED by the consumer. A consumer branches on the produced class tag and structured sibling fields only — never on status codes, message substrings, or producer-detail codes.
Classification is emitted as a structured field, preserved across every layer boundary, and consumed by branching on the class tag. Message text and status codes are not substitutes for a producer's classification.
Wire strings, snake_case, pinned by a conformance test in every producer:
| Wire string | Consumer decision |
|---|---|
transient |
Retry may succeed. With retry_after_secs present: respect it as a backoff floor (a longer producer value wins; a shorter one may clamp down). Without: consumer's own schedule/routing. |
permanent |
Retrying THIS target with THIS input is futile until out-of-band action. Advance to an alternative immediately; if all alternatives are permanent-dead, abandon and surface — never backoff-retry. |
auth_required |
A credential/authorization must be re-established by a human or admin. Pause and surface an actionable auth prompt. Provider-scoped: the consumer marks same-provider alternatives dead from its own routing knowledge. |
context_overflow |
Input exceeds THIS producer+model's bound; retrying the same input against the SAME model is futile. Whether a larger-bound alternative helps is the CONSUMER's decision (windows are heterogeneous — a 128k overflow may be precisely fixable by a 1M fallback). Producer-neutral: model context windows, bounded batch reads, any bounded-input producer. |
The canonical copy-pastable set every producer constant and golden test asserts against:
ERROR_CLASS_WIRE_SET = ["transient", "permanent", "auth_required", "context_overflow"]
(+ optional sibling retry_after_secs, seconds)
Not all quota errors are the same class, and they all arrive as HTTP 429:
- Billing/credits exhaustion (e.g. OpenAI
insufficient_quota):permanent— a human must pay; no amount of waiting fixes it. - Window quotas (e.g. Claude 5-hour windows, daily caps):
transient+retry_after_secswhen the provider supplies it — they self-recover in minutes-to-hours. - Safe default: when the producer cannot distinguish which kind a quota-429
is, map it to
transient. The costs are asymmetric: mis-classifying as transient burns a few retries; mis-classifying as permanent silently kills a healthy model and fires a false chain-dead alarm in the consumer's health channel.
The permanent arm's definition pins as "cannot recover without human or config
action", which makes the quota split derivable per provider code.
Ordering rule: code/body discrimination runs before generic status defaults. A quota-429 is indistinguishable only after provider-code discrimination.
The root broca.jsonc setting max_same_account_wait does not add a fifth error class.
It defaults to 15: non-negative integers cap same-account waits in minutes, 0 never
pauses, and "max" waits only up to cache expiry. Other values refuse boot. The obsolete
account_limit_pause key is ignored with one boot warning naming max_same_account_wait.
The setting is loaded once at boot; changes take effect at the next restart, like other
broca.jsonc settings. The existing frozen consent boolean is setting != 0; new pause
decisions use the executor's in-memory cap.
The transport's
positive account-wall classification produces kind: account_limit, scope: account beside
its existing transient error. Consenting runs persist that disposition with the failed attempt;
replay never infers it from HTTP status, Retry-After alone, message text or producer detail.
Let wake be the latest blocking reset/retry floor plus any scheduling jitter,
cache_expiry the send time of the session's last 2xx attempt on that account plus the run's
frozen cache TTL (explicit 5 minutes or 1 hour, otherwise 5 minutes), and cap = now + setting
(unbounded for "max"). A valid, non-stale floor pauses only when
wake <= min(cache_expiry, cap) and consent is enabled. A 2xx stream need not complete to
refresh the cache; a refused attempt cannot refresh it. Without an accepted attempt on that
account there is no pause. Declines end the run with the unchanged transient
account_limit_exhausted error and reset time, so Core can revive it and routing can switch
accounts. Committed pauses replay their recorded wake, never re-decide these bounds.
Untimed walls, resets beyond the cache/cap bounds,
generic 429s, payment exhaustion, authentication and context overflow keep their earlier paths.
Newly stale floors end the run and increment health.check.metrics.account_limit_stale_resets;
a committed floor that expires during downtime is instead revalidated for immediate wake.
The always-present health object account_limit_pause_declined counts disabled,
no_accepted_response, cache_expires_first and beyond_cap; declines log reset, wake,
cache expiry, cap and reason at info level.
These mappings refine the producer's classification only; they do not add wire vocabulary or change the consumer contract:
| Provider response | Class |
|---|---|
| HTTP 401 | auth_required |
| HTTP 403 (authenticated but forbidden) | permanent |
Anthropic authentication_error |
auth_required |
Anthropic permission_error |
permanent |
A producer may use a more specific structured provider code before applying a generic status
default. In particular, a credential-authentication code remains auth_required, while an
authorization/entitlement denial remains permanent. Only the former reaches vault auth-failure
reporting; a 403 must not invalidate a valid credential.
Every served run error includes class, message and provider_code, on both storage
implementations. Historical stored ProviderError records may omit the code; the
SharedProviderError boundary supplies it from the caller-facing class without rewriting
the record:
| Caller-facing class | Code when the stored error has none |
|---|---|
transient |
transient |
auth_required |
auth_required |
context_overflow |
context_overflow |
permanent or an unrecognized class |
provider_error |
An existing code, including one a reader does not recognize, stays unchanged. The provider's
finer provider_subcode and provider_details diagnostics also stay unchanged; they are not
promoted into the required code. New-storage terminal error waits use this served error
with llm-runner's ending_awaits; legacy storage still omits awaits.
retry_after_secs(seconds — the only unit) is an optional structured sibling, not arm data. Rate-limitedness is a transport phenomenon, not a consumer decision: a 429 withRetry-Afteristransient+ the field; a 429insufficient_quota(billing exhaustion) ispermanent.- Normalization is the PRODUCER's job: whatever shape the provider sends
(
Retry-Afterseconds or HTTP-date,retry-after-ms, rate-limit-reset headers, reset hints in body text), the producer folds it intoretry_after_secsso no consumer ever parses headers or text. Which shapes count is per provider family: the OpenAI Responses and ChatGPT families read only what Codex reads (whole seconds or an HTTP date inRetry-After, plus Codex'stry again intext), notretry-after-ms. Consumers treat the value as a backoff floor and may cap it — capping policy stays consumer-local. - Finer producer detail (broca
provider_subcode/status, vaultReadErrorname) travels alongside for diagnostics, logging, and corroboration ONLY. A consumer branching generically on detail is the bug this contract kills. ProviderError.messageis retained verbatim from the provider on caller and status surfaces. It may echo request content or credentials; callers must treat it as untrusted text, and this contract makes no redaction or secret-removal guarantee. Classification must never be inferred from it.
"Does a consumer branch on it GENERICALLY?"
ProviderUnavailable(broca): NO — its generic decision istransient's; the runner's respawn-and-reissue mechanics are producer business. It maps totransientat shared boundaries (ErrorClass::shared_class) and survives in detail.ContextOverflow: YES — the compaction/reduce trigger is a generic consumer decision distinct from bothpermanentandtransient. A consumer whose inputs are budget-sized below every target's bound may treat an overflow as its own estimator bug and short-circuit — that mapping is consumer-specific, not contract semantics.
The set is pinned for PRODUCERS. Consumers should decode class as an OPEN string
rather than a closed enum, so an unrecognised value becomes a PASSTHROUGH rather
than a decode failure.
This is not a softening of the contract, and it costs nothing while the set holds. It decides what happens on the day it does not: with a closed enum, adding a fifth class turns every existing consumer's decode into an error on a field they were reading fine — the producer ships a strictly more precise error and the consumer reports a parse failure, which is the least useful outcome available. With an open string, an unknown class arrives intact and can be logged, surfaced, or defaulted by the consumer's own policy.
A consumer that pins the enum makes vocabulary extension a BREAKING change for
everyone at once, which in practice means it never happens and producers smuggle
new meanings into message text instead. That is the failure this rule exists to
prevent.
Producers assert the closed set. Widening is a contract amendment; open consumer reads protect against vocabulary changes without licensing arbitrary new classes.
The contract is the WIRE STRING SET, not a Rust type. Each producer keeps its own enum; a pinned string-set serde test per producer asserts conformance. Each producer mirrors this wire contract independently.
broca specifics:
-
The canonical enum is
ErrorClassincrates/broca-protocol/src/error.rs. -
The
Autharm's wire spelling isauth_required, withauthaccepted on read indefinitely (serde alias) so records written before the rename read clean. -
ErrorClass::shared_class()is the boundary mapping for cross-producer consumers. Durable provider records keep the closed producer enum; caller error wrappers and served refusal class fields decode through open strings. -
Served management refusals with a fixed class are identified by their error code; the corresponding code-to-class pairs are:
Code Class Detail variant_unsupportedpermanent{model, variant, defined, class: "permanent"}tool_alias_invalidpermanent{tool, class: "permanent"}agent_run_scopes_unsupportedpermanent{<session scope>}projection_not_readydetail.class: transient{class}; the provider catalog that decides compaction entry attribution could not be read, sosession.entriesmay succeed on retrytransientdetail.class: transient{class, cause?}; a dependency the request needs has not answered or loaded yet (for a send: the model catalog, a credential lookup), so the same request may succeed on retry. Callers retry by this code alone.causeis present only where broca names the dependency:cause: "credentials_unavailable"means broca's vault credential listing has not loaded yet;cause: "module_stopping"means broca refused the request because it is stopping, the request did nothing and may be repeated after the restart (it says nothing about whether an earlier request with the samesend_idwas admitted) -
Principal-specific admission refusals
flow_scope_requiredandsender_not_ownercarry a top-levelclass: "permanent"besidecode,message, anddetail: {kind, principal}. Their served bytes are pinned bycrates/broca-wire/tests/golden/flow_scope_required.jsonandsender_not_owner.json; the class is mapped byErrorClass::shared_class()before serialization.Served admission refusals about account selection carry their class in their detail:
Code Class Detail account_selection_refuseddetail.class:transientorauth_required{routing_code, class, retry_after_s?, retry_after_secs?, decision_id?, resets_at_ms?, routing_detail?}account_selection_finaldetail.class: alwayspermanentsame fields as account_selection_refused; noprovider_codeaccount_limit_exhausteddetail.class:transientsame fields, plus provider_code: "account_limit_exhausted"routing_unavailabledetail.class: alwaystransient{reason, class, budget_ms?}The fetch-plan admission refusal
scoped_tools_require_planis permanent and carriesdetail: {class: "permanent"}. A new send declaring non-empty legacytoolson a stamped route or an already-scoped session needs a fetch plan (carried by the send or already frozen in the session's manifest): scoped tool providers require a per-call preset, which only the manifest supplies. Nothing is fetched or written for this refusal. Existing scope and plan refusals retain precedence, and an already-admitted keyed resend keeps its existing answer. The served bytes are pinned bycrates/broca-wire/tests/golden/scoped_tools_require_plan.json.account_selection_refusedmeans the routing module would not choose a provider account for the send; nothing was written.routing_codeis routing's own refusal code, copied verbatim with its original detail inrouting_detail,retry_after_sanddecision_id. It istransientforaccount_hold,account_pool_exhausted,account_pool_reserve_limited,account_quota_unknown,no_eligible_account,account_selection_unavailable,pin_generation_conflict,store_errorandinternal_error, withretry_after_secsset from routing's wait when it gave one;permanentforadmission_conflict,invalid_request,unknown_decision,unscoped_caller,account_not_authorizedandaccount_selection_unsupported, and for every routing code broca does not know: until broca learns a code it can't tell that waiting would clear it, and holding a send forever on a refusal that can't clear is the worse failure (routing's own contract classes every untimed refusal as permanent exceptaccount_selection_unavailable). An authorization refusal means operator policy excludes the request's credentials; logging in cannot fix it.account_selection_unsupportedmeans the account cannot serve the requested provider; it is a permanent refusal, not a static-credential fallback. A permanent refusal goes out with the outer codeaccount_selection_final: routing refused the account choice and waiting can't change it, so a caller deciding an account wait by the outer code alone never waits on it. Itsdetailis the same asaccount_selection_refused's. A queued send refused this way ends withprovider_code: "account_selection_final"and classpermanenton its run'serror. Refusal codes, known or not, stay verbatim inrouting_codeand are neverrouting_unavailable. Pool exhaustion, reserve limits, account holds and unknown quota useaccount_limit_exhaustedinstead ofaccount_selection_refused, so callers wait or reroute rather than hot-retrying. Routing'sreset_at_msis carried asresets_at_ms; when no wait was supplied it also yields aretry_after_secshint rounded up to the next second. Holds preferuntil_ms(Unix milliseconds), then legacyretry_after_s(seconds). A legacy wait's end is the time broca received the routing answer plus that wait. Either form suppliesresets_at_ms, withretry_after_sandretry_after_secsderived from that end and rounded up to the next second. Legacyreset_atis retained only in the original detail and is never parsed. A hold with neither numeric timing field stays untimed.auth_requiredretains the admit-and-pause-for-login path, with its routing code in the paused run'sauth.routing_code.account_selection_disabledis the routing operator's module-wide off-switch: that answer admits the send on the configured static credential, records an account decision with pathdisabled, and logs the literal routing codeaccount_selection_disabled. It is not an account or provider refusal. The undeclared aliasesdisabledandunsupportedare routing codes broca does not know, so they are permanentaccount_selection_finalrefusals, not fallbacks. A send that carries an account hint while routing answersaccount_selection_disabledis refused the same way. Callers branch on structured fields, never on the message. The bodies are pinned bycrates/broca-wire/tests/golden/account_selection_refused.*.jsonandcrates/broca-wire/tests/golden/account_selection_final.*.json.routing_unavailablemeans broca got no usable account decision from the routing module for a send that needs one: nothing was written and broca did not pick an account itself. It is broca's statement, not routing's, so it never appears as arouting_code.detail.reasonisunreachable(the route failed, the connection was lost, the reply could not be decoded),no_decision_within_budget(the admission budget ran out;budget_msnames it) orinvalid_pick(routing chose an account broca had not offered). Alwaystransient: the caller retries the same send. A run already admitted keeps its frozen selection on resume and is never routed again. The bodies are pinned bycrates/broca-wire/tests/golden/routing_unavailable.*.json, which the real serve path's replies are compared with.A log holding a record kind or must-understand field this build does not know was written by a newer broca; release placement refuses that downgrade through the state root's feature floor, so a served session never reaches it. Every failure to open a session, corruption included, is
open_failed.open_failedcarries optionaldetail.classin the four-class shared vocabulary. Admission and run-resolution causes useRunError::admission_error_class, never message matching. A send refused before its run starts gets the same typed refusal (its own code, detail and class) whichever storage keeps the session and whether or not it carries a fetch plan; a run task that panicked or was aborted before its start stays unclassified. An open that may succeed when repeated (the session store's key still loading, for example) answers the retryable codetransientwithdetail.cause. Unsupported handler operations are permanent. Opaque storage, write and lifecycle errors remain unclassified, including corruption; no generic storage error establishes retryability. When class is absent, no detail is added. Consumers must not invent a default class; they may keep their legacy fallback for unclassified errors. All other error bodies are unchanged.