Skip to content

Wire the agent token broker into the gateway - #67

Open
dcmcand wants to merge 1 commit into
slice/agent-tokens-14-agent-requestfrom
slice/agent-tokens-15-wiring
Open

dcmcand wants to merge 1 commit into
slice/agent-tokens-14-agent-requestfrom
slice/agent-tokens-15-wiring

Conversation

@dcmcand

@dcmcand dcmcand commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Slice 15: Wiring and gateway start

The gateway builds the broker from config when the switch is on (failing start naming what is missing), runs its janitor, and runs Purge beside start when the switch is off.

Spec: nebari-dev/tapas/docs/superpowers/specs/2026-11-30-agent-token-broker-design.md
Plan: nebari-dev/tapas/docs/superpowers/plans/2026-12-01-agent-tokens-and-frames.md (Slice 15)
Contracts touched: gateway.Config gains AgentTokens
Depends on: #66

  • Switch on: broker from agentTokens.services, the sessions key, api.tokens.groupsMaxAge, and the OIDC provider as minter; authoidc.WithOfflineTokens() and Authenticator.OfflineTokens from the same switch; RunJanitor(JanitorFirst, JanitorEvery). Start fails naming the setting for no persistent sessions key, an empty client secret file, or no minter (Journey 10).
  • Switch off: no broker, OfflineTokens a nil interface, Purge in a goroutine; a hanging minter does not hold start (Q43).
  • Purge deletes by the gen it read (owner decision); a row it did not delete counts as kept.
  • After this PR, agentTokens.enabled: true turns the whole broker on. Nothing consumes it until the Frames slices.

Reviewer note: each connection between the broker and the running gateway has a test that fails when it is cut (checked by mutation).

Validation

Step Command / action Expected Result
unit go test -count=1 ./internal/cli/... ./internal/gateway/... ok ok (also make test-postgres: exit 0)
local make test-local ok exit 0
vet go vet ./... clean clean

With agentTokens.enabled on, the gateway builds the broker from config at
start: the services and their scopes, the sessions key to seal tokens,
api.tokens.groupsMaxAge as the age limit, and the OIDC provider as the
minter. The OIDC provider collects an offline token at each sign-in, the
sign-in host hands it to the broker, and the janitor runs in the
background. Start fails, naming the setting and not its value, when the
sessions key is not persistent, the client secret file is empty, or no
sign-in provider can mint.

With the switch off there is no broker, sign-in collects nothing, and
Purge runs beside start to end every stored token at Keycloak; a minter
that never answers does not hold start. Purge now deletes a live row by
the generation it read, so a token a still-switched-on replica stores
meanwhile stays for the next start, and any row it did not delete counts
as kept.

The broker's hand-off into the gateway, the cluster's sessions-key check
and the sign-in collection switch each have a test that fails when the
connection is cut. contracts.md, the spec and the plan's evidence,
checkpoint review and deviations are updated.
@dcmcand
dcmcand added this pull request to stack #40 December 2, 2026 15:58
@dcmcand dcmcand mentioned this pull request Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant