feat: backfill typed auth clients for existing OAuth clients
Stacked on #7761.
Summary
- New
authclientbackfillpackage, the same shape asassociationbackfill: a dry run decides only, every write is conditional on the evidence it was decided from, and the report carries ids only. - For every live server โ upstream OAuth client association, it records one
mcp_auth_clientsrow per client per organization, typed bycredential_owner(subjectโremote_session,selfโservice_account), then links the server to it inmcp_server_auth_clients. - Scope follows the client: a project client gets a project auth client, and an organization or platform-global client gets an organization auth client (one per organization for a global client).
- A client shared by several servers becomes one auth client with several links. Unknown owners or a type mismatch are reported as
ambiguousand never guessed. A changed association or a concurrent insert isskipped_race; rerun to pick it up. - Every record it writes is marked
source = 'backfill', and it only ever finds, links or retires backfilled records. Admin-created clients and links are never touched. - Each run also retires backfilled links whose association is gone (soft or hard deleted) or whose server, project or client is deleted, and backfilled clients no live association reaches. Retirements count toward "complete".
- An existing backfilled client in another project is
ambiguous, neverskipped_race. Ambiguous associations are listed by id in the admin status. - The admin upstream OAuth migration runs this as a third step after associations and selections, and shows it as its own "Auth clients" line. "Migrate all pending" also runs organizations that are migrated but still have auth clients to record or retire.
Motivation
Milestone 2 of the multiple upstream credentials RFC makes every upstream identity a stable, typed auth client. This records the OAuth-backed ones (personal connections and service accounts) from existing configuration, so later work (permissions, the shared resolver, the admin UI) has stable ids to build on.
No runtime change. Nothing reads these records yet; current resolution stays authoritative.
Doesn't gate the cutover. Auth client status is reported separately in auth_clients and never feeds migrated. A failure in this step is returned as auth_clients_error and never fails the association or selection migration.
Staff Admin MCP: no tool added, for the same reason as #7659 (a one-time rollout operation already on the dashboard).
๐ค Generated with Claude Code
Summary by cubic
Implements the typed auth client backfill for AIM-588. The admin upstream OAuth migration now records a stable, typed auth client for every upstream OAuth client an MCP server is associated with, links each server to it, and marks servers offering one as needing upstream authentication where that is still undecided. Nothing reads these records yet, so runtime resolution is unchanged and this step never gates the migration cutover.
- Subject-owned clients become
remote_sessionauth clients, self-owned onesservice_account; unclear ownership is reported asambiguousand never guessed. - Project clients get a project auth client; organization and platform-global clients get one per organization. A client shared by servers becomes one auth client with several server links.
- A new
authclientbackfillpackage decides from a dry run first, writes conditionally on that evidence, and skips stale or concurrent changes asskipped_race, picking them up on rerun. - Each run retires backfilled links and clients whose association or upstream client is gone, and marks linked servers as needing upstream authentication when undecided.
The migration runs this as its own "Auth clients" line after associations and selections; a failure is returned as auth_clients_error and never fails the other steps. The admin UI shows this status apart from migrated, and "Migrate all pending" also runs migrated organizations that still have records to write, retire, or mark.
๐ Preview Environment (PR #7768)
Preview URL: https://pr-7768.dev.getgram.ai
| Component | Status | Details | Updated (UTC) |
|---|---|---|---|
| โ Database | Ready | Created and validated | 2026-10-19 21:36:44. |
| โ Images | Available | Container images ready | 2026-10-19 21:38:04. |
Gram Preview Bot