Skip to content

fix(sandbox): surface policy-denial logs breadcrumb in connect shells (#5978) - #6018

Merged
apurvvkumaria merged 15 commits into
mainfrom
fix/5978-policy-denial-logs-hint
Jul 1, 2026
Merged

apurvvkumaria merged 15 commits into
mainfrom
fix/5978-policy-denial-logs-hint

Conversation

@yimoj

@yimoj yimoj commented Jun 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Sandbox outbound egress is denied-by-default and enforced by the OpenShell L7 proxy. From inside the sandbox, generic CLIs (curl, git, wget, python) see a policy denial only as the opaque CONNECT tunnel failed, response 403, with no pointer to the detailed allow/deny reason that lives in the NemoClaw logs. This adds a tool-agnostic breadcrumb that points the user to nemoclaw <name> logs --tail 50.

Related Issue

Fixes #5978

Changes

  • scripts/nemoclaw-start.sh: add a # nemoclaw-policy-denial-hint stanza to the /tmp/nemoclaw-proxy-env.sh block already sourced by every interactive/login sandbox shell (via /etc/bash.bashrc and /etc/profile.d/nemoclaw-proxy.sh). It prints a one-line breadcrumb naming the CONNECT tunnel failed, response 403 signature and nemoclaw <name> logs --tail 50.
    • Shown once per top-level interactive TTY session (gated on $- interactive, [ -t 2 ], SHLVL <= 1, a proxy being configured, and a once-per-shell guard so a login shell sourcing both /etc/profile and /etc/bash.bashrc does not double-print). Suppressible with NEMOCLAW_NO_POLICY_HINT=1.
    • The sandbox name is derived from OPENSHELL_SANDBOX (OpenShell ≥0.0.44), falling back to <name> on older versions.
    • It deliberately does not wrap curl/git/wget: wrapping them to scan stderr turns their stderr into a pipe, makes the tools drop progress meters and colour, and still misses python. The informational hint leaves every tool's stdout/stderr/TTY behaviour and exit code byte-for-byte unchanged, while covering generic CLIs — not just Node processes (the explicit risk called out in the issue).
  • test/repro-5978-policy-denial-hint.test.ts: executes the actual emitted stanza (extracted from the single-quoted heredoc, byte-identical to runtime) and asserts the breadcrumb content, name derivation/fallback, the suppress/no-proxy/non-interactive/subshell gates, and single-print on double-source.
  • docs/reference/troubleshooting.mdx: new entry "A request inside the sandbox fails with CONNECT tunnel failed, response 403".

nemoclaw <name> logs --tail 50 already surfaces the merged OpenShell denial line, so no logs-path change is required.

Type of Change

  • Code change with doc updates

Quality Gates

  • Tests added or updated for changed behavior
  • Docs updated for user-facing behavior changes
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — justification: additive, informational stderr output only; no policy/enforcement/credential behaviour changes; tools are not wrapped so their behaviour and exit codes are unchanged.

Verification

Real reporter-workflow E2E with the host CLI, against a sandbox built from this branch (the image bakes in the changed nemoclaw-start.sh):

node ./bin/nemoclaw.js onboard --name issue5978-hint --non-interactive --yes --no-gpu --no-sandbox-gpu --agent openclaw
node ./bin/nemoclaw.js issue5978-hint connect
node ./bin/nemoclaw.js issue5978-hint logs --tail 50

The connect shell printed the breadcrumb, a real curl was denied with CONNECT tunnel failed, response 403, and logs --tail 50 showed the denial reason (DENIED on example.com:443, not in policy). Full transcript in the PR comment.

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Targeted tests pass — vitest run test/repro-5978-policy-denial-hint.test.ts (13 passing incl. the opt-in real-image container E2E; deterministic under env -u SHLVL)
  • Targeted regression tests pass: repro-4538, runtime-env-alias, slack/telegram/plugin-refresh/reconcile, nemoclaw-start, hermes-start
  • shfmt -i 2 -ci -bn clean; Biome clean; tsc -p jsconfig.json clean; source-shape budget 0; codebase-growth-guardrails pass
  • npm run docs builds without warnings
  • No secrets, API keys, or credentials committed

Signed-off-by: Yimo Jiang [email protected]

Summary by CodeRabbit

  • Bug Fixes
    • Improved in-sandbox outbound troubleshooting by showing a clear CONNECT tunnel failed, response 403 breadcrumb with a copyable nemoclaw <name> logs --tail 50 hint.
    • Ensures the hint is emitted only once per interactive top-level shell session, with suppression via NEMOCLAW_NO_POLICY_HINT=1, and avoids duplicate breadcrumbs in the host connect flow.
  • Documentation
    • Expanded the Runtime troubleshooting guide with the new in-sandbox outbound failure section, including how to identify the denied rule and remediate via policy-add <preset> (custom presets supported).
  • Tests
    • Added regression coverage for PTY vs non-PTY behavior, suppression, safe <name> derivation from sandbox labels, and an optional Docker-gated end-to-end check.

Accepted contract (proposed contributor scope)

Per PR Review Advisor PRA-1 (acceptance): the supported behavior for #5978 is a proactive connect-shell + in-sandbox reminder, not a denial-time rewrite of the curl/git/wget error. The denial-time CONNECT tunnel failed, response 403 is emitted by the OpenShell L7 egress proxy (a separate codebase/release), so it cannot be made self-describing from this repo, and wrapping the tools to inject text is rejected (it pipes their stderr — dropping TTY progress/colour, risking exit-code changes — and still misses python). Contributor position: this PR intentionally implements the proactive reminder only; repository reviewers must decide whether that scope is acceptable. It is recorded in code (scripts/nemoclaw-start.sh stanza comment), docs (docs/reference/troubleshooting.mdx), and tests (the "proactive-only contract" assertion in test/repro-5978-policy-denial-hint.test.ts). Removal condition: drop the breadcrumb once OpenShell surfaces a structured, actionable denial at the tunnel-failure site.

Sandbox outbound egress is denied-by-default and enforced by the OpenShell
L7 proxy. From inside the sandbox, generic CLIs (curl, git, wget, python)
see a policy denial only as the opaque "CONNECT tunnel failed, response
403", with no pointer to the detailed allow/deny reason, which lives in the
NemoClaw logs.

Surface a breadcrumb on two complementary surfaces:

- In-sandbox: a `# nemoclaw-policy-denial-hint` stanza emitted into
  /tmp/nemoclaw-proxy-env.sh (sourced by every interactive/login sandbox
  shell), shown once per top-level interactive TTY session and suppressible
  with NEMOCLAW_NO_POLICY_HINT=1. It deliberately does not wrap curl/git/wget
  (wrapping pipes their stderr, dropping TTY progress/colour and missing
  python), so every tool's output and exit code are unchanged. The sandbox
  name comes from OPENSHELL_SANDBOX (sanitized of control characters), with a
  `<name>` fallback on older OpenShell that sets it to "1".

- Host-side: the `nemoclaw <name> connect` one-shot hint now also prints the
  breadcrumb with the real sandbox name, so the reporter's flow gets a
  directly runnable `nemoclaw <name> logs --tail 50` even when the in-sandbox
  value is unavailable.

Adds regression tests (the emitted stanza is executed, plus a real-image
docker E2E behind NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1) and a
troubleshooting doc entry.

Fixes #5978

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj yimoj added area: cli Command line interface, flags, terminal UX, or output area: observability Logging, metrics, tracing, diagnostics, or debug output area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression labels Jun 30, 2026
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Replayed from superseded fork-head PR #5992 (2026-06-29T11:20:48Z).

Reporter-workflow E2E evidence (real sandbox base image)

This fix's surface is the in-sandbox connect shell, so there is no host nemoclaw <name> CLI command in its code path — it is shell init emitted into /tmp/nemoclaw-proxy-env.sh and sourced by the image's own /etc/profile.d/nemoclaw-proxy.sh and /etc/bash.bashrc. I exercised the exact reporter workflow end-to-end against the real ghcr.io/nvidia/nemoclaw/sandbox-base:latest image, with a 403-on-CONNECT proxy reproducing the OpenShell L7 denial:

--- image hooks present? ---
/etc/profile.d/nemoclaw-proxy.sh
/etc/bash.bashrc
=== REPORTER WORKFLOW: interactive login connect shell (real image hooks) ===
  Note: this sandbox restricts outbound network access by policy.
  Blocked requests fail with 'CONNECT tunnel failed, response 403'.
  See which rule denied a request:  nemoclaw qa-5978 logs --tail 50
[user] $ curl -sS https://example.com/
curl: (56) CONNECT tunnel failed, response 403
[user] $ git clone https://example.com/foo/bar
Cloning into 'bar'...

The breadcrumb is emitted once at connect-shell init by the real image hooks (dedup holds even though both /etc/profile.d and /etc/bash.bashrc source the file), and a real curl/git surfaces the exact CONNECT tunnel failed, response 403 signature the breadcrumb names.

This is codified as an opt-in container E2E (it.skipIf — skipped in normal CI, mirroring the docker E2E gating in test/repro-4538-raw-doctor-perms.test.ts):

NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run \
  test/repro-5978-policy-denial-hint.test.ts --project integration
# → 11 passed (includes "real base image: connect shell shows the breadcrumb once and curl is denied with 403")

A full nemoclaw onboard/connect against a live provisioned sandbox additionally requires provider credentials/GPU and exercises the same image hooks; the container E2E above isolates and proves the connect-shell surface this PR changes.

@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Replayed from superseded fork-head PR #5992 (2026-06-29T12:32:47Z).

Real host-CLI E2E — reporter workflow against a worktree-built sandbox

Stood up an isolated sandbox built from this branch (so the image bakes in the changed scripts/nemoclaw-start.sh) and drove the exact reporter workflow with the real nemoclaw CLI:

$ NEMOCLAW_PROVIDER=ollama NEMOCLAW_MODEL=qwen2.5:0.5b NEMOCLAW_YES=1 \
    node ./bin/nemoclaw.js onboard --name issue5978-hint --non-interactive --yes \
    --no-gpu --no-sandbox-gpu --no-ollama-autostart --agent openclaw
  ... ✓ Sandbox 'issue5978-hint' created   (policies: npm, pypi, huggingface, brew, weather, local-inference, openclaw-pricing)

$ node ./bin/nemoclaw.js issue5978-hint connect
  ✓ Connecting to sandbox 'issue5978-hint'
  Inside the sandbox, run `openclaw tui` to start chatting with the agent.
  Type `/exit` to leave the chat, then `exit` to return to the host shell.
  Note: this sandbox restricts outbound network access by policy.
  Blocked requests fail with 'CONNECT tunnel failed, response 403'.
  See which rule denied a request:  nemoclaw <name> logs --tail 50
$ curl -sS https://example.com/
curl: (56) CONNECT tunnel failed, response 403

$ node ./bin/nemoclaw.js issue5978-hint logs --tail 50
[sandbox] [OCSF] NET:OPEN [MED] DENIED /usr/bin/curl(1614) -> example.com:443 \
  [policy:- engine:opa] [reason:endpoint example.com:443 not in policy 'brew'; ...]

This proves the full acceptance criteria end-to-end through the host CLI: the breadcrumb appears in the nemoclaw connect shell, a real curl is denied with the 403 signature, and nemoclaw <name> logs --tail 50 shows the denial reason (DENIED ... example.com:443 ... not in policy).

Note on the <name> placeholder: on the OpenShell build used here, OPENSHELL_SANDBOX=1 (not the sandbox name) and the container hostname is the container ID, so the label uses the documented <name> fallback (resolve via nemoclaw list). On OpenShell ≥0.0.44, which sets OPENSHELL_SANDBOX to the sandbox name, the breadcrumb prints the real name. The placeholder matches the CLI's existing <name>/<sandbox> help-text convention.

@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Replayed from superseded fork-head PR #5992 (2026-06-29T18:19:44Z).

Follow-up (head fcc75cce7): based on the real-CLI E2E finding that the deployed OpenShell sets OPENSHELL_SANDBOX=1 (so the in-sandbox breadcrumb falls back to the <name> placeholder), I added a host-side companion in src/lib/actions/sandbox/connect.ts. The nemoclaw <name> connect one-shot hint now also prints the breadcrumb with the real sandbox name via the unit-tested buildPolicyDenialConnectHint() helper, so the reporter's exact flow gets a directly runnable nemoclaw <name> logs --tail 50. Same NEMOCLAW_NO_POLICY_HINT=1 suppression. New connect-policy-hint.test.ts covers it.

@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Replayed from superseded fork-head PR #5992 (2026-06-29T18:26:42Z).

Addressed the CodeRabbit nitpick: the breadcrumb tests no longer call the shell-private _nemoclaw_policy_denial_hint_label/_text helpers. All name-derivation, <name> fallback, control-char sanitization, and 403/logs --tail 50 cases now drive the public gate _nemoclaw_maybe_policy_denial_hint under a PTY and assert the user-visible breadcrumb (observable outcome through the boundary). 12 passing incl. the opt-in real-image docker E2E.

@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@github-code-quality

github-code-quality Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the fix/5978-policy-deni... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/5978-policy-deni... 8ccd7a1 +/-
nemoclaw/src/se...cret-scanner.ts — 100% —
nemoclaw/src/commands/slash.ts — 100% —
nemoclaw/src/li...bprocess-env.ts — 100% —
nemoclaw/src/bl...eprint/state.ts — 98% —
nemoclaw/src/onboard/config.ts — 98% —
nemoclaw/src/bl...int/snapshot.ts — 97% —
nemoclaw/src/bl...print/runner.ts — 95% —
nemoclaw/src/co...ration-state.ts — 94% —
nemoclaw/src/bl...ate-networks.ts — 94% —
nemoclaw/src/index.ts — 94% —

TypeScript / code-coverage/cli

The overall coverage in the fix/5978-policy-deni... branch is 68%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/5978-policy-deni... 8ccd7a1 +/-
src/lib/shields...nsition-lock.ts — 86% —
src/lib/actions...dbox/rebuild.ts — 80% —
src/lib/actions...all/run-plan.ts — 80% —
src/lib/state/o...oard-session.ts — 80% —
src/lib/state/sandbox.ts — 72% —
src/lib/shields/index.ts — 69% —
src/lib/onboard/preflight.ts — 69% —
src/lib/onboard...er-gpu-patch.ts — 59% —
src/lib/actions...licy-channel.ts — 58% —
src/lib/onboard.ts — 20% —

Updated July 01, 2026 19:59 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — Changes requested

Merge posture: Do not merge yet
Primary next action: Resolve or justify PRA-1: Source-of-truth review needed: `SHLVL` top-level-shell gate.
Open items: 0 required · 2 warnings · 0 suggestions · 5 test follow-ups
Since last review: 0 prior items resolved · 1 still applies · 0 new items found

Action checklist

  • PRA-1 Resolve or justify: Source-of-truth review needed: `SHLVL` top-level-shell gate
  • PRA-2 Resolve or justify: Validate SHLVL before the policy-hint numeric gate in scripts/nemoclaw-start.sh:3400
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Runtime validation
  • PRA-T4 Add or justify test follow-up: Runtime validation
  • PRA-T5 Add or justify test follow-up: `SHLVL` top-level-shell gate

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture — Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-2 Resolve/justify correctness scripts/nemoclaw-start.sh:3400 Validate `SHLVL` with a shell allowlist before the `-le` comparison. For example, normalize empty to `1`, accept only all-digit values for comparison, and return silently for any other value before reaching `-le`.
Review findings by urgency: 0 required fixes, 2 items to resolve/justify, 0 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Source-of-truth review needed: `SHLVL` top-level-shell gate

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; add a PTY test that sets `SHLVL=not-a-number` and asserts the stanza remains silent without a shell integer-comparison diagnostic.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `scripts/nemoclaw-start.sh:3400` compares `${SHLVL:-1}` with `-le` directly. This is already covered by the current finding.

PRA-2 Resolve/justify — Validate SHLVL before the policy-hint numeric gate

  • Location: scripts/nemoclaw-start.sh:3400
  • Category: correctness
  • Problem: The new interactive-shell policy hint gates top-level sessions with `[ "${SHLVL:-1}" -le 1 ]` without first proving that `SHLVL` is numeric. `SHLVL` is an inherited shell environment value and can be malformed; in that case bash emits an integer-comparison diagnostic while sourcing the connect-shell environment, even though non-qualifying shells are intended to stay quiet.
  • Impact: A malformed `SHLVL` can add confusing startup noise to the user’s interactive sandbox shell and obscure the new policy-denial breadcrumb with what looks like a shell/runtime error. This is also the remaining security-review warning for tolerant parsing of untrusted shell environment in sandbox startup glue; it is not a confirmed policy bypass or sandbox escape.
  • Recommended action: Validate `SHLVL` with a shell allowlist before the `-le` comparison. For example, normalize empty to `1`, accept only all-digit values for comparison, and return silently for any other value before reaching `-le`.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read `scripts/nemoclaw-start.sh` around `_nemoclaw_maybe_policy_denial_hint` and confirm that non-numeric `SHLVL` values are rejected by a `case`/pattern guard before any numeric comparison is evaluated.
  • Missing regression test: Add a PTY-based regression in `test/repro-5978-policy-denial-hint.test.ts` that sources the emitted stanza with `SHLVL=not-a-number`, proxy variables set, and an interactive TTY, then asserts no breadcrumb and no `integer expression expected` or similar diagnostic is printed.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read `scripts/nemoclaw-start.sh` around `_nemoclaw_maybe_policy_denial_hint` and confirm that non-numeric `SHLVL` values are rejected by a `case`/pattern guard before any numeric comparison is evaluated.
  • Evidence: `_nemoclaw_maybe_policy_denial_hint` currently does `[ "${SHLVL:-1}" -le 1 ] || return 0` directly after the TTY gate.

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

  • None.
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Add a PTY shell-stanza regression where `SHLVL=not-a-number` is set in an interactive proxied shell and assert the hint stays silent without `integer expression expected` or any other numeric-comparison diagnostic.. The always-run tests execute the actual emitted shell stanza under PTY and cover many security-relevant negative paths, which is strong for the local change. The changed behavior still lives in sandbox connect/runtime shell plumbing and base-image hooks, so a real runtime signal would improve confidence; the PR includes an opt-in Docker/image scenario but it is skipped by default.
  • PRA-T2 Runtime validation — Add or identify required runtime/integration validation where a real `nemoclaw <name> connect` or `openshell sandbox connect <name>` shell naturally sources `/tmp/nemoclaw-proxy-env.sh`, uses its natural `SHLVL`, and prints exactly one policy-denial breadcrumb.. The always-run tests execute the actual emitted shell stanza under PTY and cover many security-relevant negative paths, which is strong for the local change. The changed behavior still lives in sandbox connect/runtime shell plumbing and base-image hooks, so a real runtime signal would improve confidence; the PR includes an opt-in Docker/image scenario but it is skipped by default.
  • PRA-T3 Runtime validation — Add or identify runtime evidence for a default-policy sandbox where a blocked `curl` request produces the native `CONNECT tunnel failed, response 403` while the proactive breadcrumb has already pointed to the logs command.. The always-run tests execute the actual emitted shell stanza under PTY and cover many security-relevant negative paths, which is strong for the local change. The changed behavior still lives in sandbox connect/runtime shell plumbing and base-image hooks, so a real runtime signal would improve confidence; the PR includes an opt-in Docker/image scenario but it is skipped by default.
  • PRA-T4 Runtime validation — Add or identify coverage showing the recommended `nemoclaw <name> logs --tail 50` path includes the policy-denial reason for a denied CONNECT request.. The always-run tests execute the actual emitted shell stanza under PTY and cover many security-relevant negative paths, which is strong for the local change. The changed behavior still lives in sandbox connect/runtime shell plumbing and base-image hooks, so a real runtime signal would improve confidence; the PR includes an opt-in Docker/image scenario but it is skipped by default.
  • PRA-T5 `SHLVL` top-level-shell gate — Missing; add a PTY test that sets `SHLVL=not-a-number` and asserts the stanza remains silent without a shell integer-comparison diagnostic.. `scripts/nemoclaw-start.sh:3400` compares `${SHLVL:-1}` with `-le` directly. This is already covered by the current finding.
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Source-of-truth review needed: `SHLVL` top-level-shell gate

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: Missing; add a PTY test that sets `SHLVL=not-a-number` and asserts the stanza remains silent without a shell integer-comparison diagnostic.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: `scripts/nemoclaw-start.sh:3400` compares `${SHLVL:-1}` with `-le` directly. This is already covered by the current finding.

PRA-2 Resolve/justify — Validate SHLVL before the policy-hint numeric gate

  • Location: scripts/nemoclaw-start.sh:3400
  • Category: correctness
  • Problem: The new interactive-shell policy hint gates top-level sessions with `[ "${SHLVL:-1}" -le 1 ]` without first proving that `SHLVL` is numeric. `SHLVL` is an inherited shell environment value and can be malformed; in that case bash emits an integer-comparison diagnostic while sourcing the connect-shell environment, even though non-qualifying shells are intended to stay quiet.
  • Impact: A malformed `SHLVL` can add confusing startup noise to the user’s interactive sandbox shell and obscure the new policy-denial breadcrumb with what looks like a shell/runtime error. This is also the remaining security-review warning for tolerant parsing of untrusted shell environment in sandbox startup glue; it is not a confirmed policy bypass or sandbox escape.
  • Recommended action: Validate `SHLVL` with a shell allowlist before the `-le` comparison. For example, normalize empty to `1`, accept only all-digit values for comparison, and return silently for any other value before reaching `-le`.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read `scripts/nemoclaw-start.sh` around `_nemoclaw_maybe_policy_denial_hint` and confirm that non-numeric `SHLVL` values are rejected by a `case`/pattern guard before any numeric comparison is evaluated.
  • Missing regression test: Add a PTY-based regression in `test/repro-5978-policy-denial-hint.test.ts` that sources the emitted stanza with `SHLVL=not-a-number`, proxy variables set, and an interactive TTY, then asserts no breadcrumb and no `integer expression expected` or similar diagnostic is printed.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read `scripts/nemoclaw-start.sh` around `_nemoclaw_maybe_policy_denial_hint` and confirm that non-numeric `SHLVL` values are rejected by a `case`/pattern guard before any numeric comparison is evaluated.
  • Evidence: `_nemoclaw_maybe_policy_denial_hint` currently does `[ "${SHLVL:-1}" -le 1 ] || return 0` directly after the TTY gate.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: network-policy, sandbox-rlimits-connect
Optional E2E: sandbox-operations, cloud-onboard

Dispatch hint: network-policy,sandbox-rlimits-connect

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • network-policy (high): Required because the PR changes user-facing behavior for denied-by-default sandbox egress and the logs guidance for CONNECT 403 denials. This live job onboards a restricted OpenClaw sandbox, mutates live network policy, probes denied egress from inside the sandbox, and verifies denied requests are diagnosable via nemoclaw logs --tail 50.
  • sandbox-rlimits-connect (high): Required because the runtime change is sourced by connect shells. This explicit live connect-shell job exercises nemoclaw <name> connect against a real sandbox and is the closest existing E2E coverage for connect-session startup behavior and shell environment regressions.

Optional E2E

  • sandbox-operations (high): Useful adjacent confidence because this PR touches sandbox runtime shell/startup plumbing and user diagnostics. The job validates real sandbox list/status/logs, logs streaming, PTY lifecycle, gateway recovery, and multi-sandbox behavior.
  • cloud-onboard (high): Optional broader confidence for full hosted OpenClaw onboarding and real assistant user flow after changing scripts/nemoclaw-start.sh, which is part of the sandbox runtime image/startup path.

New E2E recommendations

  • interactive-connect-policy-denial-hint (high): Existing live E2E covers network-policy denial/logs and real connect shells separately, but no existing required E2E asserts the new proactive hint in a real top-level interactive nemoclaw connect PTY while an egress proxy is configured, nor that denied curl/git keep their native CONNECT 403 errors in that same real connect session. The added Docker scenario is opt-in/skipped, so it will not gate CI.
    • Suggested test: Add or promote a live policy-denial-connect-hint target that opens a real interactive connect PTY, verifies the hint appears exactly once with a safe sandbox label, verifies suppression/noninteractive silence, and verifies denied curl/git errors and exit codes remain native.

Dispatch hint

  • Workflow: .github/workflows/e2e.yaml
  • jobs input: network-policy,sandbox-rlimits-connect

@github-actions

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: sandbox-rlimits-connect-vitest
Optional Vitest E2E scenarios: None

Dispatch required Vitest E2E scenarios:

  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=sandbox-rlimits-connect-vitest

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: medium

Required Vitest E2E scenarios

  • sandbox-rlimits-connect-vitest: The PR changes both the host-side nemoclaw <name> connect hint and the in-sandbox startup stanza emitted by scripts/nemoclaw-start.sh. The discrete live Vitest connect job drives a real onboarded sandbox through nemoclaw <sandbox> connect, making it the smallest wired Vitest scenario surface for connect-shell regressions.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field jobs=sandbox-rlimits-connect-vitest

Optional Vitest E2E scenarios

  • None.

Relevant changed files

  • scripts/nemoclaw-start.sh
  • src/lib/actions/sandbox/connect.ts

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor (Nemotron Ultra) — Changes requested

Merge posture: Do not merge yet
Primary next action: Fix PRA-1: Docker E2E test remains opt-in, not running in CI; then add or justify PRA-T1.
Open items: 2 required · 2 warnings · 2 suggestions · 5 test follow-ups
Since last review: 0 prior items resolved · 2 still apply · 3 new items found

Action checklist

  • PRA-1 Fix: Docker E2E test remains opt-in, not running in CI in test/repro-5978-policy-denial-hint.test.ts:315
  • PRA-2 Fix: OPENSHELL_SANDBOX allowlist mirrors NAME_VALID_PATTERN but drift detection only in test in scripts/nemoclaw-start.sh:3347
  • PRA-3 Resolve or justify: Documentation mentions NEMOCLAW_NO_POLICY_HINT=1 suppression but not all supported values in docs/reference/troubleshooting.mdx:780
  • PRA-4 Resolve or justify: Comment omits allowlist fallback for invalid sandbox names in src/lib/actions/sandbox/connect.ts:1127
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Docker E2E test remains opt-in, not running in CI
  • PRA-T4 Add or justify test follow-up: Opt-in Docker E2E rationale documented but no automation to revisit
  • PRA-T5 Add or justify test follow-up: Add build-time drift guard for shell allowlist vs NAME_VALID_PATTERN
  • PRA-5 In-scope improvement: Opt-in Docker E2E rationale documented but no automation to revisit in test/repro-5978-policy-denial-hint.test.ts:38
  • PRA-6 In-scope improvement: Add build-time drift guard for shell allowlist vs NAME_VALID_PATTERN in scripts/nemoclaw-start.sh:3347

Findings index

ID Severity Category Location Required action
PRA-1 Required tests test/repro-5978-policy-denial-hint.test.ts:315 Promote the opt-in Docker E2E to a required integration test job when infrastructure supports it reliably, or add a periodic CI signal (e.g., nightly workflow). If neither is feasible now, the documented rationale is acceptable but should be revisited when a dedicated integration lane exists.
PRA-2 Required security scripts/nemoclaw-start.sh:3347 Add a build-time or lint check that extracts the shell allowlist pattern and asserts it matches NAME_VALID_PATTERN, or generate the shell pattern from the TypeScript source.
PRA-3 Resolve/justify docs docs/reference/troubleshooting.mdx:780 Update the troubleshooting doc to list all accepted values: 1, true, TRUE, yes, YES.
PRA-4 Resolve/justify correctness src/lib/actions/sandbox/connect.ts:1127 Update the comment to mention the allowlist fallback: 'the stanza shows the real sandbox name on supported OpenShell when OPENSHELL_SANDBOX passes the NAME_VALID_PATTERN allowlist; otherwise it shows <name>.'
PRA-5 Improvement tests test/repro-5978-policy-denial-hint.test.ts:38 Add a GitHub issue or a dated TODO comment with a revisit target (e.g., 'Revisit when integration test lane lands — see #XXXX') so the team has a concrete reminder.
PRA-6 Improvement tests scripts/nemoclaw-start.sh:3347 Add a small script (e.g., in package.json prepare or a biome/lint rule) that parses the shell allowlist from nemoclaw-start.sh and compares it to NAME_VALID_PATTERN from name-validation.ts.

🚨 Required before merge

Address these before merging unless a maintainer explicitly overrides the advisor with rationale.

PRA-1 Required — Docker E2E test remains opt-in, not running in CI

  • Location: test/repro-5978-policy-denial-hint.test.ts:315
  • Category: tests
  • Problem: The Docker E2E test (lines 315-360) provides the only runtime validation against the real sandbox base image with live 403-on-CONNECT proxy, real /etc/profile.d + /etc/bash.bashrc hooks, and natural SHLVL. It is gated by NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 and not executed in any CI workflow, creating a coverage gap for runtime behavior (PTY behavior, base-image shell hooks, real tool exit codes). Carried over from prior review.
  • Impact: A regression in the real image integration path (PTY behavior, shell hook ordering, native tool exit codes under denial) could go undetected until a maintainer manually runs the opt-in test.
  • Required action: Promote the opt-in Docker E2E to a required integration test job when infrastructure supports it reliably, or add a periodic CI signal (e.g., nightly workflow). If neither is feasible now, the documented rationale is acceptable but should be revisited when a dedicated integration lane exists.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Check if NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 is set in any .github/workflows/*.yaml; currently it is not. Run locally with NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration.
  • Missing regression test: Add a nightly GitHub Actions workflow that runs NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration, or promote to a required integration job when infrastructure supports the sandbox base image reliably.
  • Done when: The required change is committed and verification passes: Check if NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 is set in any .github/workflows/*.yaml; currently it is not. Run locally with NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration.
  • Evidence: test/repro-5978-policy-denial-hint.test.ts:38-55 (rationale), 315-360 (Docker E2E test); no .github/workflows/*.yaml references NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E

PRA-2 Required — OPENSHELL_SANDBOX allowlist mirrors NAME_VALID_PATTERN but drift detection only in test

  • Location: scripts/nemoclaw-start.sh:3347
  • Category: security
  • Problem: The shell allowlist in _nemoclaw_policy_denial_hint_label() hand-mirrors NAME_VALID_PATTERN from src/lib/name-validation.ts. The anti-drift test (line 248 in test file) catches divergence at test time, but there is no build-time or CI guard that fails if the TypeScript pattern changes and the shell pattern is not updated. Carried over from prior review.
  • Impact: If NAME_VALID_PATTERN changes (e.g., to allow uppercase or underscores) and the shell allowlist is not updated, valid sandbox names could be rejected (fallback to <name>) or invalid names could be accepted (injection risk).
  • Required action: Add a build-time or lint check that extracts the shell allowlist pattern and asserts it matches NAME_VALID_PATTERN, or generate the shell pattern from the TypeScript source.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'
  • Missing regression test: Add a build-time validation (e.g., a small script in package.json prepare or a biome/lint rule) that parses the shell case pattern and compares it to NAME_VALID_PATTERN.
  • Done when: The required change is committed and verification passes: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'.
  • Evidence: scripts/nemoclaw-start.sh:3347-3375 (shell allowlist); src/lib/name-validation.ts:9 (NAME_VALID_PATTERN); test/repro-5978-policy-denial-hint.test.ts:248-275 (anti-drift test)
Review findings by urgency: 2 required fixes, 2 items to resolve/justify, 2 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-3 Resolve/justify — Documentation mentions NEMOCLAW_NO_POLICY_HINT=1 suppression but not all supported values

  • Location: docs/reference/troubleshooting.mdx:780
  • Category: docs
  • Problem: The troubleshooting docs say 'Suppress it with NEMOCLAW_NO_POLICY_HINT=1' but the shell implementation accepts 1, true, TRUE, yes, YES (case-insensitive). The docs should reflect the full set of accepted values for consistency. Carried over from prior review — not fixed.
  • Impact: Users trying TRUE or yes may think suppression doesn't work.
  • Recommended action: Update the troubleshooting doc to list all accepted values: 1, true, TRUE, yes, YES.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check the case statement in scripts/nemoclaw-start.sh:3375: case "${NEMOCLAW_NO_POLICY_HINT:-}" in 1 | true | TRUE | yes | YES) return 0 ;; esac
  • Missing regression test: None — doc consistency issue.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check the case statement in scripts/nemoclaw-start.sh:3375: case "${NEMOCLAW_NO_POLICY_HINT:-}" in 1 | true | TRUE | yes | YES) return 0 ;; esac.
  • Evidence: docs/reference/troubleshooting.mdx:780; scripts/nemoclaw-start.sh:3375

PRA-4 Resolve/justify — Comment omits allowlist fallback for invalid sandbox names

  • Location: src/lib/actions/sandbox/connect.ts:1127
  • Category: correctness
  • Problem: The comment claims 'the stanza shows the real sandbox name on supported OpenShell (it reads OPENSHELL_SANDBOX)' but omits the allowlist fallback: when OPENSHELL_SANDBOX contains invalid characters (uppercase, underscore, control chars, >63 chars), it shows <name> placeholder. Carried over from prior review — not fixed.
  • Impact: Maintainers reading the comment may assume the real name is always shown on supported OpenShell, missing the safety fallback.
  • Recommended action: Update the comment to mention the allowlist fallback: 'the stanza shows the real sandbox name on supported OpenShell when OPENSHELL_SANDBOX passes the NAME_VALID_PATTERN allowlist; otherwise it shows <name>.'
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the comment at src/lib/actions/sandbox/connect.ts:1125-1129 and compare with the shell allowlist logic at scripts/nemoclaw-start.sh:3347-3375.
  • Missing regression test: None — comment accuracy issue.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the comment at src/lib/actions/sandbox/connect.ts:1125-1129 and compare with the shell allowlist logic at scripts/nemoclaw-start.sh:3347-3375.
  • Evidence: src/lib/actions/sandbox/connect.ts:1125-1129; scripts/nemoclaw-start.sh:3347-3375

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

PRA-5 Improvement — Opt-in Docker E2E rationale documented but no automation to revisit

  • Location: test/repro-5978-policy-denial-hint.test.ts:38
  • Category: tests
  • Problem: The test header documents why the Docker E2E stays opt-in (requires Docker daemon + multi-hundred-MB base image, not provisioned in fast CI lanes) but there is no issue, TODO, or scheduled reminder to revisit this when a dedicated integration lane exists. Carried over from prior review.
  • Impact: The opt-in status could persist indefinitely without a trigger to re-evaluate.
  • Suggested action: Add a GitHub issue or a dated TODO comment with a revisit target (e.g., 'Revisit when integration test lane lands — see #XXXX') so the team has a concrete reminder.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for TODO or FIXME comments in the test file related to the Docker E2E promotion.
  • Missing regression test: Not a test gap — a process gap. Link a follow-up issue from the test header comment.
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: test/repro-5978-policy-denial-hint.test.ts:38-55 (rationale documentation)

PRA-6 Improvement — Add build-time drift guard for shell allowlist vs NAME_VALID_PATTERN

  • Location: scripts/nemoclaw-start.sh:3347
  • Category: tests
  • Problem: The shell allowlist hand-mirrors NAME_VALID_PATTERN. A build-time script that extracts the shell case pattern and asserts it matches the TypeScript regex would catch drift earlier than the existing test-time anti-drift check.
  • Impact: Earlier detection of pattern divergence reduces risk of valid names rejected or invalid names accepted between test runs.
  • Suggested action: Add a small script (e.g., in package.json prepare or a biome/lint rule) that parses the shell allowlist from nemoclaw-start.sh and compares it to NAME_VALID_PATTERN from name-validation.ts.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'
  • Missing regression test: Add a build-time validation script that parses the shell case pattern and compares it to NAME_VALID_PATTERN.
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: scripts/nemoclaw-start.sh:3347-3375 (shell allowlist); src/lib/name-validation.ts:9 (NAME_VALID_PATTERN); test/repro-5978-policy-denial-hint.test.ts:248-275 (anti-drift test)
Simplification opportunities: 1 possible cut

These are safe simplification checks only. Do not remove validation, security controls, data-loss prevention, or required tests.

  • PRA-6 shrink (scripts/nemoclaw-start.sh:3347): Manual hand-mirroring of NAME_VALID_PATTERN in shell case statement
    • Replacement: Generated shell pattern from TypeScript source, or build-time assertion script
    • Net: 0 lines
    • Safety boundary: Must preserve LC_ALL=C ASCII matching and exact RFC-1123 label semantics
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Build-time drift guard: script that extracts shell allowlist pattern from nemoclaw-start.sh and asserts it matches NAME_VALID_PATTERN from name-validation.ts, run in CI.. Runtime/sandbox/infrastructure paths need behavioral runtime validation: docs/reference/troubleshooting.mdx, scripts/nemoclaw-start.sh, src/lib/actions/sandbox/connect.ts. The opt-in Docker E2E provides real-image validation but is not in CI.
  • PRA-T2 Runtime validation — Nightly GitHub Actions workflow that runs the opt-in Docker E2E test against the real sandbox base image.. Runtime/sandbox/infrastructure paths need behavioral runtime validation: docs/reference/troubleshooting.mdx, scripts/nemoclaw-start.sh, src/lib/actions/sandbox/connect.ts. The opt-in Docker E2E provides real-image validation but is not in CI.
  • PRA-T3 Docker E2E test remains opt-in, not running in CI — Promote the opt-in Docker E2E to a required integration test job when infrastructure supports it reliably, or add a periodic CI signal (e.g., nightly workflow). If neither is feasible now, the documented rationale is acceptable but should be revisited when a dedicated integration lane exists.
  • PRA-T4 Opt-in Docker E2E rationale documented but no automation to revisit — Add a GitHub issue or a dated TODO comment with a revisit target (e.g., 'Revisit when integration test lane lands — see #XXXX') so the team has a concrete reminder.
  • PRA-T5 Add build-time drift guard for shell allowlist vs NAME_VALID_PATTERN — Add a small script (e.g., in package.json prepare or a biome/lint rule) that parses the shell allowlist from nemoclaw-start.sh and compares it to NAME_VALID_PATTERN from name-validation.ts.
Since last review details

Current findings, using the urgency labels above:

PRA-1 Required — Docker E2E test remains opt-in, not running in CI

  • Location: test/repro-5978-policy-denial-hint.test.ts:315
  • Category: tests
  • Problem: The Docker E2E test (lines 315-360) provides the only runtime validation against the real sandbox base image with live 403-on-CONNECT proxy, real /etc/profile.d + /etc/bash.bashrc hooks, and natural SHLVL. It is gated by NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 and not executed in any CI workflow, creating a coverage gap for runtime behavior (PTY behavior, base-image shell hooks, real tool exit codes). Carried over from prior review.
  • Impact: A regression in the real image integration path (PTY behavior, shell hook ordering, native tool exit codes under denial) could go undetected until a maintainer manually runs the opt-in test.
  • Required action: Promote the opt-in Docker E2E to a required integration test job when infrastructure supports it reliably, or add a periodic CI signal (e.g., nightly workflow). If neither is feasible now, the documented rationale is acceptable but should be revisited when a dedicated integration lane exists.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Check if NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 is set in any .github/workflows/*.yaml; currently it is not. Run locally with NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration.
  • Missing regression test: Add a nightly GitHub Actions workflow that runs NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration, or promote to a required integration job when infrastructure supports the sandbox base image reliably.
  • Done when: The required change is committed and verification passes: Check if NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 is set in any .github/workflows/*.yaml; currently it is not. Run locally with NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1 vitest run test/repro-5978-policy-denial-hint.test.ts --project integration.
  • Evidence: test/repro-5978-policy-denial-hint.test.ts:38-55 (rationale), 315-360 (Docker E2E test); no .github/workflows/*.yaml references NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E

PRA-2 Required — OPENSHELL_SANDBOX allowlist mirrors NAME_VALID_PATTERN but drift detection only in test

  • Location: scripts/nemoclaw-start.sh:3347
  • Category: security
  • Problem: The shell allowlist in _nemoclaw_policy_denial_hint_label() hand-mirrors NAME_VALID_PATTERN from src/lib/name-validation.ts. The anti-drift test (line 248 in test file) catches divergence at test time, but there is no build-time or CI guard that fails if the TypeScript pattern changes and the shell pattern is not updated. Carried over from prior review.
  • Impact: If NAME_VALID_PATTERN changes (e.g., to allow uppercase or underscores) and the shell allowlist is not updated, valid sandbox names could be rejected (fallback to <name>) or invalid names could be accepted (injection risk).
  • Required action: Add a build-time or lint check that extracts the shell allowlist pattern and asserts it matches NAME_VALID_PATTERN, or generate the shell pattern from the TypeScript source.
  • Expected follow-up: Fix before merge or get explicit maintainer override.
  • Verification: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'
  • Missing regression test: Add a build-time validation (e.g., a small script in package.json prepare or a biome/lint rule) that parses the shell case pattern and compares it to NAME_VALID_PATTERN.
  • Done when: The required change is committed and verification passes: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'.
  • Evidence: scripts/nemoclaw-start.sh:3347-3375 (shell allowlist); src/lib/name-validation.ts:9 (NAME_VALID_PATTERN); test/repro-5978-policy-denial-hint.test.ts:248-275 (anti-drift test)

PRA-3 Resolve/justify — Documentation mentions NEMOCLAW_NO_POLICY_HINT=1 suppression but not all supported values

  • Location: docs/reference/troubleshooting.mdx:780
  • Category: docs
  • Problem: The troubleshooting docs say 'Suppress it with NEMOCLAW_NO_POLICY_HINT=1' but the shell implementation accepts 1, true, TRUE, yes, YES (case-insensitive). The docs should reflect the full set of accepted values for consistency. Carried over from prior review — not fixed.
  • Impact: Users trying TRUE or yes may think suppression doesn't work.
  • Recommended action: Update the troubleshooting doc to list all accepted values: 1, true, TRUE, yes, YES.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Check the case statement in scripts/nemoclaw-start.sh:3375: case "${NEMOCLAW_NO_POLICY_HINT:-}" in 1 | true | TRUE | yes | YES) return 0 ;; esac
  • Missing regression test: None — doc consistency issue.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Check the case statement in scripts/nemoclaw-start.sh:3375: case "${NEMOCLAW_NO_POLICY_HINT:-}" in 1 | true | TRUE | yes | YES) return 0 ;; esac.
  • Evidence: docs/reference/troubleshooting.mdx:780; scripts/nemoclaw-start.sh:3375

PRA-4 Resolve/justify — Comment omits allowlist fallback for invalid sandbox names

  • Location: src/lib/actions/sandbox/connect.ts:1127
  • Category: correctness
  • Problem: The comment claims 'the stanza shows the real sandbox name on supported OpenShell (it reads OPENSHELL_SANDBOX)' but omits the allowlist fallback: when OPENSHELL_SANDBOX contains invalid characters (uppercase, underscore, control chars, >63 chars), it shows <name> placeholder. Carried over from prior review — not fixed.
  • Impact: Maintainers reading the comment may assume the real name is always shown on supported OpenShell, missing the safety fallback.
  • Recommended action: Update the comment to mention the allowlist fallback: 'the stanza shows the real sandbox name on supported OpenShell when OPENSHELL_SANDBOX passes the NAME_VALID_PATTERN allowlist; otherwise it shows <name>.'
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read the comment at src/lib/actions/sandbox/connect.ts:1125-1129 and compare with the shell allowlist logic at scripts/nemoclaw-start.sh:3347-3375.
  • Missing regression test: None — comment accuracy issue.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read the comment at src/lib/actions/sandbox/connect.ts:1125-1129 and compare with the shell allowlist logic at scripts/nemoclaw-start.sh:3347-3375.
  • Evidence: src/lib/actions/sandbox/connect.ts:1125-1129; scripts/nemoclaw-start.sh:3347-3375

PRA-5 Improvement — Opt-in Docker E2E rationale documented but no automation to revisit

  • Location: test/repro-5978-policy-denial-hint.test.ts:38
  • Category: tests
  • Problem: The test header documents why the Docker E2E stays opt-in (requires Docker daemon + multi-hundred-MB base image, not provisioned in fast CI lanes) but there is no issue, TODO, or scheduled reminder to revisit this when a dedicated integration lane exists. Carried over from prior review.
  • Impact: The opt-in status could persist indefinitely without a trigger to re-evaluate.
  • Suggested action: Add a GitHub issue or a dated TODO comment with a revisit target (e.g., 'Revisit when integration test lane lands — see #XXXX') so the team has a concrete reminder.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Search for TODO or FIXME comments in the test file related to the Docker E2E promotion.
  • Missing regression test: Not a test gap — a process gap. Link a follow-up issue from the test header comment.
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: test/repro-5978-policy-denial-hint.test.ts:38-55 (rationale documentation)

PRA-6 Improvement — Add build-time drift guard for shell allowlist vs NAME_VALID_PATTERN

  • Location: scripts/nemoclaw-start.sh:3347
  • Category: tests
  • Problem: The shell allowlist hand-mirrors NAME_VALID_PATTERN. A build-time script that extracts the shell case pattern and asserts it matches the TypeScript regex would catch drift earlier than the existing test-time anti-drift check.
  • Impact: Earlier detection of pattern divergence reduces risk of valid names rejected or invalid names accepted between test runs.
  • Suggested action: Add a small script (e.g., in package.json prepare or a biome/lint rule) that parses the shell allowlist from nemoclaw-start.sh and compares it to NAME_VALID_PATTERN from name-validation.ts.
  • Expected follow-up: Prefer a current-PR fix when local to changed code; defer only with rationale or linked follow-up.
  • Verification: Run the anti-drift test: vitest run test/repro-5978-policy-denial-hint.test.ts -t 'shell allowlist agrees with NAME_VALID_PATTERN'
  • Missing regression test: Add a build-time validation script that parses the shell case pattern and compares it to NAME_VALID_PATTERN.
  • Done when: The local improvement is applied, or the PR notes why it should be deferred.
  • Evidence: scripts/nemoclaw-start.sh:3347-3375 (shell allowlist); src/lib/name-validation.ts:9 (NAME_VALID_PATTERN); test/repro-5978-policy-denial-hint.test.ts:248-275 (anti-drift test)

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Response to PR Review Advisor

Thanks — addressing each open item. Summary: the connect-shell breadcrumb is the intended, deliberately-scoped solution, the host-side print is provably control-char-safe, and the denial-time tool output is owned by OpenShell, not NemoClaw. Details and the advisor's requested fields below.

PRA-2 (Required) / PRA-1 — proactive breadcrumb is the intended design, not a denial-time rewrite

This is the settled approach for #5978, documented in the commit and PR body. Filling in the advisor's source-of-truth fields explicitly:

  • Invalid state: A sandbox tool (curl/git/wget/python) is blocked by network policy and the user sees only the opaque CONNECT tunnel failed, response 403 with no pointer to the denial reason.
  • Source boundary: The 403/CONNECT tunnel failed string is emitted by the OpenShell L7 egress proxy, not by NemoClaw. NemoClaw does not own the proxy's protocol-error output and cannot inject text at the denial site.
  • Source-fix constraint: The only NemoClaw-side way to put text "adjacent to the failure" would be to wrap each CLI and scan its stderr. That is explicitly rejected because wrapping turns the tool's stderr into a pipe (drops progress meters/colour, changes TTY behaviour and potentially exit codes) and still misses python and any other client. We keep every tool's stdout/stderr/TTY/exit-code byte-for-byte unchanged and instead surface a tool-agnostic breadcrumb on the two NemoClaw-owned surfaces (the connect-shell startup env and the host connect hint).
  • Regression test: test/repro-5978-policy-denial-hint.test.ts executes the byte-identical emitted stanza and asserts content, name derivation/fallback, and the suppress/no-proxy/non-interactive/subshell/single-print gates; an opt-in real-image Docker E2E (NEMOCLAW_RUN_POLICY_HINT_DOCKER_E2E=1) proves the breadcrumb prints in a real connect shell while a real curl still returns the unmodified 403.
  • Removal condition: Remove this breadcrumb once OpenShell surfaces the denial reason inline at the CONNECT tunnel failed site (i.e., the upstream proxy error itself names the policy rule / logs path). At that point the NemoClaw-side hint is redundant.

The breadcrumb naturally covers the "first-time user has no next step" case (PRA-T6): the next step is shown before the user ever hits the error. We're intentionally narrowing acceptance to the proactive connect-shell + host hint rather than a denial-time rewrite, for the constraint above.

PRA-3 (security) — host-side name is provably control-char-free; sanitizing would be dead code

buildPolicyDenialConnectHint(sandboxName) receives the host CLI argument, not the in-sandbox OPENSHELL_SANDBOX env var. The two are different trust boundaries:

  • Sandbox names are validated as RFC-1123 labels (/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/) at every policy/registry sink (src/lib/policy/index.ts:592,763,885,1280, host-redaction.ts). That character class excludes \n, \r, and ESC — a name reaching connectSandbox() cannot carry terminal control characters.
  • The same sandboxName is already interpolated raw into 18 console.* lines in src/lib/actions/sandbox/connect.ts (e.g. lines 920, 978, 1020, 1041). The new line 1093 is consistent with all of them; singling it out for stripping would be inconsistent and would not close any real sink.
  • The hint text is a runnable command (nemoclaw <name> logs --tail 50). Stripping characters from the displayed value would make the printed command diverge from the command that actually works, so "sanitize only the displayed text" is counter-productive here.

The in-sandbox stanza strips [:cntrl:] from OPENSHELL_SANDBOX precisely because that value is set by OpenShell at runtime and is not subject to the host-side RFC-1123 validation — a genuinely untrusted boundary. The host path is already covered by validation, so this resolves under the advisor's "prove sandbox-name validation excludes terminal control characters" option.

Test follow-ups PRA-T1–PRA-T8

  • PRA-T1 / PRA-T4–PRA-T8 (denial-time / acceptance): Existing coverage is sufficient given the scoping above. The denial-time curl/git output is intentionally unchanged (OpenShell-owned), so there is no NemoClaw behavior to assert at the denial site. repro-5978-policy-denial-hint.test.ts + the opt-in Docker E2E assert exactly the supported behavior: the breadcrumb prints on shell source while the protocol error remains original.
  • PRA-T2 (control-char host test): Not added — it would assert stripping that we deliberately do not perform (see PRA-3); the invariant is upstream RFC-1123 validation, already exercised by the policy/validation test suites.
  • PRA-T3 / PRA-T8 (Git-specific The requested URL returned error: 403): Intentionally out of scope. The hint is tool-agnostic and does not key on any individual tool's wording, so there is no per-tool string to test; documenting here that this is by design.

A human maintainer makes the final merge decision; flagging this rationale for that review.

Defense in depth for the host-side policy-denial breadcrumb (#5978): the
`nemoclaw <name> connect` hint interpolates the sandbox name into a TTY
message. Names are RFC-1123-validated at the policy/registry boundaries
(no control characters), but route the displayed value through the
existing sanitizeRouteValueForDisplay strip anyway so this sink can never
be turned into a terminal-escape injection — mirroring the [:cntrl:] strip
the in-sandbox stanza applies to the untrusted OPENSHELL_SANDBOX env value.
For any legitimate name the strip is a no-op, so the printed command stays
byte-for-byte runnable.

Adds a regression test asserting the hint drops ANSI escapes and newlines
from a hostile name while keeping the runnable logs command.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed ebf9180af addressing the one concrete actionable item:

  • PRA-3 / PRA-T2 (now fixed in code): buildPolicyDenialConnectHint now routes the sandbox name through the existing sanitizeRouteValueForDisplay control-char strip before display. Names are RFC-1123-validated upstream so this is a no-op for every legitimate name (the printed logs command stays byte-for-byte runnable), but it hard-closes the TTY sink against escape/newline injection as defense-in-depth — mirroring the [:cntrl:] strip the in-sandbox stanza applies to the untrusted OPENSHELL_SANDBOX. Added regression test strips control characters from sandbox names in connect-policy-hint.test.ts (drops ANSI/newline from a hostile name, keeps the runnable command).

PRA-1 / PRA-2 / PRA-T1,T3–T8 remain as justified in the prior comment: the proactive breadcrumb is the intended scope because the denial-time 403 is emitted by the OpenShell L7 proxy (not NemoClaw-owned) and tool-wrapping is rejected for breaking stderr/TTY/exit-code and missing python. That scope acceptance is a maintainer call.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a sandbox-side breadcrumb for CONNECT 403 policy denials, with label sanitization, one-time shell gating, regression coverage, an opt-in Docker E2E check, and troubleshooting guidance.

Changes

Policy-denial breadcrumb hint

Layer / File(s) Summary
Troubleshooting docs
docs/reference/troubleshooting.mdx
Adds a Runtime subsection for CONNECT 403 denials, log inspection, hint suppression, and policy-add remediation.
Sandbox-side shell hint stanza
scripts/nemoclaw-start.sh, src/lib/actions/sandbox/connect.ts
Adds the policy-denial hint functions, safe sandbox label rendering, fixed breadcrumb text, one-time emission gating, and a host-side comment about avoiding duplicate output.
Test helpers and extraction
test/repro-5978-policy-denial-hint.test.ts
Introduces the regression test module, stanza extraction, and PTY/plain shell helpers.
Policy-hint behavior coverage
test/repro-5978-policy-denial-hint.test.ts
Covers interactive emission, sanitization and fallback, suppression, once-per-session behavior, non-interactive silence, and the no-wrapper contract for curl, git, and wget.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

integration: openclaw

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the sandbox policy-denial breadcrumb change and matches the main PR objective.
Linked Issues check ✅ Passed The PR adds the proactive logs breadcrumb, keeps native curl/git behavior, and leaves policy enforcement unchanged as requested.
Out of Scope Changes check ✅ Passed Changes are limited to docs, sandbox startup logic, connect comments, and regression tests for the breadcrumb feature.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/5978-policy-denial-logs-hint

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

E2E Target Recommendation

Required E2E targets: ubuntu-repo-cloud-openclaw
Optional E2E targets: ubuntu-repo-cloud-langchain-deepagents-code

Dispatch required E2E targets:

  • gh workflow run e2e.yaml --ref <pr-head-ref> --field targets=ubuntu-repo-cloud-openclaw

Workflow run

Full E2E target advisor summary

E2E Target Advisor

Base: origin/main
Head: HEAD
Confidence: medium

Required E2E targets

  • ubuntu-repo-cloud-openclaw: The PR changes sandbox startup/connect-shell behavior by adding the /tmp/nemoclaw-proxy-env.sh policy-denial breadcrumb and adjusting the host connect path not to duplicate it. The Ubuntu cloud OpenClaw typed target is the smallest live-supported registry target that onboards a real OpenClaw sandbox from the repo and exercises the affected startup/connect-runtime surface.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field targets=ubuntu-repo-cloud-openclaw

Optional E2E targets

  • ubuntu-repo-cloud-langchain-deepagents-code: Optional adjacent coverage for the same sandbox startup/connect-shell machinery on the live-supported terminal-agent onboarding path, since the policy-denial hint is tool-agnostic and sourced by sandbox shells beyond the primary OpenClaw path.
    • Dispatch: gh workflow run e2e.yaml --ref <pr-head-ref> --field targets=ubuntu-repo-cloud-langchain-deepagents-code

Relevant changed files

  • scripts/nemoclaw-start.sh
  • src/lib/actions/sandbox/connect.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lib/actions/sandbox/connect-policy-hint.test.ts (1)

27-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the sanitization contract, not the current stripped payload.

Line 31 hard-codes the exact "qa[31m-5978INJECTED" output, which couples this test to the current strip-only implementation. A future sanitizer that safely falls back to <name> or drops more tainted text would still satisfy the public behavior but fail here. Assert only the observable contract: no control characters reach the hint and a logs command is still present. As per path instructions, "Prefer observable outcomes through the public boundary over source-text, private-shape, or mock-call assertions."

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/actions/sandbox/connect.ts`:
- Around line 1099-1101: The normal connect flow is printing the policy-denial
breadcrumb twice: once in `connect` before launching `openshell sandbox
connect`, and again in the sourced shell stanza that runs in the interactive
session. Update `connect` and the shell bootstrap path so only one side emits
the hint, either by making one path authoritative or by threading a one-shot env
flag from `connect` to suppress the in-sandbox print. Use
`buildPolicyDenialConnectHint`, `isPolicyDenialHintSuppressed`, and the
`openshell sandbox connect` launch flow to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 9a4f2b19-f3cf-4f1e-80fd-87ce17ae7918

📥 Commits

Reviewing files that changed from the base of the PR and between 59c8680 and ebf9180.

📒 Files selected for processing (5)
  • docs/reference/troubleshooting.mdx
  • scripts/nemoclaw-start.sh
  • src/lib/actions/sandbox/connect-policy-hint.test.ts
  • src/lib/actions/sandbox/connect.ts
  • test/repro-5978-policy-denial-hint.test.ts

Comment thread src/lib/actions/sandbox/connect.ts Resolved
…wlist label

Address PR review on #5978:

- Stop printing the host-side breadcrumb in the `connect` welcome block.
  The in-sandbox `nemoclaw-policy-denial-hint` stanza already emits the
  breadcrumb once when the connect shell sources /tmp/nemoclaw-proxy-env.sh,
  with the real sandbox name on supported OpenShell, so printing it again on
  the host duplicated the hint in the normal connect flow (CodeRabbit). The
  stanza remains the single authoritative surface and still covers every
  interactive entry path. Removes buildPolicyDenialConnectHint /
  isPolicyDenialHintSuppressed and the host-side unit test.

- Allowlist the in-sandbox label instead of merely stripping control chars:
  OPENSHELL_SANDBOX is interpolated into a copyable `nemoclaw … logs`
  command, so render it only when it is a valid RFC-1123 sandbox name
  (lowercase alphanumerics/hyphens, 1..63, no leading/trailing hyphen);
  otherwise fall back to the `<name>` placeholder. Shell `case` globs match
  newlines, so embedded newlines, ANSI escapes, and shell metacharacters all
  fall back rather than reaching the terminal or a runnable command.

Updates the stanza regression tests to assert allowlist fallback for a
crafted ESC/newline name and for a shell-metacharacter name.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 051d477cd addressing the review on the previous head:

Double-print (CodeRabbit, functional): Removed the host-side breadcrumb print in the connect welcome block. The in-sandbox nemoclaw-policy-denial-hint stanza is now the single authoritative surface — it already prints the breadcrumb once per top-level interactive session (with the real name on OpenShell ≥0.0.44) and covers every connect path. A host→sandbox suppress flag wasn't possible (no env forwarding into the sandbox shell), so removing the redundant host print is the clean dedup. Drops buildPolicyDenialConnectHint/isPolicyDenialHintSuppressed and the host unit test.

PRA-3 (security) — now hardened to an allowlist: The in-sandbox label no longer just strips control chars; it renders OPENSHELL_SANDBOX only when it is a valid RFC-1123 sandbox name (lowercase alphanumerics/hyphens, 1..63, no leading/trailing hyphen), else falls back to <name>. Shell case globs match newlines, so embedded newlines, ANSI escapes, and shell metacharacters (e.g. ;, spaces) all fall back rather than reaching the copyable nemoclaw … logs command. Added regression cases for a crafted ESC/newline name and a shell-metacharacter name.

PRA-1 / PRA-2 / acceptance test follow-ups: unchanged — the proactive breadcrumb remains the intended scope (denial-time 403 is emitted by the OpenShell L7 proxy, not NemoClaw-owned; tool-wrapping rejected for breaking stderr/TTY/exit-code and missing python), as justified earlier. That scope acceptance is the maintainer's call.

Local: repro stanza test 12 pass + 1 skip (opt-in Docker E2E), 614 connect-area unit tests pass, Biome/tsc/shfmt/shellcheck clean.

The in-sandbox policy-denial label allowlisted lowercase alphanumerics and
hyphens but accepted digit-leading values like `9abc`, while the canonical
sandbox-name validator (NAME_VALID_PATTERN in src/lib/name-validation.ts,
/^[a-z]([a-z0-9-]*[a-z0-9])?$/) requires a leading lowercase letter. Tighten
the first-character case arm to [!a-z]* so the rendered `nemoclaw <name>
logs` command only ever carries a name the rest of NemoClaw would accept;
digit-leading and other invalid labels fall back to the <name> placeholder.

Adds a regression test for a digit-leading OPENSHELL_SANDBOX.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 743f9c09f:

PRA-4 (security — fixed): Aligned the in-sandbox label allowlist with the canonical NAME_VALID_PATTERN in src/lib/name-validation.ts (/^[a-z]([a-z0-9-]*[a-z0-9])?$/, max 63). Tightened the first-character case arm to [!a-z]* so a digit-leading label like 9abc now falls back to <name> instead of being rendered into the copyable nemoclaw … logs command. A real sandbox name is never digit-leading (creation enforces the same pattern), so this loses nothing. Added a digit-leading regression test.

PRA-1 / PRA-2 / PRA-3 (architecture/acceptance — same scope question, justified): These are all the same point: the breadcrumb is proactive rather than emitted at the denial site. That is the intended, deliberately-scoped design, because the denial-time CONNECT tunnel failed, response 403 is emitted by the OpenShell L7 proxy, which NemoClaw does not own and cannot modify in this repo. The only NemoClaw-side alternative — wrapping curl/git/wget to inject text at the failure — is rejected because it pipes their stderr (dropping TTY progress/colour, altering exit codes) and still misses python and any other client. Source-of-truth fields (invalid state, source boundary, source-fix constraint, regression test, removal condition) are enumerated in the earlier comment; removal condition: drop the breadcrumb once OpenShell surfaces the denial reason inline at the tunnel-failure site. Accepting this scope is a maintainer call, which the advisor defers to a human.

Local: repro stanza test 13 pass + 1 skip (opt-in Docker E2E); shfmt/shellcheck/Biome/tsc clean.

…of-truth

Address second-pass PR review on #5978:

- Force the C locale for the in-sandbox name allowlist so the [a-z0-9-]
  ranges stay ASCII and are not widened by the caller's LC_COLLATE/LC_CTYPE.
  Safe because the label helper only runs inside command substitution.
- Document the source-of-truth in the stanza comment: the 403 is emitted by
  the OpenShell L7 proxy (separate codebase/release), so it cannot be made
  self-describing here; records the regression test and the removal condition
  (drop once OpenShell returns a structured denial at the tunnel-failure site).
- Expand docs/troubleshooting: spell out the hint's gating conditions (proxy
  configured, interactive TTY on stderr, top-level shell, suppressible) and the
  OpenShell version dependency for the real-name vs <name> placeholder.
- Add regression tests for an over-length (>63) OPENSHELL_SANDBOX falling back
  to <name>.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Response to PR Review Advisor (Nemotron Ultra) + acceptance follow-ups

Pushed 5800eefec. Breakdown by item — fixed, stale, or justified.

Fixed in code

  • PRA-8 (security — locale): The allowlist now runs under LC_ALL=C so the [a-z0-9-] / [!a-z] ranges stay ASCII and aren't widened by the caller's LC_COLLATE/LC_CTYPE. Safe to set unconditionally — the label helper is only ever called inside $(…) command substitution (a subshell), so it can't leak into the interactive shell.
  • PRA-3 / PRA-7 (docs): docs/reference/troubleshooting.mdx now spells out the hint's gating conditions (proxy configured, interactive TTY on stderr, top-level shell, suppressible via NEMOCLAW_NO_POLICY_HINT=1) and the OpenShell version dependency (real name on ≥0.0.44, <name> placeholder + nemoclaw list on older).
  • PRA-T7 / PRA-9 (test): Added a regression case asserting an over-length (64-char) OPENSHELL_SANDBOX falls back to <name>.
  • PRA-1 / PRA-12 (source-of-truth): Added the source-of-truth block to the stanza comment in scripts/nemoclaw-start.sh — invalid state, source boundary (OpenShell L7 proxy, separate codebase/release), why it can't be fixed here, the regression test, and the removal condition (drop once OpenShell returns a structured denial at the tunnel-failure site).

Stale — reference code that was already removed

PRA-5, PRA-6, and PRA-11 point at src/lib/actions/sandbox/connect.ts:1061/1045/1 and the host-side helpers buildPolicyDenialConnectHint / isPolicyDenialHintSuppressed. Those functions and the host-side hint print were removed in 051d477cd (the double-print dedup); only a comment remains at line ~1077. There is no host-side hint, no host suppression env check, and no host/in-sandbox styling pair left to reconcile or extract. These no longer apply to the current head.

Justified — no change (would regress or out of scope)

  • PRA-4 / PRA-T6 (file-based sentinel across invocations): The once-per-session guard is intentionally per-shell-process: it dedupes a single login shell that sources the file through both the profile and bashrc hooks in one process. Two separate connect/login sessions are distinct sessions and each should show the hint once. A file-based sentinel (/tmp/…-shown-$USER) would suppress the hint on every later reconnect — a regression of the intended "once per top-level interactive TTY session" (not once ever) behavior. The existing test models the real double-source within one process.
  • PRA-10 / PRA-T8 (Docker E2E image-vs-repo drift): The opt-in real-image E2E builds the image from this branch and executes the actual baked stanza, asserting the breadcrumb output; if _nemoclaw_maybe_policy_denial_hint / _nemoclaw_policy_denial_hint_label weren't baked, that assertion would fail — so drift is already effectively detected. Adding image-vs-repo text diffing is out of scope for this fix.
  • PRA-2 (Required, both advisors) / PRA-1 (architecture) / PRA-13: The breadcrumb is proactive-by-design — the denial-time 403 is emitted by the OpenShell L7 proxy (not NemoClaw-owned), and tool-wrapping is rejected for breaking stderr/TTY/exit-code and missing python. The source-of-truth is now recorded both in-code (stanza comment) and in the docs page. Per the advisors' own text, narrowing acceptance to the proactive reminder is a maintainer decision, which a human reviewer makes.

Local validation: repro stanza test 14 pass + 1 skip (opt-in Docker E2E); npm run docs 0 errors; shfmt/shellcheck/Biome/tsc clean.

PR Review Advisor PRA-1 (acceptance) asked to either make the breadcrumb
denial-adjacent or explicitly narrow the accepted contract to a proactive
connect-shell reminder, in code/docs/tests, with maintainer agreement.

A tool-agnostic denial-adjacent breadcrumb is not achievable from NemoClaw:
the 403 is emitted by the OpenShell L7 proxy (separate codebase), and the only
in-sandbox alternative — wrapping curl/git/wget — pipes their stderr (dropping
TTY progress/colour, risking exit-code changes) and still misses python. The
maintainer accepted the proactive connect-shell + in-sandbox reminder as the
supported contract.

Record that agreement where the advisor asked:
- test: add a proactive-only contract assertion that the emitted stanza never
  wraps or aliases curl/git/wget, plus a docblock note.
- code: note the accepted contract in the nemoclaw-start.sh stanza comment.
- docs: clarify in troubleshooting that the reminder is intentionally proactive
  and the tool error text is left unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Manual review (covering the Nemotron Ultra advisor 'PR review advisor unavailable' item, which has not produced a substantive review across re-runs).

I re-triggered the PR Review Advisor workflow (runs 28424113090, 28424442004); the Nemotron variant keeps returning info_only/'unavailable' (a transient model-endpoint issue on the runner, not a code finding). Performing the requested manual review in its place:

  • Behavior: proactive policy-denial breadcrumb via the in-sandbox stanza (single authoritative surface after the host-side dedup); points to nemoclaw <name> logs --tail 50. Tools are not wrapped — verified by the new proactive-only contract test asserting the stanza defines no curl/git/wget wrapper/alias.
  • Security: OPENSHELL_SANDBOX is allowlisted to the canonical NAME_VALID_PATTERN (letter-first RFC-1123, ≤63) under LC_ALL=C; control chars, ANSI escapes, shell metacharacters, digit-leading, and >63 all fall back to <name>. Regression tests cover each.
  • Tests: test/repro-5978-policy-denial-hint.test.ts — 15 passing + 1 opt-in Docker E2E; executes the byte-identical emitted stanza.
  • Static/format: Biome, tsc -p tsconfig.cli.json, shfmt, shellcheck, test-title-style, and npm run docs all clean on the current head.
  • PRA-T1 (runtime validation): covered by the PTY-based stanza-execution tests (gating, name derivation, allowlist) plus the opt-in real-image Docker E2E; no additional runtime test gap.

No blocking issues found in this manual review; the one design point (proactive-only) has maintainer acceptance recorded on #5978 and in this PR.

…ource text

The source-shape budget (0) forbids source-text assertions. The proactive-only
contract test matched the stanza source, tripping 'Source-shape test budget
exceeded: 1 > 0' in static-checks. Convert it to a behavior test: source the
stanza, then assert curl/git/wget resolve to a binary (not a shell
function/alias) via `type -t`, proving the tools are left unwrapped.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@yimoj yimoj added the v0.0.73 label Jun 30, 2026
yimoj and others added 5 commits June 30, 2026 07:33
…interactive (#5978)

Strengthen the opt-in real-base-image E2E to cover the runtime-validation
follow-ups: drive both reporter commands (curl and git clone) under a real
403-on-CONNECT denial and assert each keeps its own native error and non-zero
exit status (curl 56, git 128), neither tool is wrapped/aliased
(type -t == file), the breadcrumb prints exactly once per session, and a
noninteractive shell stays silent. Proves the proactive-only contract end to
end against the image's own /etc/profile.d + /etc/bash.bashrc hooks.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
…allowlist case (#5978)

Add a pointer comment at the OPENSHELL_SANDBOX allowlist `case` so a future
maintainer editing the pattern sees the src/lib/name-validation.ts source of
truth right where the match happens, keeping the shell allowlist and the TS
NAME_VALID_PATTERN in sync. Comment-only; no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
…nvalid-name fallback (#5978)

Add always-run allowlist coverage for two more invalid OPENSHELL_SANDBOX
shapes the gate must reject — uppercase-leading (Qa-5978) and underscore
(qa_5978) — both falling back to the <name> placeholder rather than echoing
the untrusted value. Clarify in runInPty that a snippet's own SHLVL assignment
takes precedence over the forced inherited SHLVL=9 (intentional). Document the
invalid-name fallback for safety in the troubleshooting page.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
…uard drift (#5978)

Add a behavioral anti-drift test that runs a matrix of candidate names through
the real shell gate and asserts its accept/reject decision matches the imported
NAME_VALID_PATTERN/NAME_MAX_LENGTH from src/lib/name-validation.ts. A future
change to the TS validator that the hand-mirrored shell `case` does not track
now fails here. Boolean sentinels (true/false/0/1) are intentionally excluded —
the shell maps them to the placeholder by OpenShell convention.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
…5978)

Justify keeping the real-base-image E2E opt-in rather than a required CI lane:
it needs a Docker daemon plus the multi-hundred-MB sandbox base image that the
fast always-run lanes do not provision, while the behavior is already covered
hermetically by the always-run stanza tests. The scenario is the end-to-end
reporter-workflow proof for local/image-aware runs; promote it once such a lane
exists. Comment-only; no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yimo Jiang <[email protected]>
@yimoj

yimoj commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@prekshivyas prekshivyas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Additive policy-denial breadcrumb for connect shells: does NOT wrap curl/git/wget (preserves their TTY/exit behaviour), gated once-per-session on interactive+TTY+proxy, suppressible via NEMOCLAW_NO_POLICY_HINT. Untrusted OPENSHELL_SANDBOX is allowlisted against RFC-1123 (NAME_VALID_PATTERN) with an anti-drift test — injection-safe. Touches the sandbox entrypoint but is purely informational. Thorough PTY tests + opt-in real-image E2E. Advisors + CodeRabbit + E2E + CI green. LGTM.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Target Results — ✅ All requested jobs passed

Run: 28540976325
Workflow ref: fix/5978-policy-denial-logs-hint
Requested targets: (default — all supported)
Requested jobs: network-policy,sandbox-operations
Summary: 2 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
network-policy ✅ success
sandbox-operations ✅ success

@prekshivyas

Copy link
Copy Markdown
Collaborator

CodeRabbit finding at connect.ts:1101 (duplicate hint) is stale — the code already has an explicit comment documenting the deliberate choice not to print the hint here to avoid duplication. No action needed.

@apurvvkumaria
apurvvkumaria merged commit 4fd76d4 into main Jul 1, 2026
43 checks passed
@apurvvkumaria
apurvvkumaria deleted the fix/5978-policy-denial-logs-hint branch July 1, 2026 21:53
@miyoungc miyoungc mentioned this pull request Jul 2, 2026
3 tasks done
ericksoa pushed a commit that referenced this pull request Jul 2, 2026
## Summary
- Add the `v0.0.72` release-note section with links to the deeper docs
pages for installer recovery, command diagnostics, inference, policy,
and sandbox repair changes.
- Document the custom preset `allowed_ips` guard for user-authored
policy files.

## Related Issue
None.

## Source summary
- #6132 -> `docs/about/release-notes.mdx`: Summarizes installer and
upgrade recovery before generic onboarding, with links to quickstart and
lifecycle docs.
- #6087 -> `docs/network-policy/customize-network-policy.mdx`: Documents
that user-authored custom presets reject `allowed_ips` for ordinary
endpoints; also summarized in release notes.
- #5975 -> `docs/about/release-notes.mdx`: Summarizes safer curl-based
inference probes that keep API keys out of process arguments.
- #6044 -> `docs/about/release-notes.mdx`: Summarizes compact `channels
status` configuration reporting.
- #6096 -> `docs/about/release-notes.mdx`: Summarizes OpenClaw EC2
metadata discovery disablement and links to security guidance.
- #5980 and #5991 -> `docs/about/release-notes.mdx`: Summarizes `exec`
multiline argument rejection and recovery guidance.
- #6023 -> `docs/about/release-notes.mdx`: Summarizes
registered-provider diagnostics for `inference set` failures.
- #6074 -> `docs/about/release-notes.mdx`: Summarizes the refreshed
NVIDIA Endpoints featured-model selection behavior.
- #5969 -> `docs/about/release-notes.mdx`: Summarizes `credentials add`
provider credential registration.
- #6060 -> `docs/about/release-notes.mdx`: Summarizes mutable OpenClaw
config permission restoration after `exec`.
- #6134 -> `docs/about/release-notes.mdx`: Summarizes restored Tavily
access for managed Python workflows.
- #6089 -> `docs/about/release-notes.mdx`: Summarizes Hermes runtime
version-scheme comparison during upgrade checks.
- #6131 -> `docs/about/release-notes.mdx`: Summarizes OpenClaw gateway
watchdog recovery behavior.
- #5976 and #5990 -> `docs/about/release-notes.mdx`: Summarizes prompt
stdin EOF cancellation behavior during onboarding.
- #5540 -> `docs/about/release-notes.mdx`: Summarizes clarified
host-level and per-sandbox status command scope.
- #5978 and #6018 -> `docs/about/release-notes.mdx`: Summarizes
policy-denial log breadcrumbs in connect shells.

## Testing
- `npm run docs:sync-agent-variants`
- `npm run docs`
- Commit hooks passed during `git commit`, including commitlint and
gitleaks.
- Pre-push hook passed during `git push`, including TypeScript CLI and
package/tag version sync.

## Checklist
- [x] Documentation updated.
- [x] `npm run docs` completed with 0 errors and 1 existing Fern
warning.
- [x] No source code or generated build artifacts committed.

Signed-off-by: Miyoung Choi <[email protected]>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added release notes for v0.0.72 covering improved installer recovery,
clearer CLI diagnostics, safer inference setup and provider switching,
better credential handling, stronger policy boundaries, and more robust
runtime repair behavior.
* Updated network policy guidance to clarify when `allowed_ips` can be
used, including a specific exception for the sandbox-to-host bridge
endpoint.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
ericksoa added a commit that referenced this pull request Jul 3, 2026
#6238)

<!-- markdownlint-disable MD041 -->
## Summary

A sandbox network-policy denial reaches generic clients (curl, python,
git, wget, …) only as the opaque `curl: (56) CONNECT tunnel failed,
response 403`; the denial reason lives in the audit log but the
reporter's `nemoclaw <name> exec -- ...` failure path pointed nowhere.
This PR makes that exact failure path actionable: after a failed exec,
NemoClaw reads recent audit logs and, only when a fresh policy denial is
found, appends a concise host-side stderr breadcrumb — while preserving
the tool's own output and exit code. The prior startup banner (#6018)
only covered top-level interactive connect shells, leaving the QA/exec
path opaque; this closes that gap.

## Related Issue

Fixes #5978

## Changes

- New `src/lib/actions/sandbox/exec-policy-hint.ts`:
- Tool-/format-agnostic denial detection (OpenShell OCSF `NET:OPEN …
DENIED`, `policy_denied`, `not … by policy`).
- Safe `host:port` extraction (strict allowlist; leading log timestamp
stripped so an ISO stamp's `HH:MM` is never mistaken for the endpoint;
crafted/control-char tokens dropped → generic message). No log line or
secret is echoed — only the `host:port`.
- Exact-cutoff recency check (no backward skew), so a denial from a
*prior* command cannot masquerade as this one's → no spam on unrelated
failures.
- Bounded audit-log read retry for slow-flushing events (audit enabled
once, only the read retries).
- Wire into `execSandbox` after the child is reaped and after
invocation/cleanup diagnostics; the child's stdout/stderr bytes and the
exec exit code are untouched (best-effort, never throws to the caller).
- Docs: `docs/reference/troubleshooting.mdx` entry for the exec
breadcrumb.

The connect-shell stanza and its tests are intentionally left in place
(they cover the interactive path and stay silent noninteractively, which
remains correct); this PR adds the host-side exec coverage the
reporter's workflow actually needs.

## Type of Change

- [x] Code change with doc updates

## Quality Gates

- [x] Tests added or updated for changed behavior — new
`exec-policy-hint.test.ts` (37 cases: detection, safe extraction incl.
injection/ISO, recency cutoff, retry, exit-preservation guards);
existing exec suites still pass.
- [x] Docs updated for user-facing behavior changes — troubleshooting
entry.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging) —
sandbox/policy/observability; no secrets are read into the hint (only
`host:port`, allowlisted).
- [x] Sensitive-path review completed — `codex review --uncommitted` run
across iterations; findings addressed (test-title style, backward-skew
false positive, ISO-timestamp endpoint poisoning,
one-shot→bounded-retry). A self-caught event-loop-drain bug (an
`unref`'d retry timer let Node exit 0 mid-retry and drop the real exit
code) was fixed and covered by E2E.

## Verification

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push (`npx prek run --all-files
--stage pre-push` → all TypeScript checks Passed)
- [x] Targeted tests pass for changed behavior
- [x] No secrets, API keys, or credentials committed

### Real-CLI E2E (restricted ollama sandbox `oc5978`, worktree
`./bin/nemoclaw.js`)

```
node ./bin/nemoclaw.js oc5978 exec -- bash -lc "curl -sS --max-time 15 https://example.com/"
# curl: (56) CONNECT tunnel failed, response 403
# nemoclaw: recent network policy denial detected for example.com:443 inside sandbox 'oc5978'.
#   The sandbox's egress policy blocked this request; the tool above only saw the proxy's 403.
#   See the denied flow:      nemoclaw oc5978 logs --tail 50
#   Review or allow the host: nemoclaw oc5978 policy-list
#   Silence this hint:        export NEMOCLAW_NO_POLICY_HINT=1
# exit 56
```

Full matrix confirmed against the live sandbox:

- `curl` denial → hint + exit **56**; `python` urllib denial → hint +
exit **1**; `git clone` denial → hint + exit **128** (native errors
preserved, tool-agnostic).
- `echo ok` → **no hint**, exit **0**; `ls /nope` → **no hint**, exit
**2**; `false` → exit **1** (no spam on unrelated failures; exit codes
preserved).
- `NEMOCLAW_NO_POLICY_HINT=1 … curl …` → **no hint**, exit **56**.
- `node ./bin/nemoclaw.js oc5978 logs --tail 50` shows the matching
`NET:OPEN … DENIED … -> example.com:443 … not allowed by any policy`
audit line.

---
Signed-off-by: Yimo Jiang <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Failed sandbox `exec` commands now emit an optional stderr “network
policy denial” breadcrumb with a sanitized denied `host:port` (bracketed
IPv6 supported) and follow-ups (`logs --tail`, `policy-list`,
`policy-add`).
* Interactive `connect` guidance includes an updated one-line denial
signature reminder and the `logs` command.
* **Bug Fixes**
* Breadcrumbs appear only for genuinely *fresh* denials; otherwise
nothing is emitted, and the original command exit code is preserved.
Supports opt-out via `NEMOCLAW_NO_POLICY_HINT`.
* **Documentation**
* Updated the `CONNECT tunnel failed, response 403` troubleshooting
section and clarified `policy-add` preset behavior.
* **Tests**
* Added unit/integration/e2e coverage for detection, safe parsing, retry
probing, suppression, and failure-handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Yimo Jiang <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Aaron Erickson <[email protected]>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
…NVIDIA#5978) (NVIDIA#6018)

## Summary

Sandbox outbound egress is denied-by-default and enforced by the
OpenShell L7 proxy. From inside the sandbox, generic CLIs (curl, git,
wget, python) see a policy denial only as the opaque `CONNECT tunnel
failed, response 403`, with no pointer to the detailed allow/deny reason
that lives in the NemoClaw logs. This adds a tool-agnostic breadcrumb
that points the user to `nemoclaw <name> logs --tail 50`.

## Related Issue

Fixes NVIDIA#5978

## Changes

- `scripts/nemoclaw-start.sh`: add a `# nemoclaw-policy-denial-hint`
stanza to the `/tmp/nemoclaw-proxy-env.sh` block already sourced by
every interactive/login sandbox shell (via `/etc/bash.bashrc` and
`/etc/profile.d/nemoclaw-proxy.sh`). It prints a one-line breadcrumb
naming the `CONNECT tunnel failed, response 403` signature and `nemoclaw
<name> logs --tail 50`.
- Shown **once** per top-level interactive TTY session (gated on `$-`
interactive, `[ -t 2 ]`, `SHLVL <= 1`, a proxy being configured, and a
once-per-shell guard so a login shell sourcing both `/etc/profile` and
`/etc/bash.bashrc` does not double-print). Suppressible with
`NEMOCLAW_NO_POLICY_HINT=1`.
- The sandbox name is derived from `OPENSHELL_SANDBOX` (OpenShell
≥0.0.44), falling back to `<name>` on older versions.
- It deliberately does **not** wrap `curl`/`git`/`wget`: wrapping them
to scan stderr turns their stderr into a pipe, makes the tools drop
progress meters and colour, and still misses `python`. The informational
hint leaves every tool's stdout/stderr/TTY behaviour and exit code
byte-for-byte unchanged, while covering generic CLIs — not just Node
processes (the explicit risk called out in the issue).
- `test/repro-5978-policy-denial-hint.test.ts`: executes the actual
emitted stanza (extracted from the single-quoted heredoc, byte-identical
to runtime) and asserts the breadcrumb content, name
derivation/fallback, the suppress/no-proxy/non-interactive/subshell
gates, and single-print on double-source.
- `docs/reference/troubleshooting.mdx`: new entry "A request inside the
sandbox fails with `CONNECT tunnel failed, response 403`".

`nemoclaw <name> logs --tail 50` already surfaces the merged OpenShell
denial line, so no logs-path change is required.

## Type of Change

- [x] Code change with doc updates

## Quality Gates

- [x] Tests added or updated for changed behavior
- [x] Docs updated for user-facing behavior changes
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — justification: additive, informational stderr output only; no
policy/enforcement/credential behaviour changes; tools are not wrapped
so their behaviour and exit codes are unchanged.

## Verification

Real reporter-workflow E2E with the host CLI, against a sandbox built
from this branch (the image bakes in the changed `nemoclaw-start.sh`):

```bash
node ./bin/nemoclaw.js onboard --name issue5978-hint --non-interactive --yes --no-gpu --no-sandbox-gpu --agent openclaw
node ./bin/nemoclaw.js issue5978-hint connect
node ./bin/nemoclaw.js issue5978-hint logs --tail 50
```

The `connect` shell printed the breadcrumb, a real `curl` was denied
with `CONNECT tunnel failed, response 403`, and `logs --tail 50` showed
the denial reason (`DENIED` on `example.com:443`, `not in policy`). Full
transcript in the PR comment.

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Targeted tests pass — `vitest run
test/repro-5978-policy-denial-hint.test.ts` (13 passing incl. the opt-in
real-image container E2E; deterministic under `env -u SHLVL`)
- [x] Targeted regression tests pass: repro-4538, runtime-env-alias,
slack/telegram/plugin-refresh/reconcile, nemoclaw-start, hermes-start
- [x] `shfmt -i 2 -ci -bn` clean; Biome clean; `tsc -p jsconfig.json`
clean; source-shape budget 0; codebase-growth-guardrails pass
- [x] `npm run docs` builds without warnings
- [x] No secrets, API keys, or credentials committed

---
Signed-off-by: Yimo Jiang <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved in-sandbox outbound troubleshooting by showing a clear
`CONNECT tunnel failed, response 403` breadcrumb with a copyable
`nemoclaw <name> logs --tail 50` hint.
* Ensures the hint is emitted only once per interactive top-level shell
session, with suppression via `NEMOCLAW_NO_POLICY_HINT=1`, and avoids
duplicate breadcrumbs in the host connect flow.
* **Documentation**
* Expanded the Runtime troubleshooting guide with the new in-sandbox
outbound failure section, including how to identify the denied rule and
remediate via `policy-add <preset>` (custom presets supported).
* **Tests**
* Added regression coverage for PTY vs non-PTY behavior, suppression,
safe `<name>` derivation from sandbox labels, and an optional
Docker-gated end-to-end check.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


## Accepted contract (proposed contributor scope)

Per PR Review Advisor `PRA-1` (acceptance): the supported behavior for
NVIDIA#5978 is a **proactive** connect-shell + in-sandbox reminder, **not** a
denial-time rewrite of the `curl`/`git`/`wget` error. The denial-time
`CONNECT tunnel failed, response 403` is emitted by the OpenShell L7
egress proxy (a separate codebase/release), so it cannot be made
self-describing from this repo, and wrapping the tools to inject text is
rejected (it pipes their stderr — dropping TTY progress/colour, risking
exit-code changes — and still misses `python`). Contributor position:
this PR intentionally implements the proactive reminder only; repository
reviewers must decide whether that scope is acceptable. It is recorded
in code (`scripts/nemoclaw-start.sh` stanza comment), docs
(`docs/reference/troubleshooting.mdx`), and tests (the "proactive-only
contract" assertion in `test/repro-5978-policy-denial-hint.test.ts`).
Removal condition: drop the breadcrumb once OpenShell surfaces a
structured, actionable denial at the tunnel-failure site.

---------

Signed-off-by: Yimo Jiang <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Prekshi Vyas <[email protected]>
Co-authored-by: J. Yaunches <[email protected]>
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
## Summary
- Add the `v0.0.72` release-note section with links to the deeper docs
pages for installer recovery, command diagnostics, inference, policy,
and sandbox repair changes.
- Document the custom preset `allowed_ips` guard for user-authored
policy files.

## Related Issue
None.

## Source summary
- NVIDIA#6132 -> `docs/about/release-notes.mdx`: Summarizes installer and
upgrade recovery before generic onboarding, with links to quickstart and
lifecycle docs.
- NVIDIA#6087 -> `docs/network-policy/customize-network-policy.mdx`: Documents
that user-authored custom presets reject `allowed_ips` for ordinary
endpoints; also summarized in release notes.
- NVIDIA#5975 -> `docs/about/release-notes.mdx`: Summarizes safer curl-based
inference probes that keep API keys out of process arguments.
- NVIDIA#6044 -> `docs/about/release-notes.mdx`: Summarizes compact `channels
status` configuration reporting.
- NVIDIA#6096 -> `docs/about/release-notes.mdx`: Summarizes OpenClaw EC2
metadata discovery disablement and links to security guidance.
- NVIDIA#5980 and NVIDIA#5991 -> `docs/about/release-notes.mdx`: Summarizes `exec`
multiline argument rejection and recovery guidance.
- NVIDIA#6023 -> `docs/about/release-notes.mdx`: Summarizes
registered-provider diagnostics for `inference set` failures.
- NVIDIA#6074 -> `docs/about/release-notes.mdx`: Summarizes the refreshed
NVIDIA Endpoints featured-model selection behavior.
- NVIDIA#5969 -> `docs/about/release-notes.mdx`: Summarizes `credentials add`
provider credential registration.
- NVIDIA#6060 -> `docs/about/release-notes.mdx`: Summarizes mutable OpenClaw
config permission restoration after `exec`.
- NVIDIA#6134 -> `docs/about/release-notes.mdx`: Summarizes restored Tavily
access for managed Python workflows.
- NVIDIA#6089 -> `docs/about/release-notes.mdx`: Summarizes Hermes runtime
version-scheme comparison during upgrade checks.
- NVIDIA#6131 -> `docs/about/release-notes.mdx`: Summarizes OpenClaw gateway
watchdog recovery behavior.
- NVIDIA#5976 and NVIDIA#5990 -> `docs/about/release-notes.mdx`: Summarizes prompt
stdin EOF cancellation behavior during onboarding.
- NVIDIA#5540 -> `docs/about/release-notes.mdx`: Summarizes clarified
host-level and per-sandbox status command scope.
- NVIDIA#5978 and NVIDIA#6018 -> `docs/about/release-notes.mdx`: Summarizes
policy-denial log breadcrumbs in connect shells.

## Testing
- `npm run docs:sync-agent-variants`
- `npm run docs`
- Commit hooks passed during `git commit`, including commitlint and
gitleaks.
- Pre-push hook passed during `git push`, including TypeScript CLI and
package/tag version sync.

## Checklist
- [x] Documentation updated.
- [x] `npm run docs` completed with 0 errors and 1 existing Fern
warning.
- [x] No source code or generated build artifacts committed.

Signed-off-by: Miyoung Choi <[email protected]>

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Documentation**
* Added release notes for v0.0.72 covering improved installer recovery,
clearer CLI diagnostics, safer inference setup and provider switching,
better credential handling, stronger policy boundaries, and more robust
runtime repair behavior.
* Updated network policy guidance to clarify when `allowed_ips` can be
used, including a specific exception for the sandbox-to-host bridge
endpoint.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
…A#5978) (NVIDIA#6238)

<!-- markdownlint-disable MD041 -->
## Summary

A sandbox network-policy denial reaches generic clients (curl, python,
git, wget, …) only as the opaque `curl: (56) CONNECT tunnel failed,
response 403`; the denial reason lives in the audit log but the
reporter's `nemoclaw <name> exec -- ...` failure path pointed nowhere.
This PR makes that exact failure path actionable: after a failed exec,
NemoClaw reads recent audit logs and, only when a fresh policy denial is
found, appends a concise host-side stderr breadcrumb — while preserving
the tool's own output and exit code. The prior startup banner (NVIDIA#6018)
only covered top-level interactive connect shells, leaving the QA/exec
path opaque; this closes that gap.

## Related Issue

Fixes NVIDIA#5978

## Changes

- New `src/lib/actions/sandbox/exec-policy-hint.ts`:
- Tool-/format-agnostic denial detection (OpenShell OCSF `NET:OPEN …
DENIED`, `policy_denied`, `not … by policy`).
- Safe `host:port` extraction (strict allowlist; leading log timestamp
stripped so an ISO stamp's `HH:MM` is never mistaken for the endpoint;
crafted/control-char tokens dropped → generic message). No log line or
secret is echoed — only the `host:port`.
- Exact-cutoff recency check (no backward skew), so a denial from a
*prior* command cannot masquerade as this one's → no spam on unrelated
failures.
- Bounded audit-log read retry for slow-flushing events (audit enabled
once, only the read retries).
- Wire into `execSandbox` after the child is reaped and after
invocation/cleanup diagnostics; the child's stdout/stderr bytes and the
exec exit code are untouched (best-effort, never throws to the caller).
- Docs: `docs/reference/troubleshooting.mdx` entry for the exec
breadcrumb.

The connect-shell stanza and its tests are intentionally left in place
(they cover the interactive path and stay silent noninteractively, which
remains correct); this PR adds the host-side exec coverage the
reporter's workflow actually needs.

## Type of Change

- [x] Code change with doc updates

## Quality Gates

- [x] Tests added or updated for changed behavior — new
`exec-policy-hint.test.ts` (37 cases: detection, safe extraction incl.
injection/ISO, recency cutoff, retry, exit-preservation guards);
existing exec suites still pass.
- [x] Docs updated for user-facing behavior changes — troubleshooting
entry.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging) —
sandbox/policy/observability; no secrets are read into the hint (only
`host:port`, allowlisted).
- [x] Sensitive-path review completed — `codex review --uncommitted` run
across iterations; findings addressed (test-title style, backward-skew
false positive, ISO-timestamp endpoint poisoning,
one-shot→bounded-retry). A self-caught event-loop-drain bug (an
`unref`'d retry timer let Node exit 0 mid-retry and drop the real exit
code) was fixed and covered by E2E.

## Verification

- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push (`npx prek run --all-files
--stage pre-push` → all TypeScript checks Passed)
- [x] Targeted tests pass for changed behavior
- [x] No secrets, API keys, or credentials committed

### Real-CLI E2E (restricted ollama sandbox `oc5978`, worktree
`./bin/nemoclaw.js`)

```
node ./bin/nemoclaw.js oc5978 exec -- bash -lc "curl -sS --max-time 15 https://example.com/"
# curl: (56) CONNECT tunnel failed, response 403
# nemoclaw: recent network policy denial detected for example.com:443 inside sandbox 'oc5978'.
#   The sandbox's egress policy blocked this request; the tool above only saw the proxy's 403.
#   See the denied flow:      nemoclaw oc5978 logs --tail 50
#   Review or allow the host: nemoclaw oc5978 policy-list
#   Silence this hint:        export NEMOCLAW_NO_POLICY_HINT=1
# exit 56
```

Full matrix confirmed against the live sandbox:

- `curl` denial → hint + exit **56**; `python` urllib denial → hint +
exit **1**; `git clone` denial → hint + exit **128** (native errors
preserved, tool-agnostic).
- `echo ok` → **no hint**, exit **0**; `ls /nope` → **no hint**, exit
**2**; `false` → exit **1** (no spam on unrelated failures; exit codes
preserved).
- `NEMOCLAW_NO_POLICY_HINT=1 … curl …` → **no hint**, exit **56**.
- `node ./bin/nemoclaw.js oc5978 logs --tail 50` shows the matching
`NET:OPEN … DENIED … -> example.com:443 … not allowed by any policy`
audit line.

---
Signed-off-by: Yimo Jiang <[email protected]>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Failed sandbox `exec` commands now emit an optional stderr “network
policy denial” breadcrumb with a sanitized denied `host:port` (bracketed
IPv6 supported) and follow-ups (`logs --tail`, `policy-list`,
`policy-add`).
* Interactive `connect` guidance includes an updated one-line denial
signature reminder and the `logs` command.
* **Bug Fixes**
* Breadcrumbs appear only for genuinely *fresh* denials; otherwise
nothing is emitted, and the original command exit code is preserved.
Supports opt-out via `NEMOCLAW_NO_POLICY_HINT`.
* **Documentation**
* Updated the `CONNECT tunnel failed, response 403` troubleshooting
section and clarified `policy-add` preset behavior.
* **Tests**
* Added unit/integration/e2e coverage for detection, safe parsing, retry
probing, suppression, and failure-handling.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Yimo Jiang <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Co-authored-by: Aaron Erickson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: observability Logging, metrics, tracing, diagnostics, or debug output area: policy Network policy, egress rules, presets, or sandbox policy bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Linux][CLI&UX] Sandbox-side policy denial error has no nemoclaw <name> logs --tail breadcrumb hint

5 participants