Skip to content

Let a connected program's work sign as its person after the session ends - #177

Merged
rafiki270 merged 1 commit into
mainfrom
feat/agent-grant-subject-assertions
Nov 22, 2026
Merged

rafiki270 merged 1 commit into
mainfrom
feat/agent-grant-subject-assertions

Conversation

@rafiki270

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #176. A program connected to Nessie can now outlive its approver's session, but the work it starts (DeepCRM, Ledger and memory calls, organisation reads) still signed subject assertions with the session's assurance_ref. After the 30-day sign-in, those calls would fail while the connection itself stayed alive.

  • agent_grant subject-assertion claim (confidential-token-exchange.service.ts): a product may name its agent connection grant handle in place of assurance_ref. verifyConfidentialSubjectToken accepts it only when the caller passes allowAgentGrant, and only POST /auth/token and organisation reads via X-UOA-Subject-Assertion (org-role-guard.ts) pass it. Every other verifier refuses: assurance validation, job grants, and issuing a new agent grant.

  • Checks on every use (admitAgentGrantAssertion in the new agent-connection-grant-policy.service.ts):

    • exact subject, org, team, epoch and source domain;
    • revocation, idle expiry and the org ceiling;
    • the product mapping (or first-party binding) and the sign-in evidence;
    • account participation.

    It never moves the idle clock. It is refused when combined with assurance_ref, assurance_id or evidence claims.

  • Token exchange: grant-derived exchanges may mint only ai.invoke, billing.read, memory.read and memory.write (never session:broker or token.provision). The issued token carries agent_connection and no assurance_id.

  • SSO-governed organisations: the grant's evidence reaches assertOrgAccessPolicy through getActiveClientOrgContext/getUserOrgContext (agentGrant, also on AccessTokenClaims for GET /org/me), so they admit it only with matching SSO evidence.

  • Refactor: the shared grant rules move to agent-connection-grant-policy.service.ts, to avoid an import cycle with the token exchange.

  • Docs: /llm documents the claim.

Testing

Run on Minis against Postgres 16:

  • @uoa/api typecheck and lint pass.
  • agent-connection-grant.test.ts, 6 tests. The new one covers opted-in admission, refusal without opt-in, refusal next to assurance_ref, refusal for another team, and refusal after revoke.
  • Token exchange (3 files), org-me, fresh proof, global assurance and job grants: 8 files, 59 tests pass.
  • API unit suite: 431 files pass.
  • Not covered: an end-to-end /auth/token exchange with an agent_grant assertion and a live SSO-governed org read. The exchange scope fence is covered by code review only.

🤖 Generated with Claude Code

A product's subject assertion may name agent_grant in place of assurance_ref.
Only token exchange (ai.invoke, billing.read, memory.read, memory.write) and
organisation reads opt in; every other verifier refuses it. The grant is
rechecked (revocation, expiry, epoch, mapping, sign-in evidence, account
participation), never moves the idle clock, cannot be combined with a session
proof and yields no assurance id. SSO-governed organisations admit it only with
matching SSO evidence. Shared rules move to agent-connection-grant-policy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rafiki270
rafiki270 enabled auto-merge November 22, 2026 22:45
@rafiki270
rafiki270 merged commit 319f7fe into main Nov 22, 2026
@rafiki270
rafiki270 deleted the feat/agent-grant-subject-assertions branch November 22, 2026 22:45
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T22:46:03.407884Z d4a3cd4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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