Repository navigation
feat(agent): delegated low-risk write tools, gated by the grant's capabilities - #5683
kojiwakayama wants to merge 5 commits into
Conversation
…abilities Adds user_schedules_list, user_project_create, user_schedule_set_status and user_input_request_answer over the delegated API client. Each exists only when the grant names its capability in authorization_details (decoded unverified, for presence only). Each write sends exactly the body the API guard admits and returns what changed and how the person can undo it. A refused change tells the model that nothing changed and why. The client gains sendJson (POST or PATCH, serialized once before the grant enters the request, replayed byte for byte on the 401 retry) and capabilities(). Refs veryfront/veryfront-issue-inbox#4992 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: 82/100: goodThe capability-gated write tools have a careful security design. Most of what's left is about ambiguous outcomes when a write fails, not about whether it's correct. Strengths
Concerns (none blocking)
Not verified here: the review container has no Deno toolchain, so I relied on the test run reported in the PR description ( Generated by Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ddd3b81e33
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
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❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…revoked capabilities - user_input_request_answer sends one Idempotency-Key per answer, which sendJson keeps across the 401 retry; the route requires it. - Delegated tools read response status through the native getter the client captured at load, so a patched Response.prototype.status cannot flip a write's outcome. - Answer values are limited to string, number, boolean or null, as the input contract allows. - A capability tool checks the current grant before each call, so a renewed grant that drops a capability stops its tool. Refs veryfront/veryfront-issue-inbox#4992 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
… prototype The semantic unit-boundary audit refuses a unit test that redefines Response.prototype.status. The test now gives each stubbed response an own status that lies, which the tools must ignore, and stays hermetic. Refs veryfront/veryfront-issue-inbox#4992 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
…choice field The API's InputResponseValueSchema admits a list of option values, and a select or radio field with multiple: true accepts only a list. The tool's schema refused lists, so such a request could not be answered. Refs veryfront/veryfront-issue-inbox#4992 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9892cdde7a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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".
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".
…ore the answer A transport failure after the request reached the API used to surface the raw fetch error, so the model could retry user_project_create without knowing the first project may already exist. Report the same read-back warning used for ambiguous HTTP failures, without echoing the raw error. A cancelled call keeps its own reason. Refs veryfront/veryfront-issue-inbox#4992 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
|



Refs veryfront/veryfront-issue-inbox#4992 (C4 of epic veryfront/veryfront-issue-inbox#4966). Runtime side of veryfront/veryfront-api#7959 (A7).
Problem
A7 maps the low-risk delegated writes (
projects.create,schedules.activate,schedules.pause,input_requests.answer) and theschedules.listread, but a hosted run had no tool to call them. The delegated client only offered a rawrequest, and nothing read which capabilities the grant carries, so a run could not offer a tool only when its grant allows it.Root cause
createHostedDelegatedUserToolsbuilt the seven phase 1 reads and nothing else.Fix
Client (
delegated-user-credential.ts):capabilities(): the actions of the grant's singleveryfront_delegated_actionsentry inauthorization_details, decoded without verifying the signature (presence only; the API checks every call). It follows renewals. A grant that is not a JWT, or names another type, has none.sendJson(path, { method, body, signal }):POSTorPATCHonly. The body is serialized once with a capturedJSON.stringify, before any grant is in a request, and sent withContent-Type: application/jsonthroughrequest, so the snapshot-once rules apply and a 401 retry replays the same method and bytes.readGrantClaims).Tools (
delegated-user-tools.ts), each present only when the grant names its capability:user_schedules_listschedules.listGET /projects/{ref}/schedulesuser_project_createprojects.createPOST /projectswithaccount_id(UUID, required),name, optionalslug,descriptionuser_schedule_set_statusschedules.activateand/orschedules.pausePATCH /projects/{ref}/schedules/{id}with exactly{ status }. The schema offers only the statuses the grant carriesuser_input_request_answerinput_requests.answerPOST /input-requests/{id}/responseswith exactly{ values }{ changed, undo, <api body> }: project create says the person moves the project to trash in Studio; a schedule change names the opposite status (with this tool when the grant carries it, otherwise in Studio); an answer says it cannot be undone.detail(route_not_delegated, write flag off, capability not granted, body not allowed) to a fixed message; the API body is never echoed. A 5xx says the change may or may not have been applied.Docs: the delegated section of
docs/architecture/native-request-processing.md.Tests
Fail on
main(missing exports and methods), pass here:delegated-user-tools.test.ts, newcapability toolsblock: no phase 2 tool without its capability (non-JWT grant, phase 1 grant, foreigntype); each tool exactly when its capability is present; only granted schedule statuses accepted; exact bodies per guard (method, path, JSON, content type), with project keys a subset of theprojects.createguard keys; schema refusals of what the guards refuse (missing or non-UUIDaccount_id, legacyaccountId, extra keys,cron,deleting, extra answer keys); the schedules read;changed/undoin results; grant, its segments and the run token absent from descriptions, input JSON schemas, results, errors and logs; 403route_not_delegatedand the other refusals give clear model-facing messages without echoing the body.delegated-user-credential.test.ts, new block:sendJsonserializes once before any request and replays the same bytes and method on the 401 retry even after the caller mutates its object; onlyPOST/PATCHand JSON-serializable bodies;capabilities()decoding, filtering and renewal.Ran:
deno task test:file src/agent/hosted(1089 passed, 0 failed),deno fmt --check,deno lint src/agent/hosted,deno check src/agent/hosted/*.ts,lint:anti-slop,lint:check-awaits,lint:test-typecheck,lint:ban-test-only.Not in this PR
user_agent_createwith the approval wait (C5) and advertisingdelegated_user_approvals.detailtext because the problem body carries no reason code. A stable reason field in the API would make this exact; unknown details fall back to a generic "refused, nothing changed" message.🤖 Generated with Claude Code