fix(sandbox): recover late dashboard tool-scope approvals via doctor (#4616)#4936
Conversation
…VIDIA#4616) Dashboard-only OpenClaw users hit "gateway closed (1006 abnormal closure)" and policy denials to 127.0.0.1:<dashboardPort> when an agent tool call (cron creation, exec, code search) triggers a device scope upgrade that the in-sandbox auto-pair watcher never approves — typically because the watcher has already exited. The existing recovery only runs during `nemoclaw <sandbox> connect`, which dashboard users never invoke, so the pending upgrade sticks and tools fall back to embedded mode or fail outright. - Extract the connect-time allowlisted approval pass into a shared `auto-pair-approval` module and reuse it from `doctor --fix`, giving dashboard-only users a bounded recovery path without an SSH connect. The allowlist is unchanged (openclaw-control-ui + webchat/cli, narrow scopes). - Add a read-only `doctor` tool-scope diagnostic that surfaces pending allowlisted upgrades, the gateway 1006 / scope-upgrade-pending / loopback policy-denial log signatures, and whether the auto-pair watcher is alive, so the failure reads as device-scope, not as a cron/package problem. Current device-list state is authoritative over (never-truncated) log signatures; logs are read bounded from the end. Gated to OpenClaw sandboxes. - Base64-wrap in-sandbox exec payloads: OpenShell `sandbox exec` rejects multi-line arguments, which had silently broken the connect-time recovery too. This makes both the connect and doctor recovery passes actually run. Verified end-to-end on a live dashboard-only OpenClaw sandbox: triggered a stuck pending allowlisted scope upgrade (agent fell back to embedded), saw `doctor` report it as a failure with a `doctor --fix` hint, and confirmed `doctor --fix` cleared it (pending 1 -> 0, [fail] -> [ok]). Signed-off-by: Yimo Jiang <yimoj@nvidia.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR introduces a bounded auto-pair approval pass for pending OpenClaw device-scope upgrades and integrates diagnostic/repair logic into the sandbox doctor command. It extracts connect's inline approval logic into a reusable module, adds tool-scope probe building and interpretation for doctor diagnostics, and conditionally runs the approval pass during doctor ChangesDevice-Scope Auto-Pair Approval and Doctor Integration
Sequence DiagramsequenceDiagram
participant DoctorCLI as doctor --fix
participant DoctorCmd as doctor.ts
participant ToolScope as buildToolScopeChecks
participant Sandbox as Sandbox
participant Approval as Auto-pair Approval
DoctorCLI->>DoctorCmd: Run with --fix
DoctorCmd->>ToolScope: buildToolScopeChecks(sandboxName, wantsFix=true)
ToolScope->>Sandbox: Execute probe script (list devices, scan logs)
Sandbox-->>ToolScope: Marked JSON with pending count
ToolScope->>ToolScope: parseToolScopeProbe → ToolScopeProbe
alt Allowlisted pending backlog detected
ToolScope->>Approval: runSandboxAutoPairApprovalPass(capture=true)
Approval->>Sandbox: Execute approval script
Sandbox-->>Approval: Summary marker with approved count
Approval-->>ToolScope: AutoPairApprovalResult
ToolScope->>Sandbox: Execute probe script again (re-probe)
Sandbox-->>ToolScope: Updated marked JSON
ToolScope->>ToolScope: parseToolScopeProbe → ToolScopeProbe (delta)
end
ToolScope->>ToolScope: interpretToolScopeProbe → DoctorToolScopeCheck[]
ToolScope-->>DoctorCmd: Checks (fail→fixed, warn, ok)
DoctorCmd-->>DoctorCLI: Report with checks
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ |
Summary
Dashboard-only OpenClaw users can't create cron jobs (and other agent tool calls fail) because a late device scope upgrade never gets approved: the agent tool subprocess connects to
ws://127.0.0.1:<dashboardPort>, the gateway closes with1006 abnormal closure, and OpenShell logs a policy denial to127.0.0.1:<dashboardPort>. The existing allowlisted approval pass only runs duringnemoclaw <sandbox> connect, which dashboard users never invoke — so there is no recovery path. This adds a bounded recovery + diagnostic throughdoctor.Related Issue
Fixes #4616
Changes
auto-pair-approvalmodule and reuse it fromdoctor --fix, so dashboard-only users can approve pending tool-scope upgrades without an SSHconnect. The allowlist is unchanged and narrow (openclaw-control-ui+webchat/cli,operator.pairing/read/writeonly); unknown clients are never approved.doctortool-scope diagnostic (read-only). Surfaces pending allowlisted upgrades, the1006/scope upgrade pending approval/ loopback127.0.0.1:<dashboardPort>policy-denial log signatures, and whether the in-sandbox auto-pair watcher is alive — so the failure reads as device-scope, not as a cron/package problem. Current device-list state is authoritative over the never-truncated logs; logs are read bounded from the end. Gated to OpenClaw sandboxes (Hermes hasdevice_pairing: false).sandbox execrejects multi-line arguments, which had silently broken the existing connect-time recovery too. Both passes now base64-wrap their payload and decode it inside the sandbox, so the recovery actually runs.Type of Change
Verification
npm testpasses (7413 passed, 25 skipped, 0 failed)codex review --uncommittedclean (no actionable findings)Verified end-to-end on a live dashboard-only OpenClaw sandbox: an
openclaw agenttool call triggered a stuck pending allowlisted scope upgrade (agent fell back toembedded/fallbackFrom: gateway); read-onlydoctorreported[fail] Tool-call device scope: 1 pending allowlisted tool-scope upgrade(s) blocking OpenClaw tool calls; the in-sandbox auto-pair watcher is not runningwith adoctor --fixhint; anddoctor --fixcleared it (pending 1 → 0,[fail]→[ok]).Signed-off-by: Yimo Jiang yimoj@nvidia.com
Summary by CodeRabbit
Release Notes
New Features
sandbox doctor --fixnow automatically approves pending allowlisted tool-scope upgrades.Improvements
Tests