Skip to content

refactor(gateway): admit HTTP shared-secret requests as the owner principal - #205091

Merged
obviyus merged 1 commit into
mainfrom
refactor/oa2-http-grant
Nov 25, 2026
Merged

obviyus merged 1 commit into
mainfrom
refactor/oa2-http-grant

Conversation

@obviyus

@obviyus obviyus commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

OA2 PR 5b (DESIGN §9, HTTP half of row 5). The same person got a different answer depending on how the turn started:

  • A Control UI turn signed in with the shared Gateway token or password is admitted as the Gateway owner: it carries an admitted operator authority whose grant gives owner-only tools, GitHub PR actions, skill authoring and question replacement.
  • An OpenAI-compatible (/v1/chat/completions, /v1/responses) or /tools/invoke request with the same token or password was never admitted. It ran as System with no turn grant. Owner status was produced a second time in the HTTP layer (scopes.includes(operator.admin)), and /tools/invoke mapped owner to a client with only [operator.admin]. Anything that reads the admitted grant (PR actions, skill authoring, session controls) saw no grant.

Fix

  • New prepareGatewayHttpOperatorRunAuthority (HTTP-only, next to the Control UI producer in operator-run-authority.ts): a request whose credential names the Gateway owner (shared token or password, or private mode="none") is admitted through decideOperatorAdmission with the transport facts (owner profile + the request's own scopes). Every other HTTP credential (trusted-proxy person, OpenClaw ID member/owner) keeps the existing producer, unchanged.
  • OpenAI-compatible runs and /tools/invoke both use it. senderIsOwner for the turn is now authority.grant.owner; the tool request scope carries the admitted authority.
  • Deleted: the /tools/invoke owner → [operator.admin] client mapping (tools-invoke-shared.ts), the senderIsOwner parameter of runOpenAiCompatibleAgentCommand, and the HTTP-layer owner producer in tools-invoke-http.ts.
  • Lint: OWNER_PRODUCER_FILES 51 → 50 (tools-invoke-http.ts leaves). No new allowlist entries.
  • Docs: OpenAI, OpenResponses and tools-invoke pages say what a shared-token request may do.

Decisions (recorded, not asked)

  • Cut less: resolveSharedSecretHttpOperatorScopes stays. It is not a turn-only restore: models, embeddings, managed images and session history read it, and "shared secret ignores x-openclaw-scopes" is the documented HTTP contract. Session kill deliberately refuses the shared secret through the other scope path. Readers go before the source; changing that contract is its own security PR. The turn's grant now comes from admission; this function only gathers the request's scopes (fact). Fable 5.2 consult agreed (B2).
  • Production lines are net positive (src non-test +68 / −38). The cause is missing code: HTTP had no admission at all. The addition is one admission call site; I did not add a flag, hook or state.
  • Admission facts: recorded facts with the request's scopes (Fable A1), not person facts (["operator.admin"]). person would ignore a narrowing x-openclaw-scopes header on a private mode="none" Gateway (widening). Shared secret gets the CLI default set (admin included), so its grant is the full owner grant, the same as a Control UI token turn that requests admin.
  • Device-token and scoped credentials get their own scopes, never more: non-owner HTTP credentials go through the unchanged producer with their role-capped scopes.
  • Known seam: pre-run request authorization on HTTP (model override, incognito session selection, managed image owner check) still reads scopes.includes(operator.admin). It agrees with grant.owner because both come from the same request scopes. Moving those to the grant is request admission (OA3), not this PR.
  • Accepted edge: if the owner profile row cannot be resolved during HTTP auth (state store failure, already logged as owner profile resolution failed), the request is not admitted and runs without owner tools. Before, it ran as System with owner tools.
  • MCP HTTP: not changed. The loopback MCP owner token is minted for the parent turn and carries that turn's owner bit; it is not the shared Gateway credential (Fable 3(i) in PR 5).
  • Queued replay: an admitted HTTP owner turn records no recovery source (unavailable), same as before (no authority at all). Its live queue custody uses the in-memory admitted authority.

User impact

  • An HTTP request with the shared Gateway token or password now has the same grant as the owner's Control UI turn with that token: owner-only tools, GitHub PR actions and skill authoring, decided by the one admission owner.
  • A trusted-proxy (or device) identity without admin still gets only its own scopes; an owner-only tool is refused visibly.

Evidence

  • Red on base 4369ec1e2a91, green on head (operator-admission.table.test.ts, real Gateway, real HTTP auth with the shared token, real chat queue custody and replay admission): cell OWNER x http-bearer expects the owner grant {owner: true, skillAuthoring: true, questionReplace: true, commands: "all"} (the same grant a channel owner principal gets). Base gives {fresh: undefined, replay: []} (no admitted authority: System). Head: 154/154 in the table + cron-regression run.
  • Unit: openai-compatible-agent-run.test.ts admits a token owner (scopes with admin → owner grant, senderIsOwner true) and a private none owner that narrows to operator.write (owner false: no widening).
  • Lint: test/scripts/oxlint-boundary-guards.test.ts green with OWNER_PRODUCER_FILES ceiling 50.
  • Pre-push: one ocx test call over 122 files (touched tests + every test importing a changed source or test-support file, OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1): 1 OURS failure fixed (http-session-control.incognito.test.ts relied on the deleted owner → [operator.admin] mapping; it now passes the scopes the real callers pass; 6/6 green). src/cron/service.pr-automation*.test.ts fail identically on base 4369ec1e2a91 (Cannot destructure property 'previous' of 'trigger.state', 19/20 red on base): not this change. pnpm tsgo:core and pnpm tsgo:test clean; oxfmt and oxlint clean on changed files.
  • Production lines (src, non-test): +68 / −38 (see Decisions).
  • E2E: on exact head 8ca58ec58b32, isolated Gateways, live Peanutto Gateway pid unchanged.
    • one-admission-e2e/run.sh (live gpt-5.5): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels: all pass (verdict.json + results.jsonl kept in the task proof directory).
    • HTTP /tools/invoke (trusted-proxy Gateway with a local password fallback): the shared password calls the owner-only sessions tool (owner_profiles): 200 ok, result lists the gateway-owner profile. A trusted-proxy identity with the worker role (read + write, no admin) calls the same tool: 404 {"type":"not_found","message":"Tool not available: sessions"}.

…ncipal

- OpenAI-compatible runs and /tools/invoke admit the request once through decideOperatorAdmission
  (owner credential) or the existing producer (person/OpenClaw ID), and read grant.owner.
- Delete the tools-invoke owner -> [operator.admin] client mapping and the HTTP-layer owner producer.
- Matrix: HTTP shared-token cell equals the owner grant (red on base).

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: M labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 8ca58ec58b3217676bc975bf4282e90335e90748
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/operator-run-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. labels Nov 25, 2026
@obviyus
obviyus merged commit da49415 into main Nov 25, 2026
155 checks passed
@obviyus
obviyus deleted the refactor/oa2-http-grant branch November 25, 2026 05:17
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as da49415. HTTP requests with the shared Gateway token or password are now admitted once as the Gateway owner, with the same turn grant as the owner's Control UI turn; other HTTP credentials keep their own scopes. Proof: matrix cell OWNER x http-bearer red on base, green on head; Q/R/S E2E pass; isolated-Gateway /tools/invoke: owner-only sessions tool 200 with the shared password, 404 for a non-admin trusted-proxy identity.

obviyus added a commit that referenced this pull request Nov 25, 2026
…205173)

## Problem

OA2 PR 4c, steps 1 and 2 (DESIGN §2, PR 4b leftovers from #205082). The same owner got a different automations answer depending on how the turn started:

- **An authless local socket had no admitted authority.** On a `gateway.auth.mode: "none"` Gateway, a local client (CLI, local Control UI) was never admitted through `decideOperatorAdmission`, so its turn carried no grant. Its automation rights came from a transport check instead.
- **Automation management was decided outside admission, from the transport.** The cron-creator classifier gave `manage` only to `operator.admin` **and** (local socket **or** Control UI admin **or** native-app admin). The same owner over a remote CLI, TUI or any other client got only caller-scoped creation. `operator.cron` was read from raw connect scopes, not from the admitted grant.
- **Children got nothing.** A subagent child of an owner turn had no automation rights at all (fresh-turn gate), so "update my automation" worked from the parent and failed from its subagent.
- **The channel-owner cron mint ignored the admitted grant.** A configured owner linked to a personal profile was admitted as that profile (#204904), but the mint still gave full management from the owner list.

## Fix

- **`grant.automations`** (`"none" | "self" | "manage"`) is decided once in `decideTurnGrant`: `manage` iff the grant is owner (`operator.admin`), `self` iff `operator.cron` (or `operator.write`, which covers it), else `none`.
- **Local-host principal:** an authless local operator socket (`authMethod: "none"`, handshake-attested direct-local, no named-profile actor, not an agent runtime) is admitted through `decideOperatorAdmission` as the owner principal with its own connect scopes — the same admission an HTTP `mode: "none"` owner request already uses (#205091). The HTTP owner path and the socket path now share one helper. Like every other socket path, the admitted run keeps the request's invocation ceiling and lifetime (`retainGatewayOperatorInvocation`: delegated-child participation ceiling, invocation signal and release).
- **Classifier reads the grant.** `cron-creator-authority-admission.ts` keeps only the turn-shape gate (fresh direct input, not system, not handoff). The rights come from `grant.automations`. Deleted: the `operator.admin` + `isLocalClient`/UI-admin/native-app-admin rule, the raw `operator.cron` connect-scope read, and the Template setup `controlUiAdmin` + admin check (it now requires a `manage` grant).
- **`localClient` / `uiAdminSource` settled:** deleted from the manage rule. An owner's remote and local browser (and CLI, TUI, native app) get the same `manage`. The management entitlement source collapses to `"operator" | "channel-owner"`; `resolveGatewayUiAdminSource` becomes the boolean `isGatewayUiAdmin` (its labels had no reader left). Local-host stays only as **job provenance** (`callerOrigin: local`, already stored on jobs) for a `manage` turn on a direct-local socket; it grants nothing more.
- **Children:** a subagent child (`lane: "subagent"`) gets the automations of its own admitted grant: the parent's authority, re-admitted at launch and capped by the child launch's operator scopes (`operator.write`). An owner's or writer's child gets `self`; a child of a read-only or unadmitted parent gets `none`.
- **Channel-owner mint:** a channel turn with an admitted operator authority mints channel-owner management only when its grant is `manage`.
- **Deleted:** the expired (2026-10-12) `controlUiAdmin` harness getter on the creator capability, and the `controlUiAdmin` admission output (no production reader).
- Docs: `automation/cron-jobs/managing-jobs.md` conversational management.

## Decisions (recorded, not asked)

- **Deliberate widenings (same principal, same answer):**
  - An owner on a remote non-UI client (remote CLI, TUI) now manages every automation, like the owner's Control UI. That socket already holds `operator.admin`, so it can already call every `cron.*` method directly; only the model's tool gains reach.
  - A local CLI owner now also gets the management entitlement (it already had the local creator origin).
  - **Subagent children get the parent's re-admitted automations right** (MATRIX M9). Before, a child had none. A child never exceeds its parent. It does not reach `manage`: the in-process child launch carries `operator.write`, which caps the child's admitted grant at `self`. Lifting that cap is a launch-scope change, not an automations rule; not in this PR.
- **Narrowing (brief rule, #204904):** a configured `commands.ownerAllowFrom` owner whose verified channel identity is linked to a non-admin personal profile now gets that profile's automations, not channel-owner management.
- **Asserted-identity owners keep today's mint.** Signal/WhatsApp/iMessage owners are not admitted through `decideOperatorAdmission` (DESIGN §10, D23): they have no grant to read. Cutting their mint would remove automation management they have today, so the mint still applies when there is no admitted grant. Closing that needs the D23 decision, not this PR.
- **Accepted edge:** an authless Gateway that also configures named roles has no owner profile at startup; a local socket turn there is now refused at admission. `mode: "none"` with named roles has no identities to apply roles to, so this combination is not a working setup.
- **Split (brief rule: over ~25 files → land steps 1–2 first).** 37 files. Steps 3 (in-session scheduled scope into admission, delete the `automations-run-scope.ts` trigger fallback) and 4 (split the pre-start session-event config check out of the `attempt-session-target.ts` source, delete the R7 re-check) go in the next PR. The replay `automationAdmin` output (saved UI-admin delegation) stays with step 3: it decides what an in-session scheduled run gets.

## User impact

- The owner manages automations from chat the same way from any client, including a local client of an authless Gateway.
- A subagent of an owner or writer turn can create and edit its own automations.
- A channel owner linked to a non-admin profile manages only their own automations from that channel.

## Evidence

- **Production lines** (`src`, non-test): +77 / −78 (net −1)..
- **Red on base, green on head:**
  - `message-handler.post-connect-health.test.ts` "admits an authless local socket as the local host": real WS handshake on an authless Gateway, real `prepareGatewayOperatorRunAuthority` → owner profile, `grant.automations: "manage"`. Base returns no authority.
  - Same file, trusted-proxy person over `openclaw-tui` with `operator.admin`: head gets management through the grant; base gave caller-scoped only.
  - `agent-run-local-operator-authority.test.ts`: remote Control UI, native app and CLI owners get the same management; a subagent child gets automations from its admitted grant; a local-host admission keeps the request's invocation signal and release (local review round 2).
  - `operator-admission.table.test.ts`: matrix grants carry `automations` (owner `manage`, writer `self`) for every entry kind.
- **Pre-push:** (1) one `ocx test` call over 125 files (touched tests plus importers of every changed source/test-support), then (2) one frozen-tree `ocx test` call over the 32 touched/re-run files: all green except `src/cron/service.pr-automation.test.ts`, which fails the same way on the merge base `529e37f3a53a` (13 failed on base, `ocx base merge-base`). `pnpm tsgo:core` and `tsgo:core:test` clean; oxfmt/oxlint clean; line-cap ratchet OK. `pnpm check:changed`: all lanes ok except two that fail on files this PR does not touch (changelog attribution in `CHANGELOG/2026.11.10.md`; Knip unused exports in `update-cli`, `schtasks-process`, `upgrade-survivor`).
- **E2E:** see the follow-up comment (Q/R/S on the exact head).

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 25, 2026
…ant (#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 (#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 #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 `71b629c5f86e`, 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 `71b629c5f86e` (`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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…ncipal (openclaw#205091)

## Problem

OA2 PR 5b (DESIGN §9, HTTP half of row 5). The same person got a different answer depending on how the turn started:

- A Control UI turn signed in with the shared Gateway token or password is admitted as the Gateway owner: it carries an admitted operator authority whose grant gives owner-only tools, GitHub PR actions, skill authoring and question replacement.
- An OpenAI-compatible (`/v1/chat/completions`, `/v1/responses`) or `/tools/invoke` request with the **same** token or password was never admitted. It ran as System with no turn grant. Owner status was produced a second time in the HTTP layer (`scopes.includes(operator.admin)`), and `/tools/invoke` mapped owner to a client with only `[operator.admin]`. Anything that reads the admitted grant (PR actions, skill authoring, session controls) saw no grant.

## Fix

- New `prepareGatewayHttpOperatorRunAuthority` (HTTP-only, next to the Control UI producer in `operator-run-authority.ts`): a request whose credential names the Gateway owner (shared token or password, or private `mode="none"`) is admitted through `decideOperatorAdmission` with the transport facts (owner profile + the request's own scopes). Every other HTTP credential (trusted-proxy person, OpenClaw ID member/owner) keeps the existing producer, unchanged.
- OpenAI-compatible runs and `/tools/invoke` both use it. `senderIsOwner` for the turn is now `authority.grant.owner`; the tool request scope carries the admitted authority.
- Deleted: the `/tools/invoke` owner → `[operator.admin]` client mapping (`tools-invoke-shared.ts`), the `senderIsOwner` parameter of `runOpenAiCompatibleAgentCommand`, and the HTTP-layer owner producer in `tools-invoke-http.ts`.
- Lint: `OWNER_PRODUCER_FILES` 51 → 50 (`tools-invoke-http.ts` leaves). No new allowlist entries.
- Docs: OpenAI, OpenResponses and tools-invoke pages say what a shared-token request may do.

## Decisions (recorded, not asked)

- **Cut less: `resolveSharedSecretHttpOperatorScopes` stays.** It is not a turn-only restore: models, embeddings, managed images and session history read it, and "shared secret ignores `x-openclaw-scopes`" is the documented HTTP contract. Session kill deliberately refuses the shared secret through the other scope path. Readers go before the source; changing that contract is its own security PR. The turn's grant now comes from admission; this function only gathers the request's scopes (fact). Fable 5.2 consult agreed (B2).
- **Production lines are net positive** (src non-test +68 / −38). The cause is missing code: HTTP had no admission at all. The addition is one admission call site; I did not add a flag, hook or state.
- **Admission facts:** `recorded` facts with the request's scopes (Fable A1), not `person` facts (`["operator.admin"]`). `person` would ignore a narrowing `x-openclaw-scopes` header on a private `mode="none"` Gateway (widening). Shared secret gets the CLI default set (admin included), so its grant is the full owner grant, the same as a Control UI token turn that requests admin.
- **Device-token and scoped credentials get their own scopes, never more:** non-owner HTTP credentials go through the unchanged producer with their role-capped scopes.
- **Known seam:** pre-run request authorization on HTTP (model override, incognito session selection, managed image owner check) still reads `scopes.includes(operator.admin)`. It agrees with `grant.owner` because both come from the same request scopes. Moving those to the grant is request admission (OA3), not this PR.
- **Accepted edge:** if the owner profile row cannot be resolved during HTTP auth (state store failure, already logged as `owner profile resolution failed`), the request is not admitted and runs without owner tools. Before, it ran as System with owner tools.
- **MCP HTTP:** not changed. The loopback MCP owner token is minted for the parent turn and carries that turn's owner bit; it is not the shared Gateway credential (Fable 3(i) in PR 5).
- **Queued replay:** an admitted HTTP owner turn records no recovery source (`unavailable`), same as before (no authority at all). Its live queue custody uses the in-memory admitted authority.

## User impact

- An HTTP request with the shared Gateway token or password now has the same grant as the owner's Control UI turn with that token: owner-only tools, GitHub PR actions and skill authoring, decided by the one admission owner.
- A trusted-proxy (or device) identity without admin still gets only its own scopes; an owner-only tool is refused visibly.

## Evidence

- **Red on base `1686137e00b6`, green on head** (`operator-admission.table.test.ts`, real Gateway, real HTTP auth with the shared token, real chat queue custody and replay admission): cell `OWNER x http-bearer` expects the owner grant `{owner: true, skillAuthoring: true, questionReplace: true, commands: "all"}` (the same grant a channel owner principal gets). Base gives `{fresh: undefined, replay: []}` (no admitted authority: System). Head: 154/154 in the table + cron-regression run.
- **Unit:** `openai-compatible-agent-run.test.ts` admits a `token` owner (scopes with admin → owner grant, `senderIsOwner` true) and a private `none` owner that narrows to `operator.write` (owner false: no widening).
- **Lint:** `test/scripts/oxlint-boundary-guards.test.ts` green with `OWNER_PRODUCER_FILES` ceiling 50.
- **Pre-push:** one `ocx test` call over 122 files (touched tests + every test importing a changed source or test-support file, `OPENCLAW_NODE_TEST_PLAN_CONTINUE_ON_FAILURE=1`): 1 OURS failure fixed (`http-session-control.incognito.test.ts` relied on the deleted owner → `[operator.admin]` mapping; it now passes the scopes the real callers pass; 6/6 green). `src/cron/service.pr-automation*.test.ts` fail identically on base `1686137e00b6` (`Cannot destructure property 'previous' of 'trigger.state'`, 19/20 red on base): not this change. `pnpm tsgo:core` and `pnpm tsgo:test` clean; oxfmt and oxlint clean on changed files.
- **Production lines** (`src`, non-test): +68 / −38 (see Decisions).
- **E2E:** on exact head `8ca58ec58b32`, isolated Gateways, live Peanutto Gateway pid unchanged.
  - `one-admission-e2e/run.sh` (live `gpt-5.5`): Q queued input refused visibly, R running turn finishes after revoke, S Stop cancels: all pass (`verdict.json` + `results.jsonl` kept in the task proof directory).
  - HTTP `/tools/invoke` (trusted-proxy Gateway with a local password fallback): the shared password calls the owner-only `sessions` tool (`owner_profiles`): `200 ok`, result lists the `gateway-owner` profile. A trusted-proxy identity with the `worker` role (read + write, no admin) calls the same tool: `404 {"type":"not_found","message":"Tool not available: sessions"}`.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…penclaw#205173)

## Problem

OA2 PR 4c, steps 1 and 2 (DESIGN §2, PR 4b leftovers from openclaw#205082). The same owner got a different automations answer depending on how the turn started:

- **An authless local socket had no admitted authority.** On a `gateway.auth.mode: "none"` Gateway, a local client (CLI, local Control UI) was never admitted through `decideOperatorAdmission`, so its turn carried no grant. Its automation rights came from a transport check instead.
- **Automation management was decided outside admission, from the transport.** The cron-creator classifier gave `manage` only to `operator.admin` **and** (local socket **or** Control UI admin **or** native-app admin). The same owner over a remote CLI, TUI or any other client got only caller-scoped creation. `operator.cron` was read from raw connect scopes, not from the admitted grant.
- **Children got nothing.** A subagent child of an owner turn had no automation rights at all (fresh-turn gate), so "update my automation" worked from the parent and failed from its subagent.
- **The channel-owner cron mint ignored the admitted grant.** A configured owner linked to a personal profile was admitted as that profile (openclaw#204904), but the mint still gave full management from the owner list.

## Fix

- **`grant.automations`** (`"none" | "self" | "manage"`) is decided once in `decideTurnGrant`: `manage` iff the grant is owner (`operator.admin`), `self` iff `operator.cron` (or `operator.write`, which covers it), else `none`.
- **Local-host principal:** an authless local operator socket (`authMethod: "none"`, handshake-attested direct-local, no named-profile actor, not an agent runtime) is admitted through `decideOperatorAdmission` as the owner principal with its own connect scopes — the same admission an HTTP `mode: "none"` owner request already uses (openclaw#205091). The HTTP owner path and the socket path now share one helper. Like every other socket path, the admitted run keeps the request's invocation ceiling and lifetime (`retainGatewayOperatorInvocation`: delegated-child participation ceiling, invocation signal and release).
- **Classifier reads the grant.** `cron-creator-authority-admission.ts` keeps only the turn-shape gate (fresh direct input, not system, not handoff). The rights come from `grant.automations`. Deleted: the `operator.admin` + `isLocalClient`/UI-admin/native-app-admin rule, the raw `operator.cron` connect-scope read, and the Template setup `controlUiAdmin` + admin check (it now requires a `manage` grant).
- **`localClient` / `uiAdminSource` settled:** deleted from the manage rule. An owner's remote and local browser (and CLI, TUI, native app) get the same `manage`. The management entitlement source collapses to `"operator" | "channel-owner"`; `resolveGatewayUiAdminSource` becomes the boolean `isGatewayUiAdmin` (its labels had no reader left). Local-host stays only as **job provenance** (`callerOrigin: local`, already stored on jobs) for a `manage` turn on a direct-local socket; it grants nothing more.
- **Children:** a subagent child (`lane: "subagent"`) gets the automations of its own admitted grant: the parent's authority, re-admitted at launch and capped by the child launch's operator scopes (`operator.write`). An owner's or writer's child gets `self`; a child of a read-only or unadmitted parent gets `none`.
- **Channel-owner mint:** a channel turn with an admitted operator authority mints channel-owner management only when its grant is `manage`.
- **Deleted:** the expired (2026-10-12) `controlUiAdmin` harness getter on the creator capability, and the `controlUiAdmin` admission output (no production reader).
- Docs: `automation/cron-jobs/managing-jobs.md` conversational management.

## Decisions (recorded, not asked)

- **Deliberate widenings (same principal, same answer):**
  - An owner on a remote non-UI client (remote CLI, TUI) now manages every automation, like the owner's Control UI. That socket already holds `operator.admin`, so it can already call every `cron.*` method directly; only the model's tool gains reach.
  - A local CLI owner now also gets the management entitlement (it already had the local creator origin).
  - **Subagent children get the parent's re-admitted automations right** (MATRIX M9). Before, a child had none. A child never exceeds its parent. It does not reach `manage`: the in-process child launch carries `operator.write`, which caps the child's admitted grant at `self`. Lifting that cap is a launch-scope change, not an automations rule; not in this PR.
- **Narrowing (brief rule, openclaw#204904):** a configured `commands.ownerAllowFrom` owner whose verified channel identity is linked to a non-admin personal profile now gets that profile's automations, not channel-owner management.
- **Asserted-identity owners keep today's mint.** Signal/WhatsApp/iMessage owners are not admitted through `decideOperatorAdmission` (DESIGN §10, D23): they have no grant to read. Cutting their mint would remove automation management they have today, so the mint still applies when there is no admitted grant. Closing that needs the D23 decision, not this PR.
- **Accepted edge:** an authless Gateway that also configures named roles has no owner profile at startup; a local socket turn there is now refused at admission. `mode: "none"` with named roles has no identities to apply roles to, so this combination is not a working setup.
- **Split (brief rule: over ~25 files → land steps 1–2 first).** 37 files. Steps 3 (in-session scheduled scope into admission, delete the `automations-run-scope.ts` trigger fallback) and 4 (split the pre-start session-event config check out of the `attempt-session-target.ts` source, delete the R7 re-check) go in the next PR. The replay `automationAdmin` output (saved UI-admin delegation) stays with step 3: it decides what an in-session scheduled run gets.

## User impact

- The owner manages automations from chat the same way from any client, including a local client of an authless Gateway.
- A subagent of an owner or writer turn can create and edit its own automations.
- A channel owner linked to a non-admin profile manages only their own automations from that channel.

## Evidence

- **Production lines** (`src`, non-test): +77 / −78 (net −1)..
- **Red on base, green on head:**
  - `message-handler.post-connect-health.test.ts` "admits an authless local socket as the local host": real WS handshake on an authless Gateway, real `prepareGatewayOperatorRunAuthority` → owner profile, `grant.automations: "manage"`. Base returns no authority.
  - Same file, trusted-proxy person over `openclaw-tui` with `operator.admin`: head gets management through the grant; base gave caller-scoped only.
  - `agent-run-local-operator-authority.test.ts`: remote Control UI, native app and CLI owners get the same management; a subagent child gets automations from its admitted grant; a local-host admission keeps the request's invocation signal and release (local review round 2).
  - `operator-admission.table.test.ts`: matrix grants carry `automations` (owner `manage`, writer `self`) for every entry kind.
- **Pre-push:** (1) one `ocx test` call over 125 files (touched tests plus importers of every changed source/test-support), then (2) one frozen-tree `ocx test` call over the 32 touched/re-run files: all green except `src/cron/service.pr-automation.test.ts`, which fails the same way on the merge base `2e167172fe19` (13 failed on base, `ocx base merge-base`). `pnpm tsgo:core` and `tsgo:core:test` clean; oxfmt/oxlint clean; line-cap ratchet OK. `pnpm check:changed`: all lanes ok except two that fail on files this PR does not touch (changelog attribution in `CHANGELOG/2026.11.10.md`; Knip unused exports in `update-cli`, `schtasks-process`, `upgrade-survivor`).
- **E2E:** see the follow-up comment (Q/R/S on the exact head).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:security Security boundary, credential, authz, sandbox, or sensitive-data risk. P1 High-priority user-facing bug, regression, or broken workflow. scripts Repository scripts security-sensitive-changed size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant