feat(backend): add clerk.policy.check - #9550
Draft
wyattjoh wants to merge 1 commit into
Draft
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 85a1a3a The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
wyattjoh
force-pushed
the
clerk-agent-approvals/sdk-policy-check/check
branch
from
August 25, 2026 20:12
355ee64 to
39c42c5
Compare
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-google-signin
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Register `policy: new PolicyAPI(request)` on the backend client and ship its
first method. `check` posts an operation to `POST /v1/agent_actions` and returns
the resulting `AgentAction`, never blocking and never throwing on an API
outcome.
`PolicyAPI` returns the native `{ data, errors }` union rather than throwing,
which it obtains by unwrapping the legacy request wrapper locally. The
conversion is total: `requestFn` never throws, the wrapper throws exactly
`ClerkAPIResponseError`, and every field of the errors arm survives that
construction. Anything else reaching the `catch` is rethrown.
`CheckParams` is split into per-`tokenType` arms so the contract's obligations
are compile-time facts. `actorId` is required everywhere and derived nowhere:
an inbound token's client id is ambiguous between the exchanging party and the
authorized client, and only the resource server knows which topology it is in.
The `oauth_token` arm derives `subjectId` and `authorizedClientId`, which its
token verifiably names, and accepts neither. There is no session arm.
`deepSnakecaseBodyParamKeys` stays unset so `parameters` keys reach the API
byte-for-byte — the spelling `check()` uses is the spelling the field registry
and every policy leaf must use.
wyattjoh
force-pushed
the
clerk-agent-approvals/sdk-policy-check/check
branch
from
August 25, 2026 21:17
39c42c5 to
85a1a3a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Chunk 2 of four building
clerk.policyin@clerk/backend, on top of #9542. That PR landed the resource types with no consumer; this one registersPolicyAPIand shipscheck(), which asks whether policy allows an agent's proposed operation and returns theAgentActionrecording the answer.Three things the diff doesn't explain:
{ data, errors }union is restored by unwrapping the legacy wrapper inside the class —buildRequestis untouched.actorIdis always caller-supplied, never derived. An inbound token's client id is ambiguous between the party that exchanged it and the party the human authorized, and only the application knows which. Theoauth_tokenarm derivessubjectIdandauthorizedClientId, which its token verifiably names, and accepts neither. There is no session arm.parameterskeys reach the API byte-for-byte. The spelling passed tocheck()is the spelling the field registry and every policy leaf must use; a mismatch is a rule that never matches and never errors.Reads and
waitForApprovalfollow in the two PRs above.Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change