Skip to content

fix(doctor): check sandboxes the runtime enables per agent - #207213

Merged
obviyus merged 3 commits into
mainfrom
core/doctor-runtime-resolvers
Nov 28, 2026
Merged

obviyus merged 3 commits into
mainfrom
core/doctor-runtime-resolvers

Conversation

@obviyus

@obviyus obviyus commented Nov 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

openclaw doctor and doctor --fix decided whether sandboxing is on from agents.defaults.sandbox only (#201988). With sandboxing enabled only per agent (agents.entries.<id>.sandbox.mode), Doctor gave no Docker/Podman warning and built no missing image. The first sign of trouble was a failed sandboxed turn. The runtime resolves each agent's sandbox with resolveSandboxConfigForAgent.

Change

Doctor now resolves the defaults and every configured agent through resolveSandboxConfigForAgent, the runtime's own resolver. This is the same pattern as #205395.

  • An agent's own sandbox.mode, backend and images count. A gateway role that requires a sandbox covers every agent's resolved images.
  • Each container engine is probed once, and each distinct image is checked and offered for build once.
  • When the engine is missing, the note names the agent whose mode enabled it ("set sandbox.mode to off for agent "work""). An enabled mode is named before a role-only requirement.
  • Sandbox settings the runtime resolver rejects (for example a relative SSH workspace root) are reported as a Doctor warning instead of failing the step.

User impact

Doctor and the runtime now agree on which sandboxes exist. Users with per-agent sandboxing get the Docker/image warning and the build offer they were missing.

Evidence

  • Red on main, green here: doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts "follows an agent's own sandbox mode when the defaults leave it off ([Bug]: doctor ignores per-agent sandbox mode, so Docker/image problems go unreported when only agents.entries.<id>.sandbox is set #201988)": the engine note and pending image work.
  • Adversarial review (Fable) found four gaps in round 1, all fixed and tested here: a role requirement hid an enabled agent; duplicate prompts per image; a throw on an invalid SSH root; role-required agents' own images.
  • doctor-sandbox*.test.ts 32/32; tsgo:core clean.
  • Not in scope, pre-existing: the Codex bwrap network-namespace hint still reads the defaults' docker.network.
  • Upgrade check from the latest stable: [email protected] wrote the state, and the config was given agents.entries.work.sandbox: { mode: "all", docker: { image: "openclaw-sandbox:w11-missing" } }.
    • openclaw doctor --non-interactive on 2026.11.10: no sandbox image finding.
    • This branch on the same state: Sandbox base image missing: openclaw-sandbox:w11-missing.
  • Lint fix after CI: the engine field uses the named SandboxContainerEngine type. Local ClawSweeper on 90fc97dc: clean.

Doctor read only agents.defaults.sandbox, so an agent whose own sandbox.mode enables sandboxing got no Docker or image warning and --fix built nothing. Doctor now resolves every agent through resolveSandboxConfigForAgent, the runtime's resolver (#201988).
…ected settings

Review follow-up: an agent's enabled mode is named before a role-only requirement; role-required agents' own images are checked; resolver-rejected settings become a warning.
@clawsweeper

clawsweeper Bot commented Nov 28, 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 commands Command implementations size: M labels Nov 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 28, 2026
@obviyus
obviyus merged commit 563eef9 into main Nov 28, 2026
118 checks passed
@obviyus
obviyus deleted the core/doctor-runtime-resolvers branch November 28, 2026 04:28
obviyus added a commit that referenced this pull request Nov 28, 2026
…olicy by hand (#207238)

## Problem
Three places re-derive settings instead of asking the owner the runtime uses (#205672 cases 2 and 3; #201988 follow-up). Each one gives a wrong answer when a setting is set only in the per-entry or per-agent config.
- **`/tools` browser notice** (`src/agents/tools-effective-inventory.ts`) reads `plugins.allow` by hand. With an empty allowlist and `plugins.entries.browser.enabled: false`, it blames `plugins.allow`, which is not the cause.
- **OpenShell File Transfer gate** (`extensions/openshell/src/worker-workspace.ts`) does a hand-made exact-id check. A padded deny entry (`" File-Transfer "`) passes it, so agent workspace binding does not keep the operator's File Transfer restriction.
- **Doctor Codex bwrap hint** (`src/commands/doctor-sandbox.ts`) reads only `agents.defaults.sandbox.docker.network`. An agent's own network setting changes how the runtime starts that sandbox, but Doctor ignores it. The result is a wrong network-namespace probe and a wrong hint.

## Solution
- The browser notice and the OpenShell gate call `resolveEffectiveEnableState`, the same resolver the plugin loader uses. This is the same fix as #207215.
- The bwrap check reads `docker.network` from every container sandbox that `resolveSandboxConfigForAgent` resolves (already used for the engine since #207213), including sandboxes a gateway role requires. It probes the network namespace when any of them has no egress. Whether the check runs at all still follows a mode-on sandbox, as before. The hint no longer names one engine for every sandbox.

## Impact
- Users with an empty allowlist see a correct `/tools` browser notice; a padded File Transfer deny entry now keeps its restriction.
- Users with a per-agent sandbox network get the correct Codex bwrap check on Linux.
- No config, schema or wire change.

## Evidence
- New tests are red on `main` and green on this branch (inventory blame rows, the OpenShell padded-deny row, and the bwrap resolved-network rows). Controls pass on both.
- The plugin-activation diff is the one Fable 5.2 reviewed (no finding). It applies to current `main` without change.
- The bwrap change had two Fable 5.2 rounds. Round 1 found three issues: role-required sandboxes were skipped, the test did not prove "any", and the hint named one engine. All three are fixed. Round 2 found no regression.
- Accepted edge case (round 2): when a gateway role requires a sandbox, #207213 counts the defaults entry as a sandbox. Its network (`none` unless set) can start the network-namespace probe when every listed agent has egress. The result is an extra check, not a missed one. A warning appears only on hosts that deny the network namespace.

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

## Problem
`openclaw doctor` and `doctor --fix` decided whether sandboxing is on from `agents.defaults.sandbox` only (openclaw#201988). With sandboxing enabled only per agent (`agents.entries.<id>.sandbox.mode`), Doctor gave no Docker/Podman warning and built no missing image. The first sign of trouble was a failed sandboxed turn. The runtime resolves each agent's sandbox with `resolveSandboxConfigForAgent`.

## Change
Doctor now resolves the defaults and every configured agent through `resolveSandboxConfigForAgent`, the runtime's own resolver. This is the same pattern as openclaw#205395.
- An agent's own `sandbox.mode`, backend and images count. A gateway role that requires a sandbox covers every agent's resolved images.
- Each container engine is probed once, and each distinct image is checked and offered for build once.
- When the engine is missing, the note names the agent whose mode enabled it ("set sandbox.mode to off for agent \"work\""). An enabled mode is named before a role-only requirement.
- Sandbox settings the runtime resolver rejects (for example a relative SSH workspace root) are reported as a Doctor warning instead of failing the step.

## User impact
Doctor and the runtime now agree on which sandboxes exist. Users with per-agent sandboxing get the Docker/image warning and the build offer they were missing.

## Evidence
- Red on main, green here: `doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts` "follows an agent's own sandbox mode when the defaults leave it off (openclaw#201988)": the engine note and pending image work.
- Adversarial review (Fable) found four gaps in round 1, all fixed and tested here: a role requirement hid an enabled agent; duplicate prompts per image; a throw on an invalid SSH root; role-required agents' own images.
- `doctor-sandbox*.test.ts` 32/32; `tsgo:core` clean.
- Not in scope, pre-existing: the Codex bwrap network-namespace hint still reads the defaults' `docker.network`.
- Upgrade check from the latest stable: `[email protected]` wrote the state, and the config was given `agents.entries.work.sandbox: { mode: "all", docker: { image: "openclaw-sandbox:w11-missing" } }`.
  - `openclaw doctor --non-interactive` on 2026.11.10: no sandbox image finding.
  - This branch on the same state: `Sandbox base image missing: openclaw-sandbox:w11-missing`.
- Lint fix after CI: the engine field uses the named `SandboxContainerEngine` type. Local ClawSweeper on `90fc97dc`: clean.

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

## Problem
Three places re-derive settings instead of asking the owner the runtime uses (openclaw#205672 cases 2 and 3; openclaw#201988 follow-up). Each one gives a wrong answer when a setting is set only in the per-entry or per-agent config.
- **`/tools` browser notice** (`src/agents/tools-effective-inventory.ts`) reads `plugins.allow` by hand. With an empty allowlist and `plugins.entries.browser.enabled: false`, it blames `plugins.allow`, which is not the cause.
- **OpenShell File Transfer gate** (`extensions/openshell/src/worker-workspace.ts`) does a hand-made exact-id check. A padded deny entry (`" File-Transfer "`) passes it, so agent workspace binding does not keep the operator's File Transfer restriction.
- **Doctor Codex bwrap hint** (`src/commands/doctor-sandbox.ts`) reads only `agents.defaults.sandbox.docker.network`. An agent's own network setting changes how the runtime starts that sandbox, but Doctor ignores it. The result is a wrong network-namespace probe and a wrong hint.

## Solution
- The browser notice and the OpenShell gate call `resolveEffectiveEnableState`, the same resolver the plugin loader uses. This is the same fix as openclaw#207215.
- The bwrap check reads `docker.network` from every container sandbox that `resolveSandboxConfigForAgent` resolves (already used for the engine since openclaw#207213), including sandboxes a gateway role requires. It probes the network namespace when any of them has no egress. Whether the check runs at all still follows a mode-on sandbox, as before. The hint no longer names one engine for every sandbox.

## Impact
- Users with an empty allowlist see a correct `/tools` browser notice; a padded File Transfer deny entry now keeps its restriction.
- Users with a per-agent sandbox network get the correct Codex bwrap check on Linux.
- No config, schema or wire change.

## Evidence
- New tests are red on `main` and green on this branch (inventory blame rows, the OpenShell padded-deny row, and the bwrap resolved-network rows). Controls pass on both.
- The plugin-activation diff is the one Fable 5.2 reviewed (no finding). It applies to current `main` without change.
- The bwrap change had two Fable 5.2 rounds. Round 1 found three issues: role-required sandboxes were skipped, the test did not prove "any", and the hint named one engine. All three are fixed. Round 2 found no regression.
- Accepted edge case (round 2): when a gateway role requires a sandbox, openclaw#207213 counts the defaults entry as a sandbox. Its network (`none` unless set) can start the network-namespace probe when every listed agent has egress. The result is an extra check, not a missed one. A warning appears only on hosts that deny the network namespace.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…olicy by hand (#207238)

## Problem
Three places re-derive settings instead of asking the owner the runtime uses (#205672 cases 2 and 3; #201988 follow-up). Each one gives a wrong answer when a setting is set only in the per-entry or per-agent config.
- **`/tools` browser notice** (`src/agents/tools-effective-inventory.ts`) reads `plugins.allow` by hand. With an empty allowlist and `plugins.entries.browser.enabled: false`, it blames `plugins.allow`, which is not the cause.
- **OpenShell File Transfer gate** (`extensions/openshell/src/worker-workspace.ts`) does a hand-made exact-id check. A padded deny entry (`" File-Transfer "`) passes it, so agent workspace binding does not keep the operator's File Transfer restriction.
- **Doctor Codex bwrap hint** (`src/commands/doctor-sandbox.ts`) reads only `agents.defaults.sandbox.docker.network`. An agent's own network setting changes how the runtime starts that sandbox, but Doctor ignores it. The result is a wrong network-namespace probe and a wrong hint.

## Solution
- The browser notice and the OpenShell gate call `resolveEffectiveEnableState`, the same resolver the plugin loader uses. This is the same fix as #207215.
- The bwrap check reads `docker.network` from every container sandbox that `resolveSandboxConfigForAgent` resolves (already used for the engine since #207213), including sandboxes a gateway role requires. It probes the network namespace when any of them has no egress. Whether the check runs at all still follows a mode-on sandbox, as before. The hint no longer names one engine for every sandbox.

## Impact
- Users with an empty allowlist see a correct `/tools` browser notice; a padded File Transfer deny entry now keeps its restriction.
- Users with a per-agent sandbox network get the correct Codex bwrap check on Linux.
- No config, schema or wire change.

## Evidence
- New tests are red on `main` and green on this branch (inventory blame rows, the OpenShell padded-deny row, and the bwrap resolved-network rows). Controls pass on both.
- The plugin-activation diff is the one Fable 5.2 reviewed (no finding). It applies to current `main` without change.
- The bwrap change had two Fable 5.2 rounds. Round 1 found three issues: role-required sandboxes were skipped, the test did not prove "any", and the hint named one engine. All three are fixed. Round 2 found no regression.
- Accepted edge case (round 2): when a gateway role requires a sandbox, #207213 counts the defaults entry as a sandbox. Its network (`none` unless set) can start the network-namespace probe when every listed agent has egress. The result is an extra check, not a missed one. A warning appears only on hosts that deny the network namespace.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 9bbd5f5)

Release adaptation: Ported the effective plugin resolver changes. Adapted Doctor’s network selection to the release sandbox resolver instead of importing the main-only backend inventory.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…olicy by hand (#207238)

Three places re-derive settings instead of asking the owner the runtime uses (#205672 cases 2 and 3; #201988 follow-up). Each one gives a wrong answer when a setting is set only in the per-entry or per-agent config.
- **`/tools` browser notice** (`src/agents/tools-effective-inventory.ts`) reads `plugins.allow` by hand. With an empty allowlist and `plugins.entries.browser.enabled: false`, it blames `plugins.allow`, which is not the cause.
- **OpenShell File Transfer gate** (`extensions/openshell/src/worker-workspace.ts`) does a hand-made exact-id check. A padded deny entry (`" File-Transfer "`) passes it, so agent workspace binding does not keep the operator's File Transfer restriction.
- **Doctor Codex bwrap hint** (`src/commands/doctor-sandbox.ts`) reads only `agents.defaults.sandbox.docker.network`. An agent's own network setting changes how the runtime starts that sandbox, but Doctor ignores it. The result is a wrong network-namespace probe and a wrong hint.

- The browser notice and the OpenShell gate call `resolveEffectiveEnableState`, the same resolver the plugin loader uses. This is the same fix as #207215.
- The bwrap check reads `docker.network` from every container sandbox that `resolveSandboxConfigForAgent` resolves (already used for the engine since #207213), including sandboxes a gateway role requires. It probes the network namespace when any of them has no egress. Whether the check runs at all still follows a mode-on sandbox, as before. The hint no longer names one engine for every sandbox.

- Users with an empty allowlist see a correct `/tools` browser notice; a padded File Transfer deny entry now keeps its restriction.
- Users with a per-agent sandbox network get the correct Codex bwrap check on Linux.
- No config, schema or wire change.

- New tests are red on `main` and green on this branch (inventory blame rows, the OpenShell padded-deny row, and the bwrap resolved-network rows). Controls pass on both.
- The plugin-activation diff is the one Fable 5.2 reviewed (no finding). It applies to current `main` without change.
- The bwrap change had two Fable 5.2 rounds. Round 1 found three issues: role-required sandboxes were skipped, the test did not prove "any", and the hint named one engine. All three are fixed. Round 2 found no regression.
- Accepted edge case (round 2): when a gateway role requires a sandbox, #207213 counts the defaults entry as a sandbox. Its network (`none` unless set) can start the network-namespace probe when every listed agent has egress. The result is an extra check, not a missed one. A warning appears only on hosts that deny the network namespace.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 9bbd5f5)

Companion audit: Select only OpenShell File Transfer activation and its regression. Other doctor and browser diagnostics are intentionally excluded.

Release adaptation: Use stable public activation resolver only in OpenShell workspace binding; keep browser and native diagnostics unchanged.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
`openclaw doctor` and `doctor --fix` decided whether sandboxing is on from `agents.defaults.sandbox` only (#201988). With sandboxing enabled only per agent (`agents.entries.<id>.sandbox.mode`), Doctor gave no Docker/Podman warning and built no missing image. The first sign of trouble was a failed sandboxed turn. The runtime resolves each agent's sandbox with `resolveSandboxConfigForAgent`.

Doctor now resolves the defaults and every configured agent through `resolveSandboxConfigForAgent`, the runtime's own resolver. This is the same pattern as #205395.
- An agent's own `sandbox.mode`, backend and images count. A gateway role that requires a sandbox covers every agent's resolved images.
- Each container engine is probed once, and each distinct image is checked and offered for build once.
- When the engine is missing, the note names the agent whose mode enabled it ("set sandbox.mode to off for agent \"work\""). An enabled mode is named before a role-only requirement.
- Sandbox settings the runtime resolver rejects (for example a relative SSH workspace root) are reported as a Doctor warning instead of failing the step.

Doctor and the runtime now agree on which sandboxes exist. Users with per-agent sandboxing get the Docker/image warning and the build offer they were missing.

- Red on main, green here: `doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts` "follows an agent's own sandbox mode when the defaults leave it off (#201988)": the engine note and pending image work.
- Adversarial review (Fable) found four gaps in round 1, all fixed and tested here: a role requirement hid an enabled agent; duplicate prompts per image; a throw on an invalid SSH root; role-required agents' own images.
- `doctor-sandbox*.test.ts` 32/32; `tsgo:core` clean.
- Not in scope, pre-existing: the Codex bwrap network-namespace hint still reads the defaults' `docker.network`.
- Upgrade check from the latest stable: `[email protected]` wrote the state, and the config was given `agents.entries.work.sandbox: { mode: "all", docker: { image: "openclaw-sandbox:w11-missing" } }`.
  - `openclaw doctor --non-interactive` on 2026.11.10: no sandbox image finding.
  - This branch on the same state: `Sandbox base image missing: openclaw-sandbox:w11-missing`.
- Lint fix after CI: the engine field uses the named `SandboxContainerEngine` type. Local ClawSweeper on `90fc97dc`: clean.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 563eef9)

Release adaptation: resolve stable engine and image checks with the runtime resolver and retain existing repair consent and bwrap defaults. Stable does not have the maintenance-pending API.

Companion audit: 9bbd5f5 changes a separate bwrap network diagnostic and unrelated activation owners; not required for stable image/engine discovery.

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
## Problem
`openclaw doctor` and `doctor --fix` decided whether sandboxing is on from `agents.defaults.sandbox` only (#201988). With sandboxing enabled only per agent (`agents.entries.<id>.sandbox.mode`), Doctor gave no Docker/Podman warning and built no missing image. The first sign of trouble was a failed sandboxed turn. The runtime resolves each agent's sandbox with `resolveSandboxConfigForAgent`.

## Change
Doctor now resolves the defaults and every configured agent through `resolveSandboxConfigForAgent`, the runtime's own resolver. This is the same pattern as #205395.
- An agent's own `sandbox.mode`, backend and images count. A gateway role that requires a sandbox covers every agent's resolved images.
- Each container engine is probed once, and each distinct image is checked and offered for build once.
- When the engine is missing, the note names the agent whose mode enabled it ("set sandbox.mode to off for agent \"work\""). An enabled mode is named before a role-only requirement.
- Sandbox settings the runtime resolver rejects (for example a relative SSH workspace root) are reported as a Doctor warning instead of failing the step.

## User impact
Doctor and the runtime now agree on which sandboxes exist. Users with per-agent sandboxing get the Docker/image warning and the build offer they were missing.

## Evidence
- Red on main, green here: `doctor-sandbox.warns-sandbox-enabled-without-docker.test.ts` "follows an agent's own sandbox mode when the defaults leave it off (#201988)": the engine note and pending image work.
- Adversarial review (Fable) found four gaps in round 1, all fixed and tested here: a role requirement hid an enabled agent; duplicate prompts per image; a throw on an invalid SSH root; role-required agents' own images.
- `doctor-sandbox*.test.ts` 32/32; `tsgo:core` clean.
- Not in scope, pre-existing: the Codex bwrap network-namespace hint still reads the defaults' `docker.network`.
- Upgrade check from the latest stable: `[email protected]` wrote the state, and the config was given `agents.entries.work.sandbox: { mode: "all", docker: { image: "openclaw-sandbox:w11-missing" } }`.
  - `openclaw doctor --non-interactive` on 2026.11.10: no sandbox image finding.
  - This branch on the same state: `Sandbox base image missing: openclaw-sandbox:w11-missing`.
- Lint fix after CI: the engine field uses the named `SandboxContainerEngine` type. Local ClawSweeper on `90fc97dc`: clean.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 563eef9)

Release adaptation: Reuse the per-agent backend inventory for the release Codex network namespace probe, preserving per-agent egress behavior. Omit the main-only image-repair pending oracle and its assertion because this release has no caller for it.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. commands Command implementations impact:auth-provider Auth, provider routing, model choice, or SecretRef resolution may break. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant