Skip to content
pi-c Named keys and remembered health
Login

Named keys and remembered health

Status: adopted 2026-11-22 (option B of the keys proposal); landings 2 and 3 built: failure classes, remembered health, named keys, the swap prompt. Landing 4, free checks through a probe on the credential interface, is not built.

Tier: core records (cred.c, http.c, provider_http.c, the journal's credential column); bundled decides (keyhealth.c). Clock: vendor (error wording, rate-limit headers). Record: picu_credential_health per credential name, pic_generation.credential per request. Default: the bundled reading of refusals, registered by the composition root.

The decisions

  1. Stored beats the variable, and pic says so (landed before this note).
  2. A refusal is read into a class and remembered per key: refused (401, 403), out of credit (402, Anthropic's billing_error and "credit balance is too low" as 400 or 402, OpenAI's insufficient_quota, OpenRouter's 402), limited until a time (a 429 whose retry-after, or Anthropic's or OpenAI's reset headers, say a minute or more), transient (5xx, 529, a short 429: retried as before), other. The first three are never retried blindly.
  3. Extra keys are rows provider:label in picu_credential, sealed under their own names; the provider's existing row stays its default with no reseal. The active label is the setting activeKey:PROVIDER; --key overrides it for one process.
  4. Ask, never fail over. With --hold-key-failures (the terminal interface's children) a refusal of the first three classes fails the attempt and leaves the request unfinished; the interface asks. The choice is a setting written before the next request, and the next request asks the turn again as attempt N+1, so it fits "a generation started, no reply: failed, the turn is asked again" (durability). Each attempt still counts toward the turn's three.

The seam

Core reaches the vendor wording only through pic_cred_failure_ops (cred.h: classify and message), registered by main.c beside the sign-in flows; with nothing registered core classifies by status alone. The rows are data in keyhealth.c, so wording that drifts is a table edit. The probe for free checks (landing 4) belongs on the same interface.

Not verified

Whether rate-limit headers come on error replies of every provider; whether two keys of one Anthropic workspace share a prompt cache (the prompt always shows the uncached price).