Repository navigation
fix: native runtime setup consent ignored in owner channel chats - #185597
Conversation
…hats and subagents
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesApplies remembered native-runtime consent to owner turns with unset chat modes while preserving explicit restrictions. Example: An owner sends a Telegram message using Muse with nativeRuntimeConsent set to ["muse"] and tools.allow set to ["message"].
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes owner channel chats without broadening consent to subagents; the added channel revocation and latest-stable upgrade evidence resolves the previous review’s blockers. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway admission and agent preflight combine agent consent, session modes, sandbox policy, and sender authority before dispatching to a host-native runtime. flowchart TD
A[Channel or Gateway message] --> B[Sender authorization]
B --> C[Session admission]
D[Agent consent and chat modes] --> C
C --> E[Execution preflight]
D --> E
E --> F[Native runtime dispatch]
Technical reviewBest possible solution: Land the scoped owner-chat fix through the normal gates, retaining explicit restrictions and leaving child authority propagation to separate work. Do we have a high-confidence way to reproduce the issue? Current main’s explicit-mode checks establish the owner-channel failure path, and the PR reports a base-red owner-chat regression; no target code was executed during this review. Is this the best way to solve the issue? The patch uses the existing consent owner for both admission and preflight, derives effective modes without persisting promotion, and preserves mandatory boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 71acfa454e1b. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +22, Tests +64, Docs +1, Other +64. Total +151 across 9 files. Added test files: 0. View PR surface stats
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 HistoryReview history (3 earlier review cycles)Reviewed October 27, 2026, 5:43 AM ET / 09:43 UTC (Revision 4). |
|
@clawsweeper re-review The new head |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added real Gateway proof (new |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added the requested proof to the PR body (no code change on
|
|
🦞👀 Re-review progress:
|
|
Landed as 64f2ce2.
|
…nclaw#185597) ## What Problem This Solves Fixes: after an owner accepts a native runtime's permissions during setup (for example Muse Code), their own Telegram and other channel chats are still refused with "cannot enforce this conversation's tool policy". ## User Impact User impact: the setup consent ("Remember this choice for <agent>") now applies to the owner's own turns in any chat of that agent, including channel chats, for every host-only native runtime. Subagents are not covered yet (see below). Chats driven by other senders, chats with an explicit narrower permission or sandbox mode, and chats sandboxed by agent config keep today's behavior. ## Why This Change Was Made Remembered agent consent only counted in a chat whose stored modes were explicitly `permissionMode: "full"` and `sandboxMode: "off"`. Only Control UI paths write those fields (the admin model-selection promotion and the chat recovery dialog), so channel chats and subagents, whose modes stay unset, never qualified. The run preflight now treats an unset permission and sandbox mode as Full access with sandbox off when the turn's live sender is an owner (`senderIsOwner`). The rule lives next to remembered consent in `src/config/native-runtime-consent.ts`. It never replaces an explicit chat mode and never leaves a sandbox the agent config applies. Non-owner turns keep the documented contract that remembered consent cannot raise their permissions. Subagents are deliberately out of scope. A child run carries only the spawner's `operatorAuthority`, which configured channel owners do not have, and the stored `spawnedBySenderIsOwner` receipt is not current authority (it is not revalidated against the parent incarnation or later senders here). Extending consent to children needs live owner authority carried into the child launch; that is a follow-up. Admission applies the same rule: `chat.send` classifies the stored chat with `callerCanConsent` (admin scope) before a run starts, so the session classifier treats an owner caller's unset modes the same way. Fork keeps `callerCanConsent: false`. The preflight also reuses its caller's resolved agent id instead of resolving it again. ## Evidence - Real Gateway proof: new deterministic Muse Docker mode `bash scripts/e2e/lib/muse-runtime/run.sh consent` runs the built package with a fake `muse` binary that logs every native call, under a `tools.allow: ["message"]` policy Muse cannot enforce and `nativeRuntimeConsent: ["muse"]`: ``` PASS owner turn with unset modes dispatches under remembered consent PASS non-owner turn refused before Muse I/O PASS explicit Full access chat keeps remembered consent PASS removed consent refused before Muse I/O Muse remembered-consent Docker E2E passed ``` The owner is an `operator.admin` client; the non-owner is an `operator.read`/`operator.write` client. Both refusals are `AGENT_RUNTIME_RESTRICTED` at `chat.send` admission, and the native request log does not grow. The explicit Full access chat (set through `sessions.patch`) shows stored modes keep their existing meaning after upgrade; no stored field or schema changes. Channel (Telegram) turns use the run preflight covered by the unit test below; this proof uses the webchat path. - Found on a live Gateway (main `03df9eaf`): with `nativeRuntimeConsent: ["muse"]` and unset chat modes, a `muse` turn was refused with "Muse Code cannot enforce this conversation's tool policy". That report came from an owner-spawned subagent, which this PR deliberately leaves to a follow-up; the same remembered-consent check refuses the owner's own channel turns, which the new preflight test reproduces on `main` and the Telegram proof below exercises with the fix. - Telegram Test Server proof (real QA user, one DM, leased Test Server bot, fake `muse` binary logging every native call; `tools.allow: ["message"]`, `nativeRuntimeConsent: ["muse"]`). The scenario toggles the QA user in `commands.ownerAllowFrom` between turns: | Step | Sender | Telegram reply | Reached Muse `turn/start` | |---|---|---|---| | `fixture:owner` | owner | `started: hello` | yes | | `fixture:guest` | non-owner (same chat) | "Muse Code cannot run with this chat's tool restrictions…" | no | | `fixture:wait` | owner | (runs until the Gateway restarts) | yes | | `fixture:queued`, queued behind `wait`; owner removed and Gateway restarted while it waits | revoked owner | "Muse Code cannot run with this chat's tool restrictions…" | no | Muse `turn/start` prompts for the run: `["owner", "wait"]`. A queued turn whose owner is revoked is refused after recovery and never reaches Muse. Runner: `run-mock-sut-user-e2e.mjs --dm --scenario <scenario> --timeout-ms 185000` with an `E2E_ROOT_CONFIG_PATCH` that selects `meta/muse-spark-1.3` on the `muse` runtime (credentials and ids omitted). An `ownerAllowFrom` change made while a run is active is deferred until that run ends (a Telegram channel reload); a turn claimed before the reload applies runs under the still-current config, so revocation takes effect when the Gateway applies it, never on a turn prepared after it. - Upgrade proof from the published `[email protected]`: the published Gateway stores an explicit Full access chat and an unset chat; the candidate Doctor migrates the state (`doctor --fix --non-interactive --yes`, agent schema 25 to 37); the candidate Gateway then loads both chats with their modes unchanged: ``` PASS published Gateway stored an explicit Full access chat and an unset chat PASS candidate Doctor migrated the published state PASS candidate loads both stored chats with their modes unchanged PASS stored explicit Full access chat dispatches for a non-owner PASS stored unset chat refuses a non-owner before Muse I/O PASS stored unset chat dispatches for the owner ``` - New test `applies remembered agent consent to %s` in `src/agents/harness/execution-environment.test.ts` runs the real preflight against stored sessions. On `main` the owner-chat case fails; the guest, explicit Full access, explicit workspace-mode and spawn-receipt-only subagent cases keep their current results (the last asserts a stored receipt alone grants nothing). All pass with the fix. - The existing worker test that keeps a config sandbox in force for an unset sandbox mode still passes. - Passing locally: every test file that references native consent, the execution-environment preflight or spawn owner receipts (29 files, 586 tests); `oxfmt`, `oxlint` (including `max-lines`) and `git diff --check`. - The existing `deterministic` Muse lane fails before this change on its first assertion (two Muse `initialize` calls instead of one); it is not run in CI and is unrelated, so the new scenario runs as its own `consent` mode. Size against `main`: production +36/−14, tests +64, Muse Docker proof scripts +76/−12, docs +3/−2. Co-authored-by: Ayaan Zaidi <[email protected]>
…er the owner is removed (#185796) Related: #185597, #185476 ## What Problem This Solves Fixes: a subagent spawned by a channel owner (for example a Telegram owner in `commands.ownerAllowFrom`) keeps running on its native runtime, such as Muse, after that person stops being an owner. ## User Impact An owner's subagent keeps remembered native runtime consent (`nativeRuntimeConsent`) only while the spawner is still an owner. When an operator removes the owner, the child stops before its next native dispatch. Children spawned by non-owners still get refused, and owner-spawned children still dispatch. ## Why This Change Was Made #185597 made remembered consent cover an owner's own turns. A child run already gets its owner fact from the spawner's live requester check (`prepareCommandOwnerAuthority`), not from the stored `spawnedBySenderIsOwner` receipt. But that check ran only while the Gateway admitted the child. After that, nothing checked it again, so removing the owner did not stop the child. This change adds the same check to the child run's source assertion. A channel owner's own turn already uses this pattern (`captureCommandOwnerAssertion` in the run's `assertSourceCurrent`). The harness host checks that assertion just before native dispatch. If the check fails, it stays failed for the rest of the run. ## Evidence Regression test (in-process): production-boundary test `fences remembered native consent for a child spawned by a channel %s`. It runs the real `sessions_spawn` tool, then the in-process Gateway `agent` admission, then the child's run parameters. The parent turn is a Telegram sender. The agent config has `nativeRuntimeConsent: ["native-fixture"]` and the child session modes are unset. The model-facing `senderIsOwner` receipt is `true` in both rows. - Owner (`telegram:456`): the child gets `senderIsOwner: true` and `assertAgentHarnessExecutionEnvironment` returns consent. When the owner is removed after admission, the captured admitted-run assertion (the one the harness host checks before `runAttempt`) throws. - Guest (`telegram:789`): the child gets `senderIsOwner: false` and consent is refused, even with an owner receipt. - Negative control: without the production change, the owner row fails because nothing stops the child after revocation. Also ran: - The full spawn production-boundary file (106 tests), `agent.test.ts` and `agent.followup-owner.test.ts` (414 tests), and `execution-environment.test.ts`: all pass. - `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxlint and `git diff --check`: clean. ### Live proof: Telegram Test Server + real Muse Isolated Gateway with a leased Telegram Test Server bot and user. The parent agent is a deterministic mock model that issues a real `sessions_spawn`. Children run on the real Muse runtime (`meta/muse-spark-1.3`, Muse Code 1.4.11). Config: `nativeRuntimeConsent: ["muse"]`, `agents.defaults.subagents.model: meta/muse-spark-1.3`, `subagents.maxConcurrent: 1`. The tester is made an owner through `commands.ownerAllowFrom`, then removed by editing the config file while child A runs on Muse. A Gateway detail controls the timing: it defers an owner-removal config reload until active runs end, or until its 300 s timeout. Child A runs a 330 s shell `sleep` on Muse, so the removal takes effect while A is still running. | Step | `main` (`32f9477bf4`) | This PR | | --- | --- | --- | | Owner's child A dispatches to Muse | Yes: Muse replies (`muse-spark-1.3`) | Yes: Muse replies (`muse-spark-1.3`) | | Owner removed; reload applies after 300 s timeout | Applied | Applied | | Child A's next native dispatch | **Continues**: `FIRST_CHILD_DONE` is delivered to Telegram | **Stopped**: "Requester owner authority changed; send a new request." | | Queued child B (admitted before removal) | Refused, no Muse turn | Refused, no Muse turn | | Guest's child (tester not an owner) | — | Refused before Muse I/O: "Muse Code cannot enforce this conversation's tool policy." No Muse assistant turn. | So the discriminating case is a child that is already running when the removal applies. A queued child was already refused on `main`. ## Merge danger Two-way door. The change writes no state and does not change config or protocol, so a revert undoes it fully. Blast radius: only child runs whose owner fact comes from a channel requester (`requesterOwner`). If the owner is removed while such a child runs, the child now stops instead of finishing. Operator, admin-scope and non-owner children do not change. Restart replay of a final reply keeps its current behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
…er the owner is removed (openclaw#185796) Related: openclaw#185597, openclaw#185476 ## What Problem This Solves Fixes: a subagent spawned by a channel owner (for example a Telegram owner in `commands.ownerAllowFrom`) keeps running on its native runtime, such as Muse, after that person stops being an owner. ## User Impact An owner's subagent keeps remembered native runtime consent (`nativeRuntimeConsent`) only while the spawner is still an owner. When an operator removes the owner, the child stops before its next native dispatch. Children spawned by non-owners still get refused, and owner-spawned children still dispatch. ## Why This Change Was Made openclaw#185597 made remembered consent cover an owner's own turns. A child run already gets its owner fact from the spawner's live requester check (`prepareCommandOwnerAuthority`), not from the stored `spawnedBySenderIsOwner` receipt. But that check ran only while the Gateway admitted the child. After that, nothing checked it again, so removing the owner did not stop the child. This change adds the same check to the child run's source assertion. A channel owner's own turn already uses this pattern (`captureCommandOwnerAssertion` in the run's `assertSourceCurrent`). The harness host checks that assertion just before native dispatch. If the check fails, it stays failed for the rest of the run. ## Evidence Regression test (in-process): production-boundary test `fences remembered native consent for a child spawned by a channel %s`. It runs the real `sessions_spawn` tool, then the in-process Gateway `agent` admission, then the child's run parameters. The parent turn is a Telegram sender. The agent config has `nativeRuntimeConsent: ["native-fixture"]` and the child session modes are unset. The model-facing `senderIsOwner` receipt is `true` in both rows. - Owner (`telegram:456`): the child gets `senderIsOwner: true` and `assertAgentHarnessExecutionEnvironment` returns consent. When the owner is removed after admission, the captured admitted-run assertion (the one the harness host checks before `runAttempt`) throws. - Guest (`telegram:789`): the child gets `senderIsOwner: false` and consent is refused, even with an owner receipt. - Negative control: without the production change, the owner row fails because nothing stops the child after revocation. Also ran: - The full spawn production-boundary file (106 tests), `agent.test.ts` and `agent.followup-owner.test.ts` (414 tests), and `execution-environment.test.ts`: all pass. - `pnpm tsgo:core`, `pnpm tsgo:core:test`, oxlint and `git diff --check`: clean. ### Live proof: Telegram Test Server + real Muse Isolated Gateway with a leased Telegram Test Server bot and user. The parent agent is a deterministic mock model that issues a real `sessions_spawn`. Children run on the real Muse runtime (`meta/muse-spark-1.3`, Muse Code 1.4.11). Config: `nativeRuntimeConsent: ["muse"]`, `agents.defaults.subagents.model: meta/muse-spark-1.3`, `subagents.maxConcurrent: 1`. The tester is made an owner through `commands.ownerAllowFrom`, then removed by editing the config file while child A runs on Muse. A Gateway detail controls the timing: it defers an owner-removal config reload until active runs end, or until its 300 s timeout. Child A runs a 330 s shell `sleep` on Muse, so the removal takes effect while A is still running. | Step | `main` (`b5c6e98ca9`) | This PR | | --- | --- | --- | | Owner's child A dispatches to Muse | Yes: Muse replies (`muse-spark-1.3`) | Yes: Muse replies (`muse-spark-1.3`) | | Owner removed; reload applies after 300 s timeout | Applied | Applied | | Child A's next native dispatch | **Continues**: `FIRST_CHILD_DONE` is delivered to Telegram | **Stopped**: "Requester owner authority changed; send a new request." | | Queued child B (admitted before removal) | Refused, no Muse turn | Refused, no Muse turn | | Guest's child (tester not an owner) | — | Refused before Muse I/O: "Muse Code cannot enforce this conversation's tool policy." No Muse assistant turn. | So the discriminating case is a child that is already running when the removal applies. A queued child was already refused on `main`. ## Merge danger Two-way door. The change writes no state and does not change config or protocol, so a revert undoes it fully. Blast radius: only child runs whose owner fact comes from a channel requester (`requesterOwner`). If the owner is removed while such a child runs, the child now stops instead of finishing. Operator, admin-scope and non-owner children do not change. Restart replay of a final reply keeps its current behavior. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: after an owner accepts a native runtime's permissions during setup (for example Muse Code), their own Telegram and other channel chats are still refused with "cannot enforce this conversation's tool policy".
User Impact
User impact: the setup consent ("Remember this choice for ") now applies to the owner's own turns in any chat of that agent, including channel chats, for every host-only native runtime. Subagents are not covered yet (see below). Chats driven by other senders, chats with an explicit narrower permission or sandbox mode, and chats sandboxed by agent config keep today's behavior.
Why This Change Was Made
Remembered agent consent only counted in a chat whose stored modes were explicitly
permissionMode: "full"andsandboxMode: "off". Only Control UI paths write those fields (the admin model-selection promotion and the chat recovery dialog), so channel chats and subagents, whose modes stay unset, never qualified.The run preflight now treats an unset permission and sandbox mode as Full access with sandbox off when the turn's live sender is an owner (
senderIsOwner). The rule lives next to remembered consent insrc/config/native-runtime-consent.ts. It never replaces an explicit chat mode and never leaves a sandbox the agent config applies. Non-owner turns keep the documented contract that remembered consent cannot raise their permissions.Subagents are deliberately out of scope. A child run carries only the spawner's
operatorAuthority, which configured channel owners do not have, and the storedspawnedBySenderIsOwnerreceipt is not current authority (it is not revalidated against the parent incarnation or later senders here). Extending consent to children needs live owner authority carried into the child launch; that is a follow-up.Admission applies the same rule:
chat.sendclassifies the stored chat withcallerCanConsent(admin scope) before a run starts, so the session classifier treats an owner caller's unset modes the same way. Fork keepscallerCanConsent: false. The preflight also reuses its caller's resolved agent id instead of resolving it again.Evidence
Real Gateway proof: new deterministic Muse Docker mode
bash scripts/e2e/lib/muse-runtime/run.sh consentruns the built package with a fakemusebinary that logs every native call, under atools.allow: ["message"]policy Muse cannot enforce andnativeRuntimeConsent: ["muse"]:The owner is an
operator.adminclient; the non-owner is anoperator.read/operator.writeclient. Both refusals areAGENT_RUNTIME_RESTRICTEDatchat.sendadmission, and the native request log does not grow. The explicit Full access chat (set throughsessions.patch) shows stored modes keep their existing meaning after upgrade; no stored field or schema changes. Channel (Telegram) turns use the run preflight covered by the unit test below; this proof uses the webchat path.Found on a live Gateway (main
8299fea7): withnativeRuntimeConsent: ["muse"]and unset chat modes, amuseturn was refused with "Muse Code cannot enforce this conversation's tool policy". That report came from an owner-spawned subagent, which this PR deliberately leaves to a follow-up; the same remembered-consent check refuses the owner's own channel turns, which the new preflight test reproduces onmainand the Telegram proof below exercises with the fix.Telegram Test Server proof (real QA user, one DM, leased Test Server bot, fake
musebinary logging every native call;tools.allow: ["message"],nativeRuntimeConsent: ["muse"]). The scenario toggles the QA user incommands.ownerAllowFrombetween turns:turn/startfixture:ownerstarted: hellofixture:guestfixture:waitfixture:queued, queued behindwait; owner removed and Gateway restarted while it waitsMuse
turn/startprompts for the run:["owner", "wait"]. A queued turn whose owner is revoked is refused after recovery and never reaches Muse. Runner:run-mock-sut-user-e2e.mjs --dm --scenario <scenario> --timeout-ms 185000with anE2E_ROOT_CONFIG_PATCHthat selectsmeta/muse-spark-1.3on themuseruntime (credentials and ids omitted).An
ownerAllowFromchange made while a run is active is deferred until that run ends (a Telegram channel reload); a turn claimed before the reload applies runs under the still-current config, so revocation takes effect when the Gateway applies it, never on a turn prepared after it.Upgrade proof from the published
[email protected]: the published Gateway stores an explicit Full access chat and an unset chat; the candidate Doctor migrates the state (doctor --fix --non-interactive --yes, agent schema 25 to 37); the candidate Gateway then loads both chats with their modes unchanged:New test
applies remembered agent consent to %sinsrc/agents/harness/execution-environment.test.tsruns the real preflight against stored sessions. Onmainthe owner-chat case fails; the guest, explicit Full access, explicit workspace-mode and spawn-receipt-only subagent cases keep their current results (the last asserts a stored receipt alone grants nothing). All pass with the fix.The existing worker test that keeps a config sandbox in force for an unset sandbox mode still passes.
Passing locally: every test file that references native consent, the execution-environment preflight or spawn owner receipts (29 files, 586 tests);
oxfmt,oxlint(includingmax-lines) andgit diff --check.The existing
deterministicMuse lane fails before this change on its first assertion (two Museinitializecalls instead of one); it is not run in CI and is unrelated, so the new scenario runs as its ownconsentmode.Size against
main: production +36/−14, tests +64, Muse Docker proof scripts +76/−12, docs +3/−2.