[Feature]: opt-in hosted-gateway account controls (served-account header, trusted pin, cross-process seat)

Aperta
#8,761 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
22/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

Read the account-pool selection path first: accountLogLabel in the request log, the active-account/affinity/strategy logic, and the per-process session-affinity snapshot added in #7828. Part 1 (a config-gated x-ocx-served-account response header) is the smallest slice and the only one worth starting from, once a maintainer agrees it fits dev; parts 2 and 3 change the auth surface and the round-robin seating rule and need design sign-off. Done means the flag is off by default and tests cover the header being absent when no pooled account was admitted. Note the thread is one day old with no maintainer reply yet.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

account-pool enhancement
Area

Authentication and account pool

What are you trying to accomplish?

I run OpenCodex as a hosted gateway that sits behind a multi-tenant app. The app needs three things the local single-user proxy does not:

  1. Attribution. After a turn, the app needs to know which pooled account served it so it can charge the right tenant. That means an opaque account label, never an email or a token.
  2. Pinning. The app needs to send a request on one specific stored account, for example the tenant's own Claude subscription, and have it refused rather than failed over when that account is spent.
  3. Stable placement across processes. Many gateway processes share no state (serverless environments). Each one must put the same session on the same pooled account, or the prompt cache is rebuilt whenever a turn lands on a different process.
What prevents this today?
  • There is no response header naming the served account. accountLogLabel already exists for the request log, but it is not exposed to the caller.
  • There is no per-request account selector. Selection is process-wide: the active account, affinity, or the strategy.
  • Session affinity is per process, plus the private snapshot added in #7828. That snapshot covers a restart on one machine, but not N processes without a shared home. Under round-robin, an unbound keyed session gets a process-dependent pick.
What should OpenCodex do?

I propose three opt-in pieces. Each would be its own small PR, and each is off by default:

  1. Served-account header. Behind an explicit config flag, responses carry x-ocx-served-account: <accountLogLabel>. That is the same non-PII label the request log already stores, and the header is absent when no pooled account was admitted.
  2. Trusted-caller account pin. Behind a config flag, and only for callers authenticated with the admin or a dedicated token, x-ocx-account-provider and x-ocx-account-id select one stored account. A pinned request still records the refusal or cooldown, but it never fails over to another account. A malformed pin, or a pin from an untrusted caller, is refused with 400. It is never silently ignored.
  3. Cross-process seat (round-robin only). An unbound keyed session takes the rendezvous-hash winner of sha256(key \0 accountId) over the eligible accounts, so every process agrees without shared state. On a 429, the session that hit it moves to its hash runner-up. The process's startup selection does not seat a keyed round-robin session.
Example usage or interface
POST /v1/chat/completions
Authorization: Bearer <trusted gateway token>
x-ocx-account-provider: claude
x-ocx-account-id: <stored account id>
→ 200, x-ocx-served-account: anthropic (ab12cd3)
Alternatives or workarounds

The vadymhimself fork has shipped all three on a hosted gateway since 2026-10. There they are gated by an environment flag and use x-agentradar-* header names:

  • the per-request pin and served-account header;
  • the hash seat (0428964be2, b60e434917, 0c4ffad3e3).

Keeping them fork-only works, but every rebase costs a port.

Additional context

I'm asking whether any of the three fits dev before I write code. Part 1 is the smallest and safest, so if you're open to it, I'd start there. Part 2 changes the auth surface, so I'd expect it to need maintainer-sponsored. Header names and gating are open for discussion.

Checks
  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.
Lingua principale
TypeScript
Stelle
16.9k
Fork
1.3k
Merge medio
1g 4h
PR unite (30g)
814

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lidge-jun/opencodex

Tutte le issue di lidge-jun/opencodex

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.