Skip to content

feat: run-scoped agent tokens with server-generated values and upsert - #22

Merged
TheGreatAxios merged 1 commit into
mainfrom
cl-10967-require-a-grant-and-server-issued-tokens-on-solution
Oct 21, 2026
Merged

TheGreatAxios merged 1 commit into
mainfrom
cl-10967-require-a-grant-and-server-issued-tokens-on-solution

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Contributor

Summary

Add mountRunScopedTokens and mintRunScopedToken so a host (e.g. Solution Builder) can mint a token for a specific workflow run with proper security:

  • The server generates the token; callers cannot choose its value
  • Every route runs the host's requireGrant (credential:* create)
  • The run must resolve to the route's own tenant; unknown runs return 404
  • Re-registering for the same run revokes the old token first (upsert inside a transaction)
  • A partial unique index on ("tenant_id", "run_id") WHERE NOT revoked enforces one active token per run at the database level
  • Schema: adds nullable run_id column to agent_token.token (migrations/0002_run_scoped_token.sql)
  • Types: AgentTokenIdentity and AgentTokenContext now carry runId: string | null

Verification

  • bun run check: passes (tsc, oxlint, oxfmt, tests)
  • bun run build: passes

Closes CL-10967

Add mountRunScopedTokens and mintRunScopedToken so a host (e.g. Solution
Builder) can mint a token for a specific workflow run with proper security:

- The server generates the token; callers cannot choose its value
- Every route runs the host's requireGrant (credential:* create)
- The run must resolve to the route's own tenant; unknown runs → 404
- Re-registering for the same run revokes the old token first (upsert)
- A partial unique index on (run_id) WHERE NOT revoked enforces one
  active token per run at the database level

Schema: adds nullable run_id column to agent_token.token (migration 0002).
Types: AgentTokenIdentity and AgentTokenContext now carry runId: string | null.

Closes CL-10967
@linear-code

linear-code Bot commented Oct 21, 2026

Copy link
Copy Markdown

CL-10967

@corbits-triage

corbits-triage Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

Waiting on a maintainer to approve: approve, request review.

@TheGreatAxios
TheGreatAxios merged commit 2cd47a1 into main Oct 21, 2026
2 of 3 checks passed
@TheGreatAxios
TheGreatAxios deleted the cl-10967-require-a-grant-and-server-issued-tokens-on-solution branch October 21, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant