Repository navigation
fix(agent): accept a cancellation-only bearer for projectless runs - #5677
Conversation
The API hands the runtime the requester's full session as the cancellation bearer of a projectless run. Before the API can mint a narrow credential, the runtime has to verify it. verifyRunCancellationToken now also accepts the projectless_run_cancellation use: the run and its requester, an empty scope, no project and no service account. The session shape stays accepted, so the API can switch producers behind its own flag after this ships. The shared contract fixture gains the projectlessCancellationOnly shape with a pinned digest. Refs veryfront/veryfront-issue-inbox#4914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
📦 Client bundle boundary
A server module in a client graph aborts hydration in the browser. New leaks fail CI; known leaks are tracked in |
|
@codex review |
Review score: 86/100Small, well-scoped reader-side change that lets the runtime accept a narrow projectless cancellation bearer while keeping the session shape. Tests are thorough. One code comment overstates the new token's reach.
Merge-ready once the comment is fixed. Both items above are about follow-up and rollout, not about this diff. Generated by Claude Code |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
The comment said the bearer is authority to stop one run and nothing else. That holds for verifyRunCancellationToken and for the API, not for the base authenticator, which admits any API-signed token with a userId. Say so, type the empty scope list like its siblings, and record the bearer lifetimes in the contract fixture notes. Refs veryfront/veryfront-issue-inbox#4914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|



Problem
The cancellation bearer of a projectless run is the requester's full session (veryfront-api
mintRuntimeCancellationAuthTokenends inmintAuthenticatedUserToken). It is valid on every API surface for 30 to 60 minutes. The API cannot mint a narrow credential yet, because this runtime's verifier only accepts the session shape and would answer every projectless Stop with 403.Refs veryfront/veryfront-issue-inbox#4914 (follow-up of #4912). This is the reader half and ships first. The producer half is a veryfront-api PR that stays off by default.
Root cause
verifyRunCancellationTokeninsrc/agent/service/auth.tsaccepts exactly two shapes, pinned bytests/fixtures/contracts/api-run-cancellation-jwt-payload.json: the project service account, and a plain user session with notokenUseand the scopesread,write,delete. A projectless bearer with anytokenUseis refused.Fix
verifyRunCancellationTokenalso accepts the cancellation-only shape:tokenUse: "projectless_run_cancellation", an emptyscope, the run and its requester, no project, no service account. The exact-run binding, expiry, RS256 pinning and own-data-property reads are the sharedreadRunControlClaimspath, unchanged.projectlessCancellationOnlywith its digest pinned in the test. The existingprojectScopedandprojectlesspayloads and digests are unchanged, so the contract id staysv1. The same file goes into veryfront-api with the producer.The claim set, in mint order:
userId,tokenUse,scope,runId,agentId(plusiatandexp). Noemailand nojti, so every claim is compared literally.Tests
New tests fail on
main(2 failures before the verifier change: the token test and the route test).src/agent/service/run-cancellation-authorization.test.ts: accepts the cancellation-only shape for its own run and refuses it for another; 15 refused variants (session scopes, any scope, missing or non-array scope, ascopesarray, no use, another use, a project, a service account, no user, no run, expired, no expiry); inherited and accessor-backed claims; the route returns 202 for the run and 403 for another run. One test fails if the fixture shape is ever regenerated from the session mint (it would carryemail,jti, session scopes and no use).tests/integration/agent/run-cancellation-authorization.test.ts: the cancellation-only shape under real RS256 verification, and end to end throughDELETE /api/runs/{run_id}on the hosted runtime (202 for its run, 403 for another).Ran:
deno task test:fileon both files, onsrc/agent/service/run-control-sealed-ingress.test.tsand ontests/integration/agent/run-cancellation-authorization-intrinsics.test.ts;deno fmt --check,deno lintanddeno checkon the changed files;deno task lint:anti-slop;deno task lint:test-semantic-dispositions.Not in this PR
PROJECTLESS_RUN_CANCELLATION_TOKEN_MODE, defaultsession). Turn it on only after a framework release with this change runs on every hosted runtime.authenticateRequest) admits any API-signed token with auserIdon its other routes, as it does today for the project cancellation bearer and the session. The narrow bearer is refused by the API behind those routes and the producer bounds it to five minutes. Narrowing the base authenticator by token use is a separate change; whether it must land before the producer is switched is a rollout decision.🤖 Generated with Claude Code