NemoClaw icon indicating copy to clipboard operation
NemoClaw copied to clipboard

[WSL2][Hermes][Sandbox] `nemoclaw-start` supervisor never invoked on custom-gateway-port sandbox — `mcp add`/`recover`/`gateway restart` fail with `SUPERVISOR_UNAVAILABLE` despite a healthy, actively-serving gateway process

Open mill101 opened this issue 4 months ago • 5 comments

Investigation Summary

Root cause found via manual source inspection: assertHermesMcpMutationRuntimeCapability in src/lib/actions/sandbox/mcp-bridge-adapter-hermes.ts runs an in-sandbox probe (/usr/local/lib/nemoclaw/hermes-mcp-config-transaction.py probe) before any MCP mutation. That probe's _gateway_has_managed_parent(pid) check requires the direct parent of the running Hermes gateway process to be the exact trusted launcher, i.e. argv == [SERVICE_MANAGER_PATH] where SERVICE_MANAGER_PATH = b"/usr/local/bin/nemoclaw-start" (see hermes-mcp-config-transaction.py around line 54 / 744-770). If that check fails, the probe returns the literal string "Hermes gateway is not running under the managed service lifecycle", which the adapter (mcp-bridge-adapter-hermes.ts:150) surfaces as the CLI error.

docker inspect <container> confirms the container's actual entrypoint is /opt/openshell/bin/openshell-sandbox (the generic OpenShell sandbox supervisor), not nemoclaw-start. nemoclaw-start (/usr/local/bin/nemoclaw-start, ~3000 lines) is itself a long-lived supervisor — its supervise_hermes_gateway_current_user() function owns and respawns the gateway process indefinitely — so the intended chain is openshell-sandbox (pid 1) → nemoclaw-start → hermes.real gateway run. In this sandbox that middle link never forms: openshell-sandbox never launches nemoclaw-start, so the gateway process ends up parented directly to pid 1 instead.

Searching the entire docker logs <container> history for this sandbox (spanning several host/container restarts, from container creation through the present) turns up zero PROC:LAUNCH entries for nemoclaw-start — only periodic healthcheck sleep(N) launches. So this isn't a regression from a specific event; as far as the available history shows, the managed lifecycle for this sandbox incarnation may never have been established in the first place.

Because of this gap, the sandbox currently only stays up via an unofficial workaround (a systemd-triggered script that manually nohup-starts hermes gateway run, orphaning it to pid 1) — which happens to keep normal chat/Slack traffic working, but obviously can never satisfy _gateway_has_managed_parent.

Hypotheses ruled out:

  • Not caused by pre-existing generic-type OpenShell providers on the sandbox. Created a throwaway generic provider with a dummy credential, unrelated to any existing provider, and attempted mcp add with a brand-new server name — identical failure.
  • Not caused by resource contention from a second, chronically crash-looping sandbox sharing host Docker/WSL resources. That sandbox (registered on the other gateway, nemoclaw/8080, itself fully dead with no listener) was removed entirely; the symptom was identical before and after.
  • Possibly related to the general "multiple gateway instances on one host" bug class (e.g. #5359 / NVBug 6225854, both since fixed) given this setup's NEMOCLAW_GATEWAY_PORT=8990 topology, but no existing issue matches this exact symptom (managed-lifecycle/nemoclaw-start parent check specifically), so filing as new.

Description

On this sandbox, nemoclaw <name> mcp add ... always fails with a "managed service lifecycle" error, and the suggested remedy (recover) does not help — recover, gateway restart, and connect --probe-only all fail the same way with SUPERVISOR_UNAVAILABLE.

However, the sandbox is not actually broken. The real hermes.real gateway run process has been running continuously for 8+ hours at time of investigation, and OCSF policy logs confirm it is actively and successfully making real Slack Web API calls (GET /api/users.conversations) on a steady ~5-minute cadence throughout that window. nemoclaw <name> doctor / doctor --fix both report Summary: healthy with no warnings — directly contradicting what status/recover/gateway restart report.

Secondary/minor issue worth noting: nemoclaw <name> status and nemoclaw <name> doctor disagree about the sandbox's health in a way that's confusing to debug: status says Hermes Agent: not running, while doctor's summary says healthy, for the exact same sandbox at the exact same time. Might be worth having doctor surface the managed-lifecycle/parent-process check too, since it currently misses the actual problem.

Expected: openshell-sandbox launches nemoclaw-start as part of bringing a Hermes sandbox to Ready, and nemoclaw-start supervises the gateway indefinitely, satisfying _gateway_has_managed_parent so mcp add/recover/gateway restart work normally.

Actual: nemoclaw-start is never launched for this sandbox. The gateway process only exists because of an external, unofficial keep-alive workaround, which can never satisfy the managed-lifecycle check.

Reproduction Steps

I don't have a clean minimal repro — this sandbox has an involved history (destroy+onboard on a non-default gateway port, followed by post-onboard provider switching via openshell provider update + nemoclaw inference set). I'm not sure which step(s) in that history are load-bearing for triggering the bug. Happy to help narrow it down if a maintainer has a hypothesis to test.

What's solidly reproducible on the affected sandbox right now:

  1. nemoclaw <name> mcp add <any-new-name> --url https://mcp.slack.com/mcp --env <ANY_UNUSED_ENV_VAR> → fails with the lifecycle error every time.
  2. docker exec <container> ps -eo pid,ppid,args | grep hermes.real always shows PPid=1.
  3. nemoclaw-start never appears in docker exec <container> ps output at all.

Environment

  • NemoClaw: v0.0.79 (latest maintained at time of filing: v0.0.83)
  • OpenShell: 0.0.72 (docker driver)
  • Host OS: Windows 11 Pro + WSL2 (Ubuntu 24.04)
  • Docker: Engine 29.4.0
  • Agent: Hermes Agent v0.17.0
  • Gateway topology: two gateway instances registered on this host —
    • nemoclaw (default, port 8080) — was serving a second, unrelated sandbox
    • nemoclaw-8990 (custom port via NEMOCLAW_GATEWAY_PORT=8990) — serves the affected sandbox
    • The second instance exists because a single gateway's inference route is shared by every sandbox registered to it, and this sandbox needs an independent inference route from the other one (documented behavior, not itself the bug).
  • Affected sandbox history: created via nemoclaw <name> destroy + NEMOCLAW_GATEWAY_PORT=8990 nemohermes onboard --fresh (onboarded with a local Ollama provider to satisfy the SSRF preflight on private-IP endpoints), later switched to a different compatible-endpoint target via openshell provider update + nemoclaw inference set (documented supported pattern for LAN endpoints).

Debug Output

$ nemoclaw mcp add --url https://mcp.slack.com/mcp --env <ANY_UNUSED_ENV_VAR> Hermes sandbox '' is not running the managed service lifecycle required for authenticated MCP changes. Run nemoclaw <name> recover and retry.

$ nemoclaw recover Probe failed: Hermes Agent gateway is not running in '' and automatic recovery failed. Check /tmp/gateway.log inside the sandbox for details.

$ nemoclaw gateway restart Restarting Hermes Agent gateway in ''... Failure layer: privileged control unavailable - gateway restart failed for ''. SUPERVISOR_UNAVAILABLE

$ docker exec ps -eo pid,ppid,comm,args | grep -i nemoclaw-start (no output — nemoclaw-start is not running as any process)

$ docker exec bash -c 'grep PPid /proc/$(pgrep -f "hermes.real gateway run")/status' PPid: 1

$ docker inspect (Entrypoint confirmed as /opt/openshell/bin/openshell-sandbox, not nemoclaw-start)

Logs

Full `docker logs <container>` history for this sandbox (from container creation through present, spanning several host/container restarts) searched for `nemoclaw-start` launch events: zero `PROC:LAUNCH` entries found for `nemoclaw-start` — only periodic healthcheck `sleep(N)` launches appear.

OCSF policy logs during the 8+ hour observation window: repeated `ALLOWED` entries for the actual gateway process (pid confirmed = the `hermes.real gateway run` process with PPid=1) making outbound `GET /api/users.conversations` calls to slack.com on a ~5-minute cadence, confirming the gateway itself is healthy and actively serving traffic throughout — consistent with `doctor`'s "healthy" verdict and inconsistent with `status`/`recover`/`gateway restart`'s failure reports.

Checklist

  • [x] I confirmed this bug is reproducible
  • [x] I searched existing issues and this is not a duplicate

mill101 avatar Jul 18 '26 07:07 mill101

✨ Thanks for the detailed root cause analysis. The probe's parent-process check assumes nemoclaw-start as the direct parent, but the container runs under the OpenShell sandbox supervisor. This breaks MCP add/recover/restart on custom-gateway-port sandboxes.

wscurran avatar Jul 20 '26 16:07 wscurran

A clean current-main CI reproduction may narrow this beyond the custom-host-port topology, although the artifact does not contain the process tree needed to prove the same parent-chain root cause.

This was a fresh E2E sandbox on the ordinary OPENSHELL_GATEWAY=nemoclaw lane. Onboarding reported:

Waiting for OpenShell supervisor to reconnect to the recreated container (up to 900s)...
...
Hermes Agent gateway is healthy
...
Policy version 2 loaded (active version: 2)
SUPERVISOR_UNAVAILABLE
NEMOCLAW_CONTROL_STAGE=preflight
Secret-boundary check did not complete cleanly for Hermes gateway

The install then exited 1 before the inference-switch assertions could run. The sandbox and gateway were observably healthy immediately before the policy/secret-boundary preflight rejected the lifecycle.

This proves the user-visible failure on a clean current-main CI setup; it does not yet prove that nemoclaw-start was absent or that the gateway's PPID was 1. Capturing ps -eo pid,ppid,args, /tmp/nemoclaw-start.log, and the control probe result whenever this preflight fails would distinguish the exact #7142 parent-chain defect from a supervisor reconnect race instead of making maintainers divine process ancestry from one token.

dfernandez365-rgb avatar Jul 20 '26 19:07 dfernandez365-rgb

Current-main follow-up, with the topology boundary kept explicit.

What this does not prove

The filed case is NemoClaw v0.0.79 on WSL2, NEMOCLAW_GATEWAY_PORT=8990, with a gateway orphaned under PID 1 by an external keep-alive and no clean minimal reproduction. I have not recreated that topology. Nothing below proves that exact custom-port / missing-nemoclaw-start root cause is fixed.

What current main now contains

At GitHub-verified 888c3d9c438d4b7a7da9e47be7d5430e9d29b9d8:

  • #6677 provides guarded transactional recovery for a registered legacy Docker container in a stable SUPERVISOR_NOT_RUNNING state.
  • ac120c86e gives an inconsistent Hermes /proc/<pinned-supervisor>/environ read up to one second of retry grace, but only while the exact process identity remains unchanged. Persistent unreadability or identity change still fails closed. That addresses the clean default-lane SUPERVISOR_UNAVAILABLE / NEMOCLAW_CONTROL_STAGE=preflight race reported above; it does not weaken the managed-parent proof.

Live current-main result

Run 29773264312 checked out exact SHA 888c3d9c....

  • Attempt 1, job 88456590526, was infrastructure-inconclusive: GitHub reported that the hosted runner lost server communication during the live Vitest step; the Anthropic log blob and artifact were never produced.
  • The failed-job rerun, job 88468598310, passed 1/1 in 423.54s. Artifact 8475223950 records install-hermes exit 0, the same managed gateway PID (240) before and after the route switch, post-switch health exit 0, and both API and inference.local chat probes exit 0.

That proves the ordinary OPENSHELL_GATEWAY=nemoclaw clean lane can install Hermes, clear managed preflight, sync a compatible Anthropic route, retain the live gateway process, and serve health/chat. It does not exercise port 8990, mcp add, recover, or gateway restart, so the original topology remains open pending a faithful reproduction.

Doctor contradiction candidate

GitHub-verified aaa10aa8aaad50cfc01310a2703f7b9da1621217 is a direct child of 888c3d9c.... It does not claim to repair the topology. It makes doctor run only the bounded, read-only managed-controller probe for registered OpenClaw/Hermes sandboxes and report Managed lifecycle as:

  • ok only for status 0 plus exactly one valid GATEWAY_PID marker and no failure marker;
  • warn for unavailable probe transport or exact SUPERVISOR_BUSY contention;
  • fail for lifecycle/security refusals, contradictions, malformed/ambiguous output, or a missing trusted completion marker.

Only one allowlisted marker and applicable probe stage can reach output; raw controller output, paths, appended exceptions, and environment material are discarded. Candidate verification: 34/34 focused tests, CLI build/type checks, docs build with 0 errors (two pre-existing warnings), and npm run check:diff passed.

dfernandez365-rgb avatar Jul 20 '26 20:07 dfernandez365-rgb

A replacement publication candidate now includes upstream main at 65d78eeb.

The original candidate had one commit-body line longer than the current 100-character limit. This branch uses a fresh verified commit and does not rewrite published history. It also preserves the #7261 command documentation.

Exact-head evidence:

  • npm run build:cli: passed
  • focused Vitest: 2 files, 34 tests passed
  • test/changelog-docs.test.ts: 6 tests passed
  • npm run docs: 0 errors, 2 warnings
  • npm run check:diff: passed, including commitlint, gitleaks, repository checks, and CLI TypeScript
  • changed-text review: no blocking ambiguity under the current Technical English pilot

The topology boundary remains unchanged. Run 29773264312 proves the ordinary managed Hermes route. It does not reproduce port 8990, the PID-1 orphan topology, mcp add, recover, or gateway restart.

dfernandez365-rgb avatar Jul 20 '26 22:07 dfernandez365-rgb

Hi @mill101, thanks for the detailed supervisor and gateway diagnostics. We’re planning an updated architecture for NemoClaw, so we’re closing this earlier custom-port supervisor recovery report as not planned.

If this is still an issue that needs prioritization, please re-open and tag @wscurran.

wscurran avatar Nov 18 '26 03:11 wscurran