Skip to content

Add agent connection grants for programs connected to a product - #176

Merged
rafiki270 merged 2 commits into
mainfrom
feat/agent-connection-grants
Nov 22, 2026
Merged

rafiki270 merged 2 commits into
mainfrom
feat/agent-connection-grants

Conversation

@rafiki270

@rafiki270 rafiki270 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A program a person connects to a product, such as ChatGPT or Claude through Nessie MCP, currently dies at that person's absolute sign-in deadline, used or not. This adds a separate grant for such a connection that lasts until it is revoked or goes 90 days unused, as Microsoft and Atlassian refresh tokens do. Session assurance is unchanged and keeps its absolute deadline.

  • POST /auth/agent-grants (agent-connection-grant.service.ts): issues one grant per (connection, team). It requires the person's live, unexpired independent or SSO proof for that exact team, carried as assurance_ref in a fresh subject assertion; recovery proofs are refused. The proof's evidence is copied onto the grant: method, SSO connection revision and generation, external identity, MFA source, AMR and policy generation. The same request_id recovers the same handle.
  • POST /auth/agent-grants/:handle/renew: returns the current org context and, on request, a 120-second resource token for a mapped downstream resource (ai.invoke, billing.read, memory.*).
    • Each renewal rechecks revocation, the credential epoch, active user and source-domain role, org and team membership, unpaid seats, the mapping, the SSO policy generation, and for SSO grants the connection, external identity and provisioning. The checks are in agent-connection-grant-evidence.service.ts and are threaded through assertOrgAccessPolicy / getActiveClientOrgContext as agentGrant, so SSO-governed organisations admit a grant only with matching SSO evidence.
    • Only touch: true slides the idle deadline, at most hourly. Reconciliation and background work send false.
  • POST /auth/agent-grants/:handle/revoke: idempotent, and needs no current membership.
  • agent.connection scope on ConfidentialDelegationMapping is the per-product switch. resolveConfidentialDelegation accepts it only from the grant service and only on its own, so /auth/token can never mint it. The Admin delegation form offers it.
  • Grants are never session proof. Resource tokens carry agent_connection {grant_handle, connection_id} and no assurance_id.
  • agent_connection_max_days on PUT /org/organisations/:orgId (1–3650 or null) sets an optional absolute ceiling. It is read live, so lowering it applies to existing grants.
  • Migration 20261122200000_agent_connection_grants: adds the enum value, the org column with a check constraint, and the table with the same uoa_app deny and RLS as sales_research_job_grants.
  • /api and /llm: schema.auth-agent-grants.ts, llm-agent-grants.ts, and the org schema field.

On for Nessie from the start: FIRST_PARTY_AGENT_CONNECTIONS lets api.nessie.works hold grants for https://api.nessie.works/mcp without a mapping row. Other products need an enabled agent.connection mapping. Nessie's side is the next PR. Plan: UnlikeOtherAI/Nessie#1857.

Testing

Run on Minis against Postgres 16 (Maxis was at 82% CPU from other work):

  • @uoa/api typecheck and lint, @uoa/admin typecheck and lint: pass.
  • New tests/integration/agent-connection-grant.test.ts, 5 tests (the fifth: a non-first-party product stops when its mapping is disabled):
    • issue only with live proof, and retry recovery;
    • the grant outlives the sign-in family, slides only on touch, and lapses after 90 unused days;
    • org ceiling, team removal, epoch bump and revoke;
    • downstream scope limits, including that agent.connection and token.provision are refused and /auth/token resolution of agent.connection is rejected.
  • Neighbouring integration files: job grants, token exchange (3), memory delegation migration, root, org-me, shared orgs, slug admission, fresh proof, global assurance: 11 files, 72 tests pass.
  • API unit suite: 431 files pass, after adding the new limiter to auth-rate-limit-global.test.ts. The CSP and bootstrap suites need a built Auth/dist, and passed once it was built.
  • Not run locally: the full integration suite, which runs in CI. Not covered: SSO-method grants against a live enterprise connection; the evidence checks mirror validateSessionAssurance.

🤖 Generated with Claude Code

codex and others added 2 commits November 22, 2026 22:10
A program a person connects to a product (an MCP client) was pinned to that
person's session proof and died at its absolute sign-in deadline however much
it was used. An agent connection grant is issued from a live session proof for
one person, organisation and team, then lives on a 90-day idle clock that only
the program's own use slides, under an optional organisation ceiling.

Every renewal rechecks revocation, the credential epoch, active user and role,
organisation and team membership, unpaid seats, the product mapping, SSO policy
generation and, for SSO grants, the connection, external identity and
provisioning. The new agent.connection mapping scope is the per-product switch
and can never be minted through /auth/token. Grants carry no assurance id and
cannot pass for a session proof; their resource tokens carry agent_connection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nessie at api.nessie.works holds agent connection grants for
https://api.nessie.works/mcp without an operator mapping, as a first-party
product. Other products still need an enabled agent.connection mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rafiki270
rafiki270 marked this pull request as ready for review November 22, 2026 22:17
@rafiki270
rafiki270 enabled auto-merge November 22, 2026 22:17
@rafiki270
rafiki270 merged commit 08743aa into main Nov 22, 2026
1 of 2 checks passed
@rafiki270
rafiki270 deleted the feat/agent-connection-grants branch November 22, 2026 22:18
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.

2 participants