Repository navigation
refactor(gateway): request entries read the owner from the request grant - #205303
Conversation
conversations, tools.invoke, session resource tool policy, Talk consult and OpenAI-compatible HTTP read grant.owner from readGatewayRequestAdmission/decideTurnGrant instead of deciding owner from the admin scope. In-process calls keep their admitted run's grant. OWNER_PRODUCER_FILES 28 -> 23. Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
E2E on exact head
|
|
Codex review: needs changes before merge. What this changesGateway request handlers read ownership from the admitted run grant, falling back to a grant derived from connection scopes. Example: An admitted owner run calls tools.invoke with operator.write request scopes.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain This PR usefully centralizes request ownership, but the new mock violates the CI ratchet and GitHub now reports a merge conflict. Reviewed head: Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway RPC, HTTP, session-resource, and Talk entry points translate authenticated request context into ownership facts consumed by tool and session authorization. flowchart TD
A[Authenticated connection] --> C[Request admission reader]
B[Admitted run grant] --> C
C --> D[RPC and Talk handlers]
E[Authenticated HTTP scopes] --> F[Turn grant decision]
F --> G[HTTP session authorization]
D --> H[Tool and conversation execution]
Technical reviewBest possible solution: Keep the shared admission reader and consumer migration, replacing mocked argument checks with focused owner/member behavior coverage through the existing production boundary. Do we have a high-confidence way to reproduce the issue? An internal client carrying an owner grant and operator.write scopes produces false ownership on the base and true ownership with this patch; the supplied tests construct that input, but no shipped-entry-point reproduction of it is shown. Is this the best way to solve the issue? The shared admission owner is the smallest coherent location for the decision, and the HTTP change preserves its existing scope semantics; the retained Talk command-owner path is explicitly justified rather than silently removed. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2ac011e302a3. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +60, Other -6. Total +56 across 21 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 25, 2026, 6:49 AM ET / 11:49 UTC. |
….invoke cell mock Talk stays an owner producer: its tool overlay owner includes the commands.ownerAllowFrom match for a Talk caller without admin. OWNER_PRODUCER_FILES ceiling 24. The tools.invoke cell mock records its isolation reason. Co-authored-by: obviyus <[email protected]>
…owner # Conflicts: # test/scripts/oxlint-boundary-guards.test.ts
|
E2E on exact head
|
|
Maintainer override:
|
|
Landed as 5730bde. Bug: an owner's agent calling |
…ant (openclaw#205303) ## Problem OA2 PR 6d (one admission owner). Four request entries decided "the sender is the owner" for themselves, from the connection's `operator.admin` scope: - `conversations.send` / `conversations.turn` (`server-methods/conversations.ts`) - `tools.invoke` RPC (`server-methods/tools-invoke.ts`) - session resource tool policy (`session-resource-tool-policy.ts`, MCP App and session resource methods) - OpenAI-compatible HTTP pre-run owner bit (`openai-compatible-http.ts`) That gave the same person two answers. An agent's `conversations_send` / `conversations_turn` tool (owner-only) and plugin `tools.invoke` calls dispatch in process with least-privilege scopes (`operator.write`) and the run's admitted authority. The handler ignored the admitted grant and saw "not owner", so the owner's own agent ran the conversation turn without owner tools, while the same owner calling the same method from the Control UI was owner. ## Fix - `operator-admission.ts` exports `readGatewayRequestAdmission(client)`: the request's grant is its admitted run's grant (`client.internal.operatorRunAuthority.grant`), else the grant `decideTurnGrant` decides from the connection scopes. - `conversations`, `tools.invoke` and the session resource tool policy read `….grant.owner` from it. - OpenAI-compatible HTTP: `prepareOpenAiCompatibleHttpRequest` returns `grant = decideTurnGrant(operatorScopes)` (the same request scopes the run is admitted with); `/v1/chat/completions` and `/v1/responses` session checks read `grant.owner`. - Lint: `OWNER_PRODUCER_FILES` 28 → 24 (four request files leave; ceiling lowered). ## Decisions (recorded, not asked) - **The admitted run's grant wins over the in-process client's least-privilege scopes.** The synthetic scopes narrow which Gateway method may run, not who the requester is. Owner-only conversation tools already require an owner run, so the owner now keeps owner status in the conversation turn they started. A member run stays non-owner (cell below). - **No full `decideOperatorAdmission` per RPC request.** Request admission (method authorization) is OA3; this PR only removes the second owner producers. A bare socket still gets the grant its connect scopes decide, through `decideTurnGrant`. - **Talk not moved (split).** `talk/client-tool-authority.ts` stays listed. The Talk tool overlay takes the owner from `resolveCommandAuthorization`, which includes the `commands.ownerAllowFrom` match for a Talk caller without admin (`client-permission-parity` "uses configured ownership without admin"). Moving only the consult bit would leave consult and tools able to disagree and would make the file look migrated. Talk moves when admission represents configured owners (openclaw#205232 follow-up (i)). - **Production lines (recorded):** `src` non-test +21 / −16 (net +5), counting the lint allowlist net 0. The +7 is the one request-grant read in the admission owner. The cause is missing code: request entries never read the admitted grant. No flag, hook or state was added. - **Kept:** `resolveOpenAiCompatibleHttpSenderIsOwner` for the model-override and managed-image checks (pre-run request checks, not owner producers; OA3 seam, same as openclaw#205091). ## User impact - An owner's agent that uses `conversations_turn` / `conversations_send`, or a plugin that calls `tools.invoke` in process, now runs with the owner's tools, the same as the owner calling the method directly. - Non-owners see no change. Control UI, Talk and HTTP owners see no change. ## Evidence - Cells (red on base `1a4f4a41098c`, green on head): `conversations.test.ts` and new `tools-invoke.test.ts`, each owner socket / write socket / owner run (write scopes + admitted owner authority) / member run. Base: only `owner run` fails (`senderIsOwner: false`); head: 8/8. - Pre-push and E2E: see comments. - Pre-push: one `ocx test` call over 55 files (touched tests + direct importers of every changed source/test-support, `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1`). 1 OURS (`client-permission-parity` configured owner): Talk cut from this PR, green. 42 Talk handler failures (`client-create-authority`, `talk/handlers/client`, `talk/handlers/index`) fail identically on base `1a4f4a41098c` (`Cannot read properties of undefined (reading 'role')`): not this change. One `openai-http` SSE case timed out at load 74; green on rerun (112/112). After rebase: `pnpm tsgo:core`, `pnpm tsgo:test` clean; cells + lint guard green; oxfmt/oxlint clean. Co-authored-by: Ayaan Zaidi <[email protected]>
Release adaptation: Use the stable admitted scope ceiling for persisted and runtime ownership, keeping configured requester ownership separate. Companion audit: Requester custody and inherited-model companions are already committed. #205303 and #205451 extend the newer grant contract; not required. (cherry picked from commit 1c83c39) Co-authored-by: RomneyDa <[email protected]>
Problem
OA2 PR 6d (one admission owner). Four request entries decided "the sender is the owner" for themselves, from the connection's
operator.adminscope:conversations.send/conversations.turn(server-methods/conversations.ts)tools.invokeRPC (server-methods/tools-invoke.ts)session-resource-tool-policy.ts, MCP App and session resource methods)openai-compatible-http.ts)That gave the same person two answers. An agent's
conversations_send/conversations_turntool (owner-only) and plugintools.invokecalls dispatch in process with least-privilege scopes (operator.write) and the run's admitted authority. The handler ignored the admitted grant and saw "not owner", so the owner's own agent ran the conversation turn without owner tools, while the same owner calling the same method from the Control UI was owner.Fix
operator-admission.tsexportsreadGatewayRequestAdmission(client): the request's grant is its admitted run's grant (client.internal.operatorRunAuthority.grant), else the grantdecideTurnGrantdecides from the connection scopes.conversations,tools.invokeand the session resource tool policy read….grant.ownerfrom it.prepareOpenAiCompatibleHttpRequestreturnsgrant = decideTurnGrant(operatorScopes)(the same request scopes the run is admitted with);/v1/chat/completionsand/v1/responsessession checks readgrant.owner.OWNER_PRODUCER_FILES28 → 24 (four request files leave; ceiling lowered).Decisions (recorded, not asked)
decideOperatorAdmissionper RPC request. Request admission (method authorization) is OA3; this PR only removes the second owner producers. A bare socket still gets the grant its connect scopes decide, throughdecideTurnGrant.talk/client-tool-authority.tsstays listed. The Talk tool overlay takes the owner fromresolveCommandAuthorization, which includes thecommands.ownerAllowFrommatch for a Talk caller without admin (client-permission-parity"uses configured ownership without admin"). Moving only the consult bit would leave consult and tools able to disagree and would make the file look migrated. Talk moves when admission represents configured owners (refactor(auto-reply): reply runs take the owner decision their commands used #205232 follow-up (i)).srcnon-test +21 / −16 (net +5), counting the lint allowlist net 0. The +7 is the one request-grant read in the admission owner. The cause is missing code: request entries never read the admitted grant. No flag, hook or state was added.resolveOpenAiCompatibleHttpSenderIsOwnerfor the model-override and managed-image checks (pre-run request checks, not owner producers; OA3 seam, same as refactor(gateway): admit HTTP shared-secret requests as the owner principal #205091).User impact
conversations_turn/conversations_send, or a plugin that callstools.invokein process, now runs with the owner's tools, the same as the owner calling the method directly.Evidence
71b629c5f86e, green on head):conversations.test.tsand newtools-invoke.test.ts, each owner socket / write socket / owner run (write scopes + admitted owner authority) / member run. Base: onlyowner runfails (senderIsOwner: false); head: 8/8.ocx testcall over 55 files (touched tests + direct importers of every changed source/test-support,OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1). 1 OURS (client-permission-parityconfigured owner): Talk cut from this PR, green. 42 Talk handler failures (client-create-authority,talk/handlers/client,talk/handlers/index) fail identically on base71b629c5f86e(Cannot read properties of undefined (reading 'role')): not this change. Oneopenai-httpSSE case timed out at load 74; green on rerun (112/112). After rebase:pnpm tsgo:core,pnpm tsgo:testclean; cells + lint guard green; oxfmt/oxlint clean.