Repository navigation
refactor(gateway): decide automations rights once, as the turn grant - #205173
Conversation
- add grant.automations (none/self/manage) to the turn grant: manage iff owner, self iff operator.cron - admit an authless local socket (auth mode none) as the local-host principal through decideOperatorAdmission - the cron-creator classifier, Template setup and the channel-owner mint read the admitted grant; drop the local/UI-admin transport rule - a subagent child gets automations from its own re-admitted grant - delete the expired controlUiAdmin harness getter and the unread controlUiAdmin admission output 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. |
|
|
E2E on exact head
|
…n participation recovery - main added a restored-authority literal with the controlUiAdmin field this branch removes - requester-custody fixture passes the admitted grant to the chat classifier (local review round 1) Co-authored-by: obviyus <[email protected]>
|
Codex review: needs changes before merge. What this changesThis PR makes automation permissions come from the admitted turn grant across Gateway clients, subagents, and configured channel owners. Example: An authenticated remote CLI owner with operator.admin asks to disable a Telegram-created reminder.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this maintainer-authorized consolidation is useful, but current-head CI exposes a missed consumer-fixture update. Reviewed head: Before merge
Findings
Tests
Agent review detailsHow this fits togetherGateway admission converts authenticated identity and scope facts into a turn grant; agent and chat entry points translate that grant into run-bound capabilities consumed by automation tools. flowchart TD
A[Authenticated client or channel sender] --> B[Operator admission]
B --> C[Turn grant]
C --> D[Agent and chat admission]
C --> E[Subagent admission]
D --> F[Run bound automation capability]
E --> F
F --> G[Cron tools and Gateway methods]
Technical reviewBest possible solution: Keep the existing admission owner and grant-based classifier, and migrate the direct-agent test fixture to carry admitted authority while preserving its capability-lifecycle assertions. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the remote-client and subagent permission differences, and exact-head CI independently demonstrates the unmigrated direct-agent fixture; no target code was executed during this review. Is this the best way to solve the issue? Using the existing turn-admission owner is the smallest coherent solution: it removes duplicate permission policy, shares owner admission between HTTP and local sockets, and preserves the separately documented scheduled-recovery follow-up. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 14db7f3bf34a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -2, Tests +18, Docs 0. Total +16 across 43 files. Added test files: 0. 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. Review metrics
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, 2:50 AM ET / 07:50 UTC. |
- an authless local socket's admitted run keeps the request's invocation ceiling, signal and release, like every other socket path (local review round 2) - the direct local agent RPC fixture carries its admitted owner authority Co-authored-by: obviyus <[email protected]>
|
E2E on exact head
|
…205206) > Lint-precision prerequisite for the owner-producer sweep. It moves no owner producer onto `grant.owner`; the sweep itself is parked as area PRs (see "Not in this PR"). ## Problem `no-turn-authority-derivation` (owner-production check) flagged 49 files as owner producers. 16 of them do not produce owner status: they only narrow a bit that was passed along (`x.senderIsOwner === true`, `admin ? request.senderIsOwner === true : false`, `profile === "full" ? params.senderIsOwner : undefined`, `input.senderIsOwner && externalUser`, a getter that returns `ctx.senderIsOwner`). Because they were listed, the allowlist overstated the work left and gave no reason for any entry. ## Fix - `passesOwnerAlong` now accepts the forms that cannot make an owner: `<pass> === true`, a conditional whose two branches pass along, `a && b` with one side passing along, `a || b` / `a ?? b` with both sides passing along, and a property getter whose only statement returns a pass-through. Defaults that make an owner (`x ?? true`, `x !== false`) and function or method values (truthy whatever they return) still fail (fixture lines 32-41). - `OWNER_PRODUCER_FILES` 49 → 33 (ceiling lowered). Every remaining entry is grouped with its reason: - principals admission does not see yet (Discord native/voice owner match, FaceTime caller claim, plugin ingress trust gate, CLI `--local`/`message`, standalone MCP, MCP loopback token, worker placement); - requests, not turns (OpenAI-compatible HTTP pre-run check, `conversations`, `tools.invoke`, session resource tools, Talk client tools): owner = connection admin scope, to move with the OA3 request grant; - channel command owner (`command-auth`, reply execute/source admission, message-action dispatch, `agent-run-user-turn` channel requester); - scheduled and requester-owner continuations (cron creator authority, scheduled targets, plugin tool owner continuation); - recorded data read back (protocol schema field, transcript metadata, memory lineage receipt, maintenance copy). No production code changes. `TURN_FLAG_FILES` (19), `ADMISSION_FILES` (59) and `CAPABILITY_PROVENANCE_FILES` (4) are unchanged; all lists stay shrink-only. ## Not in this PR (split) The real owner moves need principals or grants that do not exist yet, or files another open PR owns: - `automationAdmin`/`controlUiAdmin` and the cron creator `requesterOwner` continuation: owned by open OA2 PR 4c (#205173). - CLI `--local`, `message`, standalone MCP, worker: need the `local-host` principal that PR 4c adds. - RPC/HTTP request sites: need the OA3 request grant from method authorization. - Channel command owner and Discord native/voice: next channel PR, after 4c lands. ## User impact None. Lint tooling only. ## Evidence - `test/scripts/oxlint-boundary-guards.test.ts`: 35/35 pass, including the stale-entry check (every listed file still trips the rule) and the new fixture lines. - E2E Q/R/S pass (`one-admission-e2e/run.sh`, head `5d33e525`; the follow-up commit only changes the lint rule, no product code): `verdict.json` pass=true, `R.running-turn-finishes`, `Q.queued-input-refused-visibly`, `S.stop-cancels`. - Before/after `ignoreAllowlists` run over all 49 listed files: 16 stop tripping, 33 still do. Co-authored-by: Ayaan Zaidi <[email protected]>
|
Landed as 5e3065e.
|
…#205255) ## Problem OA2 PR 6a (one admission owner). Processes the operator runs on this host each decided "the sender is the owner" for themselves: - `openclaw agent --local` (and `agent exec`, BOOT.md, Template setup): `senderIsOwner: opts.senderIsOwner ?? true`. - `openclaw message`: `senderIsOwner: opts.senderIsOwner !== false`. - Codex supervision stdio MCP: a private `{ senderIsOwner: true }` constant. - MCP loopback: `{ senderIsOwner: ownerTokenMatched }`, where the alternative was a raw non-owner token that no production code ever hands out. These were four more owner producers outside admission (`OWNER_PRODUCER_FILES`). ## Fix - `operator-admission.ts` exports `LOCAL_HOST = { grant: decideTurnGrant(["operator.admin"]) }`: the local host is the owner principal, and `decideTurnGrant` decides its grant. The four entries read `LOCAL_HOST.grant.owner`. - `agent-command-local.ts`: no caller option narrows the local owner (no production caller set it). The local cron-creator capability is now gated only by `operatorAuthority`, because the `senderIsOwner === true` check is always true. - MCP loopback: deleted the unused raw non-owner token (`nonOwnerToken` in the runtime, listener and request auth). CLI backends get run-bound client grants; attach clients get attach grants. Only the in-process owner token remains, and it names the local host. - `OWNER_PRODUCER_FILES` 32 → 28 after merging main (ceiling lowered). ## Decisions (recorded, not asked) - **Worker placement stays listed** (`src/worker/embedded-agent.runtime.ts`). The worker runs tools on a separate box for a run the Gateway admitted. The correct value is that run's `grant.owner`, and the worker protocol does not carry it. `LOCAL_HOST` there would declare every remote box an owner. Carrying the bit is a protocol change, so it is not in this PR (Fable 5.2 consult). - **No full `decideOperatorAdmission` for in-process local runs.** It would set `operatorAuthority` on CLI-local runs and change many downstream branches. It would also need the profile store in the stdio MCP and the worker. The grant comes from the same `decideTurnGrant`. - **Raw non-owner MCP token deleted, not kept.** Only `mcp-http.ts` created it and only `resolveMcpSender` compared it; no production path hands it to a client (CLI backends use run-bound client grants, `attach` uses attach grants). Deleting it closes no client route. Without it the owner-token producer could not move, and production would not be net negative. - **Accepted risk:** any file can import `LOCAL_HOST` and pass the owner lint. Today it has four readers; adding an import allowlist would be a new guard. ## User impact None. A local CLI user, the `message` CLI, the standalone Codex supervision MCP and the in-process MCP owner token stay owner. ## Evidence - Production (`src`, non-test): +18 / −21. - One cell per entry, through the real entry function: - `agent-command-local.test.ts`: every local run reaches preparation with `senderIsOwner: true`; the operator run gets the local cron-creator capability. - `message.test.ts`: the `message` CLI dispatches with `senderIsOwner: true`. - `plugin-tools-serve.test.ts`: Codex supervision MCP context has `senderIsOwner: true`. - `mcp-http.test.ts`: a real loopback listener request with the owner token resolves tools with `senderIsOwner: true`. - `test/scripts/oxlint-boundary-guards.test.ts`: ceiling 28; the stale-entry check passes for the four removed files. - Real `openclaw agent --local` on an isolated profile (`ocx src -- --profile e2e`), real `openai/gpt-5.5`: the model called the owner-only `sessions` tool and replied `LOCAL_OWNER_DONE 0`; exit 0. - Pre-push checks: one `ocx test` call over 62 files (touched tests plus direct importers of every changed source; the 318-file set with test-support importers is over the 150 cap), all green. `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt and oxlint on changed files: clean. `pnpm check:changed`: the changelog attribution lane fails on files this PR does not touch (same as #205173); the rest was still running at 15 min, so CI runs it. - Q/R/S E2E on the exact head: see the follow-up comment. Co-authored-by: Ayaan Zaidi <[email protected]>
…ource re-check (#205268) ## Problem OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps #205173 split off). Two places still decided what a running scheduled turn may do outside admission: - **Replay `automationAdmin` output.** `decideOperatorAdmission` returned a second owner-like bit for replays: admin scope **and** a saved Control UI delegation. In-session scheduled runs (`runCronSessionTurn`) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job. - **R7 mid-run re-check (`source_authority_refused`).** The prepared session target in `attempt-session-target.ts` re-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused with `source_authority_refused` (REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start. ## Fix - `automationAdmin` is deleted from the admission decision, `RestoredGatewayOperatorAuthority`, `ScheduledSessionAutomation` and the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (`grant.owner`), the same rule restart and owner continuations already use. - `createPreparedSessionTargetAssertion` no longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (`assertScopeCurrent`), and the session row predicates still reach the writer through `composeSessionSourceAssertion`. - **Pre-start session-event config check:** no split code needed. The session-event config policy already stops at `start()`; before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target. ## Decisions (recorded, not asked) - **Widening (same principal, same answer):** an in-session scheduled run whose restored requester is an admin now binds command-owner authority even when the job was created outside the Control UI (remote CLI, TUI, native app). Same rule as #205173 for `grant.automations`. - **Stored rows unchanged:** the codec keeps writing/reading `automationAdmin`/`controlUiAdmin` on saved sources (no stored-row change); `hasAutomationAdminDelegation` keeps its two non-admission readers (`cron-job-turn-target.ts`, the control-edit refresh in `cron-operator-source.ts`). - **Cut less: the `automations-run-scope.ts` trigger fallback stays.** Every Gateway occurrence is admitted through `admitScheduledOccurrence`, but when that admission fails (`status: "fail"`), `bind()` binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here. - **Accepted edge (AGENTS.md "a started request may finish"):** an operator whose access is revoked mid-run no longer has the run's transcript/context writes refused; Stop and the run lifetime still end it. ## Tests - Deleted (assert removed behavior): `run-attempt-dispatch.owner` "policy" case (mid-run access-policy revoke → `source_authority_refused`); `operator-run-recovery.native` "preserves legacy browser grants…" (only asserted the deleted `automationAdmin` output). - Changed: `run-attempt-dispatch.owner` now applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (`scope_authority_refused`). `run.operator-continuation` and `execution-context-owner-authority` fixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback. ## Evidence - **Production lines** (`src`, non-test): +12 / −38 (net −26). - **Red on base, green on head:** `run-attempt-dispatch.owner.test.ts` invalidation cases now assert the prepared target never calls the run's source (`assertSourceCurrent` not called). On base the same case asserted it was called once (`toHaveBeenCalledOnce`), i.e. the R7 mid-run re-check. - **Pre-start refusal kept:** `session-run.session-model-strictness.integration.test.ts` "selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence with `status: "error"`, `executionStarted: false` and zero provider requests; the error now names the policy (`Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…`). - **Scheduled scope:** `run.operator-continuation` (36/36, incl. self-removal and `next_check`) and `execution-context-owner-authority` (embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway. - **Pre-push:** one `ocx test` call over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools with `trigger`/`jobId`): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green. `pnpm tsgo:core` and `tsgo:test` clean (also after rebase on `81d69df5dcea`); oxfmt/oxlint clean on changed files. - **E2E:** Q/R/S pass on both heads (`75ac48d68d24`, `4cddd31e0f21`); see the PR comments. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#205206) > Lint-precision prerequisite for the owner-producer sweep. It moves no owner producer onto `grant.owner`; the sweep itself is parked as area PRs (see "Not in this PR"). ## Problem `no-turn-authority-derivation` (owner-production check) flagged 49 files as owner producers. 16 of them do not produce owner status: they only narrow a bit that was passed along (`x.senderIsOwner === true`, `admin ? request.senderIsOwner === true : false`, `profile === "full" ? params.senderIsOwner : undefined`, `input.senderIsOwner && externalUser`, a getter that returns `ctx.senderIsOwner`). Because they were listed, the allowlist overstated the work left and gave no reason for any entry. ## Fix - `passesOwnerAlong` now accepts the forms that cannot make an owner: `<pass> === true`, a conditional whose two branches pass along, `a && b` with one side passing along, `a || b` / `a ?? b` with both sides passing along, and a property getter whose only statement returns a pass-through. Defaults that make an owner (`x ?? true`, `x !== false`) and function or method values (truthy whatever they return) still fail (fixture lines 32-41). - `OWNER_PRODUCER_FILES` 49 → 33 (ceiling lowered). Every remaining entry is grouped with its reason: - principals admission does not see yet (Discord native/voice owner match, FaceTime caller claim, plugin ingress trust gate, CLI `--local`/`message`, standalone MCP, MCP loopback token, worker placement); - requests, not turns (OpenAI-compatible HTTP pre-run check, `conversations`, `tools.invoke`, session resource tools, Talk client tools): owner = connection admin scope, to move with the OA3 request grant; - channel command owner (`command-auth`, reply execute/source admission, message-action dispatch, `agent-run-user-turn` channel requester); - scheduled and requester-owner continuations (cron creator authority, scheduled targets, plugin tool owner continuation); - recorded data read back (protocol schema field, transcript metadata, memory lineage receipt, maintenance copy). No production code changes. `TURN_FLAG_FILES` (19), `ADMISSION_FILES` (59) and `CAPABILITY_PROVENANCE_FILES` (4) are unchanged; all lists stay shrink-only. ## Not in this PR (split) The real owner moves need principals or grants that do not exist yet, or files another open PR owns: - `automationAdmin`/`controlUiAdmin` and the cron creator `requesterOwner` continuation: owned by open OA2 PR 4c (openclaw#205173). - CLI `--local`, `message`, standalone MCP, worker: need the `local-host` principal that PR 4c adds. - RPC/HTTP request sites: need the OA3 request grant from method authorization. - Channel command owner and Discord native/voice: next channel PR, after 4c lands. ## User impact None. Lint tooling only. ## Evidence - `test/scripts/oxlint-boundary-guards.test.ts`: 35/35 pass, including the stale-entry check (every listed file still trips the rule) and the new fixture lines. - E2E Q/R/S pass (`one-admission-e2e/run.sh`, head `5d33e525`; the follow-up commit only changes the lint rule, no product code): `verdict.json` pass=true, `R.running-turn-finishes`, `Q.queued-input-refused-visibly`, `S.stop-cancels`. - Before/after `ignoreAllowlists` run over all 49 listed files: 16 stop tripping, 33 still do. Co-authored-by: Ayaan Zaidi <[email protected]>
…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]>
…openclaw#205255) ## Problem OA2 PR 6a (one admission owner). Processes the operator runs on this host each decided "the sender is the owner" for themselves: - `openclaw agent --local` (and `agent exec`, BOOT.md, Template setup): `senderIsOwner: opts.senderIsOwner ?? true`. - `openclaw message`: `senderIsOwner: opts.senderIsOwner !== false`. - Codex supervision stdio MCP: a private `{ senderIsOwner: true }` constant. - MCP loopback: `{ senderIsOwner: ownerTokenMatched }`, where the alternative was a raw non-owner token that no production code ever hands out. These were four more owner producers outside admission (`OWNER_PRODUCER_FILES`). ## Fix - `operator-admission.ts` exports `LOCAL_HOST = { grant: decideTurnGrant(["operator.admin"]) }`: the local host is the owner principal, and `decideTurnGrant` decides its grant. The four entries read `LOCAL_HOST.grant.owner`. - `agent-command-local.ts`: no caller option narrows the local owner (no production caller set it). The local cron-creator capability is now gated only by `operatorAuthority`, because the `senderIsOwner === true` check is always true. - MCP loopback: deleted the unused raw non-owner token (`nonOwnerToken` in the runtime, listener and request auth). CLI backends get run-bound client grants; attach clients get attach grants. Only the in-process owner token remains, and it names the local host. - `OWNER_PRODUCER_FILES` 32 → 28 after merging main (ceiling lowered). ## Decisions (recorded, not asked) - **Worker placement stays listed** (`src/worker/embedded-agent.runtime.ts`). The worker runs tools on a separate box for a run the Gateway admitted. The correct value is that run's `grant.owner`, and the worker protocol does not carry it. `LOCAL_HOST` there would declare every remote box an owner. Carrying the bit is a protocol change, so it is not in this PR (Fable 5.2 consult). - **No full `decideOperatorAdmission` for in-process local runs.** It would set `operatorAuthority` on CLI-local runs and change many downstream branches. It would also need the profile store in the stdio MCP and the worker. The grant comes from the same `decideTurnGrant`. - **Raw non-owner MCP token deleted, not kept.** Only `mcp-http.ts` created it and only `resolveMcpSender` compared it; no production path hands it to a client (CLI backends use run-bound client grants, `attach` uses attach grants). Deleting it closes no client route. Without it the owner-token producer could not move, and production would not be net negative. - **Accepted risk:** any file can import `LOCAL_HOST` and pass the owner lint. Today it has four readers; adding an import allowlist would be a new guard. ## User impact None. A local CLI user, the `message` CLI, the standalone Codex supervision MCP and the in-process MCP owner token stay owner. ## Evidence - Production (`src`, non-test): +18 / −21. - One cell per entry, through the real entry function: - `agent-command-local.test.ts`: every local run reaches preparation with `senderIsOwner: true`; the operator run gets the local cron-creator capability. - `message.test.ts`: the `message` CLI dispatches with `senderIsOwner: true`. - `plugin-tools-serve.test.ts`: Codex supervision MCP context has `senderIsOwner: true`. - `mcp-http.test.ts`: a real loopback listener request with the owner token resolves tools with `senderIsOwner: true`. - `test/scripts/oxlint-boundary-guards.test.ts`: ceiling 28; the stale-entry check passes for the four removed files. - Real `openclaw agent --local` on an isolated profile (`ocx src -- --profile e2e`), real `openai/gpt-5.5`: the model called the owner-only `sessions` tool and replied `LOCAL_OWNER_DONE 0`; exit 0. - Pre-push checks: one `ocx test` call over 62 files (touched tests plus direct importers of every changed source; the 318-file set with test-support importers is over the 150 cap), all green. `pnpm tsgo:core`, `pnpm tsgo:test`, oxfmt and oxlint on changed files: clean. `pnpm check:changed`: the changelog attribution lane fails on files this PR does not touch (same as openclaw#205173); the rest was still running at 15 min, so CI runs it. - Q/R/S E2E on the exact head: see the follow-up comment. Co-authored-by: Ayaan Zaidi <[email protected]>
…ource re-check (openclaw#205268) ## Problem OA2 PR 4e (DESIGN §4.7 and §4.12; the two steps openclaw#205173 split off). Two places still decided what a running scheduled turn may do outside admission: - **Replay `automationAdmin` output.** `decideOperatorAdmission` returned a second owner-like bit for replays: admin scope **and** a saved Control UI delegation. In-session scheduled runs (`runCronSessionTurn`) used it to decide whether the run carries its restored operator source and binds command-owner authority. Same admin, different answer depending on which client created the job. - **R7 mid-run re-check (`source_authority_refused`).** The prepared session target in `attempt-session-target.ts` re-ran the run's whole source assertion (operator access, policy grants, session-event config) on every transcript and context write during the run, and refused with `source_authority_refused` (REFUSALS R7, seen on Peanutto). Admission already checked that source once, at start. ## Fix - `automationAdmin` is deleted from the admission decision, `RestoredGatewayOperatorAuthority`, `ScheduledSessionAutomation` and the participation path. An in-session scheduled run now binds command-owner authority iff its restored grant is owner (`grant.owner`), the same rule restart and owner continuations already use. - `createPreparedSessionTargetAssertion` no longer calls the run's source. It keeps the selected-target fence (attempt, session identity, target fields), Stop and the run lifetime (`assertScopeCurrent`), and the session row predicates still reach the writer through `composeSessionSourceAssertion`. - **Pre-start session-event config check:** no split code needed. The session-event config policy already stops at `start()`; before start, a config publication that denies the selected model is refused by the start's own model-policy check, before any provider request. The integration test now asserts that refusal instead of probing it through the prepared target. ## Decisions (recorded, not asked) - **Widening (same principal, same answer):** an in-session scheduled run whose restored requester is an admin now binds command-owner authority even when the job was created outside the Control UI (remote CLI, TUI, native app). Same rule as openclaw#205173 for `grant.automations`. - **Stored rows unchanged:** the codec keeps writing/reading `automationAdmin`/`controlUiAdmin` on saved sources (no stored-row change); `hasAutomationAdminDelegation` keeps its two non-admission readers (`cron-job-turn-target.ts`, the control-edit refresh in `cron-operator-source.ts`). - **Cut less: the `automations-run-scope.ts` trigger fallback stays.** Every Gateway occurrence is admitted through `admitScheduledOccurrence`, but when that admission fails (`status: "fail"`), `bind()` binds no context and the run still starts. The fallback is then the only thing that keeps an unadmitted hook/event turn (no sender bit, owner surface) from getting the full automations tool, and a cron turn limited to its own job. Deleting it needs the failed occurrence to carry its scope from admission (or a refused start), which is a separate change. Found while running the pre-push set (the fallback's own suite asserts the unadmitted event case); I removed it on the first head, then restored it: not patched here. - **Accepted edge (AGENTS.md "a started request may finish"):** an operator whose access is revoked mid-run no longer has the run's transcript/context writes refused; Stop and the run lifetime still end it. ## Tests - Deleted (assert removed behavior): `run-attempt-dispatch.owner` "policy" case (mid-run access-policy revoke → `source_authority_refused`); `operator-run-recovery.native` "preserves legacy browser grants…" (only asserted the deleted `automationAdmin` output). - Changed: `run-attempt-dispatch.owner` now applies each invalidation directly and asserts the prepared target never calls the run's source (red on base: base calls it once); "source-closed" refuses through the run lifetime (`scope_authority_refused`). `run.operator-continuation` and `execution-context-owner-authority` fixtures now admit occurrences / build the Codex host on the run's admitted context, as the Gateway does, so their scope comes from admission rather than the fallback. ## Evidence - **Production lines** (`src`, non-test): +12 / −38 (net −26). - **Red on base, green on head:** `run-attempt-dispatch.owner.test.ts` invalidation cases now assert the prepared target never calls the run's source (`assertSourceCurrent` not called). On base the same case asserted it was called once (`toHaveBeenCalledOnce`), i.e. the R7 mid-run re-check. - **Pre-start refusal kept:** `session-run.session-model-strictness.integration.test.ts` "selected-model-denied": a config publication during target preparation that denies the selected model still ends the occurrence with `status: "error"`, `executionStarted: false` and zero provider requests; the error now names the policy (`Scheduled model "primary/model-a" is not allowed by agents.defaults.modelPolicy.allow…`). - **Scheduled scope:** `run.operator-continuation` (36/36, incl. self-removal and `next_check`) and `execution-context-owner-authority` (embedded, Codex and CLI surfaces equal) pass with the fixtures admitting occurrences like the Gateway. - **Pre-push:** one `ocx test` call over 81 files (touched tests + importers of every changed source/test-support + every test constructing cron tools with `trigger`/`jobId`): all green on the first head; after restoring the fallback, the fallback's own suite and the affected files rerun green. `pnpm tsgo:core` and `tsgo:test` clean (also after rebase on `5279ca48bbe1`); oxfmt/oxlint clean on changed files. - **E2E:** Q/R/S pass on both heads (`75ac48d68d24`, `4cddd31e0f21`); see the PR comments. Co-authored-by: Ayaan Zaidi <[email protected]>
Release adaptation: Read the existing admitted scope ceiling for stored operator sources. Keep current recovery, requester admission, and configured channel-owner handling. Companion audit: #205173 and #205346 restructure newer admission contracts, not required for this stable repair. (cherry picked from commit 4d07855) Co-authored-by: RomneyDa <[email protected]>
Release adaptation: Select the existing turn authority as the requester source; retain stable invocation, workflow, and data fences. Companions: #205082 and #205173 affect automations, #205155 and #205184 affect channel trust, and #205232 affects reply dispatch; none is a prerequisite to selecting the already-admitted requester. (cherry picked from commit ddc8340) Co-authored-by: RomneyDa <[email protected]>
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:
gateway.auth.mode: "none"Gateway, a local client (CLI, local Control UI) was never admitted throughdecideOperatorAdmission, so its turn carried no grant. Its automation rights came from a transport check instead.manageonly tooperator.adminand (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.cronwas read from raw connect scopes, not from the admitted grant.Fix
grant.automations("none" | "self" | "manage") is decided once indecideTurnGrant:manageiff the grant is owner (operator.admin),selfiffoperator.cron(oroperator.write, which covers it), elsenone.authMethod: "none", handshake-attested direct-local, no named-profile actor, not an agent runtime) is admitted throughdecideOperatorAdmissionas the owner principal with its own connect scopes — the same admission an HTTPmode: "none"owner request already uses (refactor(gateway): admit HTTP shared-secret requests as the owner principal #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).cron-creator-authority-admission.tskeeps only the turn-shape gate (fresh direct input, not system, not handoff). The rights come fromgrant.automations. Deleted: theoperator.admin+isLocalClient/UI-admin/native-app-admin rule, the rawoperator.cronconnect-scope read, and the Template setupcontrolUiAdmin+ admin check (it now requires amanagegrant).localClient/uiAdminSourcesettled: deleted from the manage rule. An owner's remote and local browser (and CLI, TUI, native app) get the samemanage. The management entitlement source collapses to"operator" | "channel-owner";resolveGatewayUiAdminSourcebecomes the booleanisGatewayUiAdmin(its labels had no reader left). Local-host stays only as job provenance (callerOrigin: local, already stored on jobs) for amanageturn on a direct-local socket; it grants nothing more.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 getsself; a child of a read-only or unadmitted parent getsnone.manage.controlUiAdminharness getter on the creator capability, and thecontrolUiAdminadmission output (no production reader).automation/cron-jobs/managing-jobs.mdconversational management.Decisions (recorded, not asked)
operator.admin, so it can already call everycron.*method directly; only the model's tool gains reach.manage: the in-process child launch carriesoperator.write, which caps the child's admitted grant atself. Lifting that cap is a launch-scope change, not an automations rule; not in this PR.commands.ownerAllowFromowner whose verified channel identity is linked to a non-admin personal profile now gets that profile's automations, not channel-owner management.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.mode: "none"with named roles has no identities to apply roles to, so this combination is not a working setup.automations-run-scope.tstrigger fallback) and 4 (split the pre-start session-event config check out of theattempt-session-target.tssource, delete the R7 re-check) go in the next PR. The replayautomationAdminoutput (saved UI-admin delegation) stays with step 3: it decides what an in-session scheduled run gets.User impact
Evidence
src, non-test): +77 / −78 (net −1)..message-handler.post-connect-health.test.ts"admits an authless local socket as the local host": real WS handshake on an authless Gateway, realprepareGatewayOperatorRunAuthority→ owner profile,grant.automations: "manage". Base returns no authority.openclaw-tuiwithoperator.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 carryautomations(ownermanage, writerself) for every entry kind.ocx testcall over 125 files (touched tests plus importers of every changed source/test-support), then (2) one frozen-treeocx testcall over the 32 touched/re-run files: all green exceptsrc/cron/service.pr-automation.test.ts, which fails the same way on the merge base529e37f3a53a(13 failed on base,ocx base merge-base).pnpm tsgo:coreandtsgo:core:testclean; 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 inCHANGELOG/2026.11.10.md; Knip unused exports inupdate-cli,schtasks-process,upgrade-survivor).