Repository navigation
Description
Depends on: #2563 (durable broker state), #2568 (sign-out and revocation); "Handle multi-pod refresh token rotation race condition" (stacklok/toolhive#4122) (refresh serialized across replicas, including storage an embedder passes in); and the ToolHive set for "Sign-out and revocation" (#2568): the "to file" rows in "Phase 3, Track: ToolHive — The remaining ToolHive changes for audit, sign-out, and schedules" (#2570) for disconnecting a provider and for AS-1's revocation notice
Problem
With the identity broker on, the mecak8s chart requires replicaCount: 1 and renders the Recreate strategy (deploy/helm/mecak8s/templates/_helpers.tpl). Phases 1 and 2 keep this (#2451, #2545). Several pieces of state and coordination assume one process:
- broker sessions and the per-host-session open lock;
- the cross-replica edge when two replicas create the same session;
- the converted access-token
jtiset, and thejtistores for client assertions and ID-JAGs; - AS-1's users, upstream tokens, and issued refresh tokens;
- the broker and AS-1 sharing a clock;
- the embedded AS-2's
mecatlclient record and signing key, which each replica would write or generate for itself; - the MCP client's send-once record, parked gateway calls, and vMCP session IDs (MCP broker authorizes gateway calls and sends them to the configured gateway #2536, MCP client state: one vMCP session per agent, durable send-once and parked calls #2564);
- run records and delegation reports (Runs, delegations, and the run owner #2557);
- per-process rate limits on the embedded AS-2 routes (Rate-limit the embedded gateway's authorization server routes #2772).
Design
- implementation.md: Sign-out and revocation checks
- implementation.md: Run owner checks
- credentials-and-lifecycle.md: (3) Session open and the broker refresh token
- credentials-and-lifecycle.md: Sign-out and revocation
Requirements
- Sessions and opens. The per-host-session open lock holds across replicas. Concurrent opens of one session on two replicas store one refresh token and revoke the other. Two replicas creating the same session converge on one broker session.
- One live refresh token per session. An exchange that gets
revokedrereads the shared record. Any replica retries pending AS-1 revocations. - One upstream refresh. Concurrent exchanges for one user across replicas cause one upstream refresh, under a lease.
- Shared
jtistores. The converted access-token set and thejtistores for client assertions and ID-JAGs are shared, so a second use on another replica is refused, including two concurrent ID-JAG redemptions at the embedded AS-2. - AS-1 and AS-2 across replicas. Every replica serves the same AS-1 and embedded AS-2: shared users, upstream tokens, refresh tokens, client records, and operator-supplied signing keys (Keys and gateway entries for the identity broker #2538), never a per-replica generated key.
- Clock. The broker's echo and hard-expiry checks allow the configured clock skew, since the broker and AS-1 no longer share a clock.
- Revocation and sign-out. Sign-out everywhere and revocation reach sessions and grants served or stored by every replica, and cancel live runs and parked calls there.
- Run records. Run records and delegation reports created concurrently on two replicas keep one record.
- mecak8s call state. The send-once record, parked gateway calls, and vMCP session IDs are shared, behind the interfaces MCP broker authorizes gateway calls and sends them to the configured gateway #2536 and MCP client state: one vMCP session per agent, durable send-once and parked calls #2564 introduce.
- Rate limits. The embedded AS-2's route limits are sized per replica or shared, and the chosen rule is documented.
- Chart. The chart allows more than one replica with the broker on only when all of the above hold.
How it fits
Removes the "one replica" shortcut in #2451. Slice 3 (the broker as its own service) builds on it, because a separate broker serves several mecak8s replicas.
Done when
The design's replica checks in "Sign-out and revocation checks" and "Run owner checks" pass with two replicas, a concurrent-open and a concurrent-redemption test pass across two replicas, and the chart allows more than one replica with the identity broker on.
Activity
rdimitrov commentedon Nov 25, 2026
Scope addition from #2985: one accepted broker record per registration and per delegation across replicas. Today in-process locks keep an identical repeat from producing a second success record; two replicas could each record it under a different
AuditID.fix(identitybroker): address the fourth review of the broker records