Skip to content

fix: native runtime setup consent ignored in owner channel chats - #185597

Merged
obviyus merged 3 commits into
mainfrom
fix/remembered-native-consent
Oct 27, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/remembered-native-consent

Conversation

@obviyus

@obviyus obviyus commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

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" 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 8299fea7): 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.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling plugin: muse size: S labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Applies 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"].

  • Before: The unset chat modes prevent remembered consent from applying, so Muse is refused.
  • After: The owner’s turn reaches Muse; a subsequent non-owner turn in the same unset-mode chat remains refused.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with shipped-entry-point authority evidence, latest-stable upgrade output, meaningful boundary tests, and no actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The updated exact-head evidence exercises packaged Gateway admission and real Telegram ingress through the production Muse transport to a fixture process: owner turns dispatch, same-chat guest turns do not, and a queued revoked-owner turn is rejected after restart before turn/start; this satisfies both prior authority-proof requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Owners who accepted native permissions during setup still receive tool-policy refusals in their channel chats.
Reason: The feature owner’s scoped repair fulfills the setup-consent promise for owner chats while explicitly deferring subagents that lack live owner authority.

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
Reviewed head: 4fc58ee46e7d1c1b135b32bb6719240aff529fcb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway 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]
Loading

Technical review

Best 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

  • Remembered native-runtime consent eligibility changes intended behavior with a stated reason (8f1a499: Remember approval per agent while preserving session identity, explicit restrictions, and revocation before native dispatch.)
  • Native runtime permission and containment checks keeps the original intent (8cd38b0: Allow explicit native-permission consent while preserving required sandbox, remote execution, and workspace boundaries.)
  • Muse setup documentation and deterministic Gateway fixture keeps the original intent (feat: run Meta models through the Muse Code CLI agent runtime #170487: Exercise the packaged Gateway through the Muse protocol; this PR extends that existing fixture with consent scenarios.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 8f1a499 adds src/config/native-runtime-consent.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8f1a499eb508; files: src/config/native-runtime-consent.ts)

PR surface

Source +22, Tests +64, Docs +1, Other +64. Total +151 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 36 14 +22
Tests 1 64 0 +64
Docs 2 3 2 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 4 76 12 +64
Total 9 179 28 +151

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A focused correction to remembered consent for owner channel turns, with explicit chat restrictions preserved.
  • merge-risk: 🚨 security-boundary: The change lets owner turns use remembered native permissions without stored Full-access modes; the maintainer-authored direction and supplied allowed, forbidden, and revoked-owner evidence address this intentional authority expansion.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-27T07:07:17.280Z sha 2883ae6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-27T08:07:50.142Z sha c93a3e7 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-27T08:58:22.509Z sha 4fc58ee :: needs real behavior proof before merge. :: none

Reviewed October 27, 2026, 5:43 AM ET / 09:43 UTC (Revision 4).

@obviyus
obviyus marked this pull request as ready for review October 27, 2026 07:09
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

The new head c93a3e79 drops the stored spawnedBySenderIsOwner receipt: remembered consent now needs a live owner sender (senderIsOwner === true), and subagents are out of scope until live owner authority reaches the child launch. A new test row asserts that a receipt alone grants nothing.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Added real Gateway proof (new consent mode of the Muse Docker lane, output in the PR body): owner unset-mode dispatch, non-owner and removed-consent refusal before any Muse I/O, and an existing explicit Full access chat unchanged. The run also showed chat.send admission classifies the chat first, so the same owner rule now applies there through callerCanConsent.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M and removed size: S labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 27, 2026
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

Added the requested proof to the PR body (no code change on 4fc58ee4):

  • Telegram Test Server, same DM: owner turn reaches Muse; non-owner turn refused; a queued turn whose owner is revoked (owner removed and Gateway restarted while it waits) is refused after recovery and never reaches Muse turn/start.
  • Upgrade from published [email protected] through the candidate Doctor: stored explicit Full access and unset chats keep their meaning.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 27, 2026
@obviyus obviyus changed the title fix: native runtime setup consent ignored in owner channel chats and subagents fix: native runtime setup consent ignored in owner channel chats Oct 27, 2026
@obviyus
obviyus merged commit 64f2ce2 into main Oct 27, 2026
191 of 194 checks passed
@obviyus
obviyus deleted the fix/remembered-native-consent branch October 27, 2026 10:05
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 64f2ce2.

  • Bug: after an owner accepted a native runtime's permissions during setup, their own channel chats were still refused ("cannot enforce this conversation's tool policy"), because remembered consent only counted for chats explicitly set to Full access.
  • Fix: remembered consent now covers an owner's turn in a chat with unset permission and sandbox modes, at both chat.send admission and the run preflight. Explicit chat modes, configured sandboxes and non-owner turns keep their current behavior. Subagents are a follow-up.
  • Proof: a preflight test that fails on main; a Muse Docker lane through Gateway admission; Telegram Test Server owner, same-chat non-owner and queued revoked-owner turns; and an upgrade from published [email protected] through the candidate Doctor. CI green and ClawSweeper ready on the exact head.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…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]>
obviyus added a commit that referenced this pull request Oct 28, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: muse proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant