Key pools — named, attachable per scope, forfait-first fallback
Who a run borrows credentials from when its own do not fill every slot: named pools (forfaits + gateway keys) attached at a cascade level, with a switchable strategy. ADR-164 is the decision; this page is the operator and debugging map.
The four laws — read before touching anything
- An explicit credential beats a pool entry. Pin, team key, org key, personal key: a pool fills only EMPTY slots, never displaces.
- Zero pool without an opt-in. No attachment at the level considered = today's legacy behavior, byte for byte.
Enabled: falseBLOCKS inheritance at that level; delete = inherit again. - Sovereignty intact.
llm_fallback=none+ a repo pin + an attachment present resolves as if the pool did not exist — pinned by test, bit for bit. - The strategy is per attachment and switchable: mode (priority / least_consumed), margin % (nil = 85), triggers (the llmroute subset, platform-narrowed), reset_hold, borrower draw caps.
Surfaces
- API: pool CRUD
/api/me/pools,/api/orgs/{id}/pools,/api/admin/llm/pools; entries/api/pools/{id}/entries(+/import,/{pledge}/reset); attachments/api/admin/llm/pool-attachment,/api/{orgs,teams}/{id}/pool-attachment,/api/teams/{id}/bots/{bot}/pool-attachment(CAS 409 on a staleexpected_updated_at). - Binding level: a
pool:block on a schedule (create/PATCH) or a forge integration (repo-bots enable/PATCH — parked by org approval, consent re-checked at apply), projected onto the webhook config and the scheduled rows; the launch folds it before every stored scope. - CLI:
iterion remote pools list|create|entries|entry|import|reset|attach|detach|sync— scopes: yours by default,--org,--team,--platform. - Studio: the org and team "Key pool" tab — the attachment editor and the entries' derived status.
What identifies an entry
An entry is a Pledge, identified by the credential it lends: an oauth entry by (lender, source, ref) — ref being the kind, the one connection the OAuth store keeps per kind — and an api_key entry by (lender, source, ref, key_id) (lender|api_key|ref|key_id). That id is the cred_pledges._id and the address every entry route takes (/api/pools/{id}/entries/{pledge}).
The key in the identity is what lets one lender push two keys of the same provider — two Anthropic keys, say — as two entries: the pair (source, ref) names both, while key_id and the entry id name one. The entries list shows each row's key_id so the two read apart, and an entry is reset by its own id, never by a provider the other key also answers to.
Authoring an attached pool (the onboarding recipe)
iterion remote pools create --name "dose gratuite"
iterion remote pools import --pool <id> --kind claude_code \
--file ~/.claude/.credentials.json --priority 0
iterion remote pools entry --pool <id> --source api_key \
--ref openai_compatible --key-id <pliage-key> \
--model openai_compatible/scaleway/deepseek-v4.1-flash --priority 5
iterion remote pools attach --pool <id> --org <org> --mode priorityForfaits ride first (priority 0 beats 5; equal priorities keep forfaits before metered keys), the paid gateway key is the LAST rung. sync runs one signal pass inline — the proof the readings are warm.
What switches, and when
- Proactive (claude_code subscriptions only today): the launch reads the shared usage ledger; an entry at or past the margin with a future reset is skipped PER CANDIDATE — the next entry serves, and the run's retry arms at the reset. The
pool-signal-synclease warms those readings every 5 minutes. - Reactive (keys, gateway, zai/moonshot): the provider's own refusal sets
CooldownUntilfrom itsResetAt; no margin exists, and the preview says "reactive — no provider telemetry". Reset by hand:pools reset --pool <id> --entry <pledge>. - In-run: the entries' rungs ride the run's fallback chain (
On:the attachment's triggers) — a usage-window failure walks forfait → next entry → gateway, exactly the composed order. - reset_hold: a SEAL-time switch marks its lease held, and the resume re-acquires that entry first instead of returning to one whose window reset — until
pools reseton the entry lifts the hold. In-run rung switches do not hold.
Debugging
- The pool never serves: is there an attachment at the resolved level? (
GET .../pool-attachmentper level —attached: false= inherit, its other fields empty.) An ATTACHED level withEnabled: falseanywhere between the launch and the platform floor BLOCKS. Is the poolEnabled? Private pools answer only their attachment. - A slot never draws: an explicit tier sealed it (law 1), or the routing whitelist holds the slot out — the credential preview shows the per-slot answer the launch will produce.
- A pinned review family refuses at launch: a mono pin (
mono_family) is a credential DEMAND, not a routing hint — the launch asks the pool for that family's entries even when no route names them (reviewtopology.PinnedFamilies). An attached pool holding none of it still refuses with "no credential serves that family": once a grant exists the platform tier is skipped, not consulted (ADR-131), so the pin either rides the pool or nothing serves it. - A gateway entry refuses: it needs the verbatim
modelat pledge time, and its grant carries the paired URL; a URL-less grant is refused and its lease released (the log names it). - Borrower caps: the
att:ledger row books per attachment scope — a cap refusal reads "exhausted" in the abstention, NOT the donor's exhaustion. - Sovereign teams: the attachment is inert there, warned at launch and in the preview. That is law 3 working, not a bug.
Full contract: ADR-164; the legacy donation tier: credential-pool.md.
