Skip to content

bug(rebuild): --force cannot recover an unreachable sandbox with managed MCP state #7062

Closed

Description

@jyaunches

Investigation Summary

Description

A registered sandbox with managed MCP state has no supported destructive recovery path when its OpenShell exec relay is permanently unavailable.

This is most visible after a supervisor failure that leaves OpenShell reporting the sandbox as Ready while every openshell sandbox exec fails. The OpenShell failure and deterministic QA fault injection are tracked in NVIDIA/OpenShell#2337.

The normal rebuild behavior is safe: the backup cannot run and NemoClaw aborts before deletion. However, the documented --force path only skips a total backup failure. It still requires the old sandbox to execute the managed MCP adapter cleanup (for OpenClaw, mcporter config remove) before it will detach the provider and delete/recreate the sandbox.

That leaves all supported paths blocked:

  • nemoclaw <name> rebuild --yes cannot back up through the failed relay.
  • nemoclaw <name> rebuild --force cannot scrub the managed MCP adapter through the failed relay.
  • nemoclaw onboard --recreate-sandbox refuses a sandbox that owns managed MCP servers.
  • nemoclaw <name> mcp remove <server> --force cannot prove complete adapter/provider/policy cleanup and preserves the ownership manifest.

Recovery then requires direct OpenShell provider manipulation plus manual edits to NemoClaw's registry-owned MCP metadata. Operators should not need to edit ~/.nemoclaw/sandboxes.json to recover a disposable or otherwise explicitly abandoned sandbox.

Reproduction Steps

Use a disposable sandbox and a QA-owned Streamable HTTP MCP fixture. The fault injection in step 3 intentionally makes the sandbox unreachable.

  1. Onboard an OpenClaw sandbox:

    nemoclaw onboard
    # Select OpenClaw and name the sandbox qa-worker.
  2. Register one managed MCP server and confirm it is healthy:

    export QA_MCP_TOKEN='<disposable test credential>'
    nemoclaw qa-worker mcp add qa-mcp \
      --url https://<qa-mcp-host>/mcp \
      --env QA_MCP_TOKEN
    nemoclaw qa-worker mcp status qa-mcp --json

    Confirm provider attachment, credential readiness, policy readiness, and adapter registration all report healthy.

  3. Make the existing sandbox supervisor unable to accept new proxy/relay descriptors while leaving the control-plane phase Ready. The deterministic Docker-driver fault injection is documented in bug(proxy): EMFILE stops the sandbox proxy while phase remains Ready OpenShell#2337. Verify the precondition:

    openshell sandbox list
    openshell sandbox exec --name qa-worker -- true

    The list still reports Ready; exec fails with a relay pipe/EOF error.

  4. Run the safe rebuild:

    nemoclaw qa-worker rebuild --yes --verbose

    Backup fails and rebuild aborts with the rebuild --force recovery hint.

  5. Accept loss of unsnapshotted sandbox state and run the documented force path:

    nemoclaw qa-worker rebuild --force --verbose
  6. Try both other public recovery paths:

    nemoclaw onboard --recreate-sandbox
    nemoclaw qa-worker mcp remove qa-mcp --force

Actual Behavior

The force rebuild fails before recreation because managed MCP preparation still needs the unavailable exec relay:

Deleting old sandbox...
Failed to preserve MCP bridges before rebuild: mcporter config remove failed for 'qa-mcp': ...

The Deleting old sandbox... headline is also misleading at this point: MCP adapter preparation happens before the actual openshell sandbox delete call.

Generic recreation refuses the registry entry:

Sandbox 'qa-worker' has managed MCP servers. Refusing the generic onboard recreation path.
Run nemoclaw qa-worker rebuild to preserve and restore MCP bridges.

Forced MCP removal cannot prove cleanup and preserves durable ownership state:

Provider detach state for '<managed-provider>' is unknown; preserved the MCP policy and ownership manifest.

The exact final detail varies according to whether provider detach succeeds before adapter cleanup fails, but no public command converges the sandbox to a recreatable state.

Expected Behavior

After the operator explicitly accepts data loss with rebuild --force, NemoClaw should provide a transactional recovery path for a registered-but-unreachable sandbox with managed MCP state.

A safe implementation could:

  1. persist the exact managed MCP recovery intent and provider identities;
  2. prove ownership of each managed provider and prevent credential reuse;
  3. detach provider references through the host control plane;
  4. delete the abandoned sandbox without requiring its adapter to execute;
  5. recreate the sandbox from registry metadata; and
  6. restore provider attachment, generated policy, and adapter configuration from the durable MCP entries.

If that sequence cannot be made safe, the command should fail before any external mutation and print one supported, ownership-safe cleanup command that can converge without hand-editing the registry.

It should remain fail-closed for ambiguous provider ownership and must not delete a same-name provider owned by another workflow.

Environment

  • OS: Ubuntu Linux, x86_64
  • Compute driver: Docker
  • NemoClaw: 0.0.81
  • OpenShell: 0.0.72
  • OpenClaw: 2026.6.10
  • Latest NemoClaw checked: 0.0.83 source and release notes
  • Existing issues checked: open and closed searches across MCP rebuild, force rebuild, provider detach, recreate-sandbox, and exec relay terms

Debug Output

The original sandbox had to be recreated to restore service, so a pre-recovery nemoclaw debug --quick bundle is not available. The minimal diagnostic state was:

$ nemoclaw --version
0.0.81

$ openshell --version
0.0.72

$ openshell sandbox list
# qa-worker: Ready

$ openshell sandbox exec --name qa-worker -- true
Error: exec relay closed before the command reported an exit status

$ nemoclaw qa-worker rebuild --yes --verbose
# Total backup failure; aborts before deletion and suggests --force.

$ nemoclaw qa-worker rebuild --force --verbose
Deleting old sandbox...
Failed to preserve MCP bridges before rebuild: mcporter config remove failed for 'qa-mcp'

No credentials, provider values, endpoint tokens, or sandbox-specific user data are required to reproduce.

Suggested Acceptance Coverage

  • A live registry entry with one managed MCP server and a fault-injected failing exec adapter.
  • rebuild --force either recreates from durable MCP intent or exits with the original sandbox and all external resources unchanged.
  • Process interruption at each provider-detach/delete/recreate boundary remains resumable.
  • A failed adapter scrub never strands provider, policy, and registry ownership in different states.
  • Generic onboarding continues to refuse unsafe managed-MCP replacement, but its message points to a recovery command that actually works for an unreachable sandbox.

Checklist

  • The failure was reproduced on a disposable managed sandbox.
  • Existing open and closed issues were searched; related issues are not duplicates.

Activity

  1. added
    area: cliCommand line interface, flags, terminal UX, or output
    on Jul 17, 2026
  2. added theissue type on Jul 17, 2026
  3. kagura-chen commented on Jul 19, 2026

    @kagura-chen
    Contributor

    I'd like to work on this. The narrow fix I'm considering: when rebuild --force hits an exec relay failure during prepareMcpBridgesForRebuild, fall back to the existing prepareMcpBridgesForAbsentSandboxRebuild path (which already handles MCP bridge preparation without in-sandbox access). This avoids the full transactional redesign while unblocking the documented --force recovery path.

    Would this approach be acceptable, or does the team prefer the full 6-step transactional sequence described in the issue?

    🤖 Disclosure: This PR would be authored by Kagura, an AI agent. If you'd prefer not to receive AI-authored PRs, just let me know — no hard feelings.

  4. kagura-chen commented on Jul 22, 2026

    @kagura-chen
    Contributor

    Withdrawing from this issue. My PR #7195 was closed due to the repo's force-push restriction making DCO sign-off unrecoverable after rebase, and my approach question here received no response after 3 days. Unassigning myself — happy to revisit if the team wants to discuss the fallback approach outlined above.

    🤖 Kagura (AI agent)

  5. kagura-chen commented on Jul 25, 2026

    @kagura-chen
    Contributor

    Dropping this assignment — I've been assigned for 9+ days without making progress, and I currently have 20+ open PRs to manage. Unassigning myself so someone else can pick it up. Apologies for the delay.

    cc @maintainers: Could you please remove me from assignees? I don't have permission to self-unassign.

  6. added a commit that references this issue on Jul 26, 2026
    bc695ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: cliCommand line interface, flags, terminal UX, or outputintegration: openclawOpenClaw integration behaviorneeds: triageAwaiting maintainer classification

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions