Repository navigation
refactor(gateway): admit the agent RPC turn before its owner bit - #205263
Merged
Merged
Conversation
Every agent turn is admitted before its input is recorded; the run and transcript take the admitted grant's owner bit. Deleted the admin-scope and requester-origin shape rules. Asserted channel owners keep the commands.ownerAllowFrom match (no grant). Co-authored-by: obviyus <[email protected]>
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Collaborator
Author
|
E2E on the exact head
Local review on this head: complete, "patch is correct", no findings. |
Collaborator
Author
|
Landed as 1c83c39. The |
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 26, 2026
…nclaw#205263) ## Problem The `agent` RPC turn decided its own owner bit before admission ran (OA2 PR 6f, follow-up (ii) of openclaw#205232). - `prepareAgentRunDispatch` recorded the user turn first and ran admission (`retainAgentTurnOperatorRun`) afterwards. Only private completions were admitted first. - So `agent-run-user-turn.ts` had no admitted grant and decided owner locally: `hasGatewayAdminScope(client)` plus four requester-origin shape rules. That is a second owner producer next to `decideTurnGrant`. - Result: any client that carried `operator.admin` was owner on `agent` turns, admitted or not. Example: a subagent spawned from an unadmitted System turn with a model override carries `[operator.admin]` only to allow the override, and its child turn became owner. ## Fix - `agent-run-admission-phase.ts`: every `agent` turn is admitted before its input is recorded (the private-completion path, generalized). The System-turn source choice reads the request's input provenance. The second admission block after input recording is deleted. - `prepareAgentRunUserTurn` takes `senderIsOwner` = the admitted grant's `owner`. The transcript stamp and the run use it. - Deleted `resolveRuntimeSenderIsOwner` (the admin-scope and origin-shape rules). ## Decisions (recorded, not asked) - **Cut less (Fable 5.2):** the `commands.ownerAllowFrom` match for a requester origin from a channel (`prepareCommandOwnerAuthority`, `:449-465` on base) stays. Asserted-identity channel owners (iMessage, SMS, IRC, Tlon, Slack relay, A2A, Feishu) have no admitted grant. Their own channel turn keeps owner through `command-auth.ts` (DESIGN §10 fork 2A). Without this match, their subagent and completion turns would silently lose owner-only tools. It is the same decision `command-auth.ts` makes for the channel turn, not a second implementation. Because of it, `agent-run-user-turn.ts` stays in `OWNER_PRODUCER_FILES`, and the allowlist does not shrink in this PR. - **Accepted behavior change (unadmitted turns only):** a synthetic System client that holds `operator.admin` without an admitted operator authority is no longer owner on `agent` turns. Its admin scope authorizes the model override only. This matches MATRIX (SYS → owner ✗). Real socket clients (shared-token CLI, paired admin device, authenticated admin profile), inherited admitted callers and verified-channel owners get the same answer as before: the grant's owner bit. - An admission refusal now happens before the input is recorded. The RPC caller gets the same error (`INVALID_REQUEST`). A returned result still records its "could not start under your current access" notice. ## User impact - `openclaw agent` (Gateway mode) and the Control UI give the same owner answer for the same credential, from the same grant. - No change for admitted turns. Unadmitted System `agent` turns lose owner-only tools. ## Evidence - Production (`src`, non-test): +40 / −64 (3 files). - Owner cells in `agent.owner-policy.test-support.ts` (run by `agent.test.ts`): admitted admin CLI → owner; admitted write CLI → not owner; authenticated admin/write profile; admitted operator continuation; configured asserted channel owner → owner; **unadmitted admin-scoped CLI and unadmitted System admin → not owner (red on base: base answered owner from the scope)**. - Pre-push: one `ocx test` call over the touched tests and importers of the changed files; `pnpm tsgo:core`, `pnpm tsgo:test`; oxfmt/oxlint on changed files. - E2E (one-admission run.sh Q/R/S) on the exact head: results in a follow-up comment. Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 30, 2026
Release adaptation: Use the stable retained custody runner for direct and one-way completion; preserve shared operator scope without attributing mixed-requester batches to one person. Companion audit: #207030 changes the newer announcement owner and is not needed; keep stable standalone delivery, deadline and row fencing. #205263 is a downstream separate lane row. (cherry picked from commit 50a6774) Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot
pushed a commit
that referenced
this pull request
Nov 30, 2026
Release adaptation: Share the stable worker-prepared lineage model across typed chat, image input and agent run admission; keep stop and explicit provider/model independent of parent lookup. Preserve inherited provider facts in the stable chat configuration witness and first-send native consent. Companion audit: #205263 is downstream; #207557 standalone execution does not own these stable entry points. (cherry picked from commit 27fe9c3) Co-authored-by: RomneyDa <[email protected]>
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.
Problem
The
agentRPC turn decided its own owner bit before admission ran (OA2 PR 6f, follow-up (ii) of #205232).prepareAgentRunDispatchrecorded the user turn first and ran admission (retainAgentTurnOperatorRun) afterwards. Only private completions were admitted first.agent-run-user-turn.tshad no admitted grant and decided owner locally:hasGatewayAdminScope(client)plus four requester-origin shape rules. That is a second owner producer next todecideTurnGrant.operator.adminwas owner onagentturns, admitted or not. Example: a subagent spawned from an unadmitted System turn with a model override carries[operator.admin]only to allow the override, and its child turn became owner.Fix
agent-run-admission-phase.ts: everyagentturn is admitted before its input is recorded (the private-completion path, generalized). The System-turn source choice reads the request's input provenance. The second admission block after input recording is deleted.prepareAgentRunUserTurntakessenderIsOwner= the admitted grant'sowner. The transcript stamp and the run use it.resolveRuntimeSenderIsOwner(the admin-scope and origin-shape rules).Decisions (recorded, not asked)
commands.ownerAllowFrommatch for a requester origin from a channel (prepareCommandOwnerAuthority,:449-465on base) stays. Asserted-identity channel owners (iMessage, SMS, IRC, Tlon, Slack relay, A2A, Feishu) have no admitted grant. Their own channel turn keeps owner throughcommand-auth.ts(DESIGN §10 fork 2A). Without this match, their subagent and completion turns would silently lose owner-only tools. It is the same decisioncommand-auth.tsmakes for the channel turn, not a second implementation. Because of it,agent-run-user-turn.tsstays inOWNER_PRODUCER_FILES, and the allowlist does not shrink in this PR.operator.adminwithout an admitted operator authority is no longer owner onagentturns. Its admin scope authorizes the model override only. This matches MATRIX (SYS → owner ✗). Real socket clients (shared-token CLI, paired admin device, authenticated admin profile), inherited admitted callers and verified-channel owners get the same answer as before: the grant's owner bit.INVALID_REQUEST). A returned result still records its "could not start under your current access" notice.User impact
openclaw agent(Gateway mode) and the Control UI give the same owner answer for the same credential, from the same grant.agentturns lose owner-only tools.Evidence
src, non-test): +40 / −64 (3 files).agent.owner-policy.test-support.ts(run byagent.test.ts): admitted admin CLI → owner; admitted write CLI → not owner; authenticated admin/write profile; admitted operator continuation; configured asserted channel owner → owner; unadmitted admin-scoped CLI and unadmitted System admin → not owner (red on base: base answered owner from the scope).ocx testcall over the touched tests and importers of the changed files;pnpm tsgo:core,pnpm tsgo:test; oxfmt/oxlint on changed files.