Skip to content

fix(config): validate OpenClaw candidates before writes - #6902

Merged
cv merged 3 commits into
NVIDIA:mainfrom
rluo8:fix/6868-config-prevalidate-review
Jul 15, 2026
Merged

cv merged 3 commits into
NVIDIA:mainfrom
rluo8:fix/6868-config-prevalidate-review

Conversation

@rluo8

@rluo8 rluo8 commented Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Host-side OpenClaw config set now validates the complete candidate config with the installed OpenClaw runtime before replacing the live config.
Invalid candidates fail without changing the existing config or reaching the destructive gateway restart path.
The validated bytes and sandbox container identity are bound to the subsequent digest-protected write.

Related Issue

Fixes #6868

Changes

  • Run openclaw config validate --json as the gateway user against the exact serialized candidate.
  • Perform schema validation outside the sandbox and shields mutation locks.
  • Re-read the config under both locks and require its source digest and serialized candidate bytes to remain unchanged.
  • Bind validation and write operations to the same sandbox container identity.
  • Limit candidates to 16 MiB and preserve relative OpenClaw config-include resolution.
  • Redact validator stderr and surface schema or write failures as clean SandboxConfigError output.
  • Keep onboarding, inference, and other generated OpenClaw writes on their existing digest-bound CAS path without adding runtime schema validation.
  • Replace schema-invalid config set help examples.
  • Add coverage for invalid candidates, validator failures and timeouts, size limits, lock ordering, exact-byte binding, and internal-writer compatibility.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: this fixes validation of the existing config set workflow without adding or changing CLI syntax; rejected candidates return actionable CLI errors.
  • Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging)
  • Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification:
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes a Signed-off-by: line and every commit appears as Verified in GitHub
  • Normal pre-commit, commit-msg, and pre-push hooks passed, or npm run check:diff passed when hooks were skipped or unavailable
  • Targeted behavior tests pass for the current change set, or tests are marked not applicable above — command/result or justification:
  • Applicable broad gate passed — npm test for broad runtime/test-harness changes; npm run check for repo-wide validation/coverage changes — command/result:
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Rui Luo ruluo@nvidia.com

Summary by CodeRabbit

  • New Features

    • Sandbox configuration updates now validate OpenClaw settings against the schema before changes are applied.
    • Validation is safer against configuration changes mid-process, preventing inconsistent writes.
  • Bug Fixes

    • Prevented invalid OpenClaw configurations from being written and from being recorded in audit history.
    • Improved error reporting with sanitized details, including clearer timeout/termination and “validation couldn’t run” messaging.
    • Added safeguards for oversized inputs and other validation-path failures.
  • Documentation

    • Updated CLI examples for OpenClaw-related config keys, including a variant that demonstrates restart behavior for applying changes.

Signed-off-by: Rui Luo <ruluo@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6c413fee-fa8a-4a3b-be82-e13bf556a2c6

📥 Commits

Reviewing files that changed from the base of the PR and between 98aafd9 and e345d8b.

📒 Files selected for processing (3)
  • src/lib/shields/openclaw-config-lock.test.ts
  • src/lib/shields/openclaw-config-lock.ts
  • test/config-set-nested-ssrf.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/config-set-nested-ssrf.test.ts
  • src/lib/shields/openclaw-config-lock.test.ts
  • src/lib/shields/openclaw-config-lock.ts

📝 Walkthrough

Walkthrough

OpenClaw sandbox config updates validate serialized candidates before acquiring mutation locks, verify unchanged content after re-reading, and reuse the validated privileged execution context for writes. Validation errors, size limits, timeout handling, CLI examples, and transaction wiring receive test coverage.

Changes

OpenClaw config set transaction

Layer / File(s) Summary
Schema candidate validation
src/lib/shields/openclaw-config-lock.ts, src/lib/shields/openclaw-config-lock.test.ts
Candidates are size-limited, validated through openclaw config validate --json, and reported with sanitized schema or execution errors.
Lock-bound candidate commit
src/lib/sandbox/config.ts, test/config-set-nested-ssrf.test.ts, test/openclaw-config-transaction-wiring.test.ts
Config set validates before locks, checks candidate bytes after re-reading, reuses the privileged handle for writing, and verifies lock/write ordering and CAS-only internal writes.
CLI examples and compatibility coverage
src/commands/sandbox/config/set.ts, test/cli-oclif-compatibility.test.ts
Examples and compatibility assertions use nested agents.defaults.* OpenClaw configuration paths.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested labels: bug-fix, integration: openclaw

Suggested reviewers: cv

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes add pre-write validation and lock hardening, but they do not address the reported config set --restart gateway restart hang or stale lock cleanup. Update the restart flow so config set --restart completes, applies the config to the running agent, and cleans up stale shields-transition locks on failure or timeout.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary change: validating OpenClaw config candidates before writes.
Out of Scope Changes check ✅ Passed The added docs, tests, and OpenClaw validation changes all support the config-set workflow and appear within scope.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Review Advisor — Informational

Advisor assessment: Informational / high confidence
Next action: No advisor follow-up needed.
Findings: 0 blockers · 0 warnings · 0 suggestions
Status: No actionable findings remain in the canonical review ledger.

Model lanes

  • GPT-5.6 Terra (primary): Completed · high confidence · 0 blockers · 0 warnings · 0 suggestions
  • Nemotron 3 Ultra (second opinion): Completed · high confidence · 0 blockers · 1 warning · 0 suggestions
  • Model comparison: normalized findings differ; normalized E2E selections differ; Nemotron reported the same number of blockers, 1 more warning, the same number of suggestions.

Nemotron output stays in workflow artifacts and does not change the assessment above.

E2E guidance

Advisory only. E2E / PR Gate selects and runs jobs independently.

Recommended E2E: credential-sanitization, security-posture

2 optional E2E recommendations
  • shields-config
  • ubuntu-repo-cloud-openclaw

Workflow run details

This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge.

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/sandbox/config.ts (1)

1019-1074: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Move the validation-and-commit workflow into a sandbox action.

This block now owns container resolution, schema validation, lock sequencing, byte verification, writing, and audit orchestration inside transitional src/lib/sandbox/**. Introduce one typed action under src/lib/actions/**, route the command and internal callers through it, and keep this module limited to adapters/domain helpers.

As per path instructions, “Actions own lifecycle workflows” and sandbox operations moved to actions must use one authoritative path.

🤖 Prompt for 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.

In `@src/lib/sandbox/config.ts` around lines 1019 - 1074, Extract the OpenClaw
validation-and-commit workflow currently surrounding validatedOpenClawCandidate
and withSandboxMutationLock into one typed action under src/lib/actions,
including container resolution, schema validation, lock sequencing,
digest/serialized-byte checks, writing, and audit orchestration. Route the
command and all internal callers through this action, leaving
src/lib/sandbox/config.ts responsible only for adapters and domain helpers and
ensuring no alternate sandbox write path remains.

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/shields/openclaw-config-lock.ts`:
- Around line 161-167: Update the validation-result branch around
schemaIssuePaths and hasSchemaIssues to require a clean validator execution
before treating payload.valid === false as a schema rejection. Track and check
the validator’s successful, non-timeout, non-terminated, non-error execution
status so partial output from failed runs cannot enter this branch; preserve the
existing schema issue handling for clean executions.

In `@test/config-set-nested-ssrf.test.ts`:
- Around line 371-428: Extend the “surfaces an OpenClaw schema rejection…” test
to pass an events array and invoke configSet with restart: true. Assert the
events contain only “validate”, guardSpy remains untouched, and the restart
adapter is not called, replacing the insufficient audit-only assertion while
preserving the existing SandboxConfigError checks.

---

Outside diff comments:
In `@src/lib/sandbox/config.ts`:
- Around line 1019-1074: Extract the OpenClaw validation-and-commit workflow
currently surrounding validatedOpenClawCandidate and withSandboxMutationLock
into one typed action under src/lib/actions, including container resolution,
schema validation, lock sequencing, digest/serialized-byte checks, writing, and
audit orchestration. Route the command and all internal callers through this
action, leaving src/lib/sandbox/config.ts responsible only for adapters and
domain helpers and ensuring no alternate sandbox write path remains.
🪄 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: 431757af-8503-45eb-a180-2f8521339408

📥 Commits

Reviewing files that changed from the base of the PR and between 5b67372 and 98aafd9.

📒 Files selected for processing (7)
  • src/commands/sandbox/config/set.ts
  • src/lib/sandbox/config.ts
  • src/lib/shields/openclaw-config-lock.test.ts
  • src/lib/shields/openclaw-config-lock.ts
  • test/cli-oclif-compatibility.test.ts
  • test/config-set-nested-ssrf.test.ts
  • test/openclaw-config-transaction-wiring.test.ts

Comment thread src/lib/shields/openclaw-config-lock.ts Resolved
Comment thread test/config-set-nested-ssrf.test.ts Resolved
@rluo8 rluo8 added the v0.0.84 label Jul 15, 2026
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior labels Jul 15, 2026

@cv cv 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.

Validated exact head e345d8b: candidate schema validation precedes mutation locks, binds exact bytes and container identity through the CAS write, redacts execution output, and has failure/race/no-write coverage. Product scope is the accepted #6868 QA defect.

@cv
cv merged commit 4f164e1 into NVIDIA:main Jul 15, 2026
78 checks passed
@prekshivyas prekshivyas mentioned this pull request Jul 16, 2026
9 of 21 tasks
cv pushed a commit that referenced this pull request Jul 16, 2026
<!-- markdownlint-disable MD041 -->
## Summary

Adds the canonical `docs/changelog/2026-07-15.mdx` entry with the exact
`## v0.0.84` heading for the release candidate range from `v0.0.83`
through `710d2b36b9eebcb6bca3c2b2f796a1bdb69c3a31`.
Fills two owner-page gaps for model-aware local inference health and
pre-write OpenClaw candidate validation.

## Changes

- Add the complete shared Fern changelog entry for `v0.0.84`, with
literal CLI names and root-absolute OpenClaw and Hermes routes.
- Document that sandbox status and doctor compare the configured Ollama
or vLLM model with provider inventory without issuing a completion.
- Document that host-side OpenClaw `config set` validates the complete
candidate before replacing live config or reaching gateway restart.
- Reconcile the `v0.0.84` release label with the commit range. PR #6773
is already contained in `v0.0.83` and remains documented there; CI,
test-harness, docs-infrastructure, and `.js` to `.mts` migration-only
changes require no additional user guidance.

### Source summary

- [#6882](#6882) ->
`docs/manage-sandboxes/backup-restore.mdx`,
`docs/changelog/2026-07-15.mdx`: Explain that OpenClaw runtime identity
and pairing state are excluded from snapshots and ignored during
restore.
- [#6873](#6873) ->
`docs/inference/set-up-ollama.mdx`, `docs/changelog/2026-07-15.mdx`:
Record the Ollama requested-model environment fallback and interactive
default.
- [#6835](#6835) ->
`docs/changelog/2026-07-15.mdx`: Include the sandbox name in the
documented rebuild resume-recovery behavior.
- [#6886](#6886) ->
`docs/inference/custom-endpoint-security.mdx`,
`docs/inference/set-up-openai-compatible-endpoint.mdx`,
`docs/changelog/2026-07-15.mdx`: Explain the exact-host trusted-private
endpoint opt-in and retained SSRF boundaries.
- [#6887](#6887) ->
`docs/reference/commands.mdx`, `docs/changelog/2026-07-15.mdx`: Document
Telegram channel health verdicts, summary behavior, and exit status.
- [#6863](#6863) ->
`docs/manage-sandboxes/lifecycle.mdx`, `docs/changelog/2026-07-15.mdx`:
Add the missing model-inventory behavior for local status and doctor
checks.
- [#6902](#6902) ->
`docs/manage-sandboxes/runtime-controls.mdx`,
`docs/changelog/2026-07-15.mdx`: Add the missing pre-write OpenClaw
candidate-validation contract.
- [#6916](#6916) ->
`docs/changelog/2026-07-15.mdx`: Preserve the failed-session
fresh-install recovery correction in the release entry.
- [#6934](#6934) ->
`docs/reference/commands.mdx`, `docs/reference/troubleshooting.mdx`,
`docs/security/credential-storage.mdx`, `docs/changelog/2026-07-15.mdx`:
Summarize completed-prompt checkpointing and validated credential reuse
during OpenClaw resume.
- [#6898](#6898) ->
`docs/inference/switch-models.mdx`,
`docs/inference/switch-providers.mdx`,
`docs/reference/troubleshooting.mdx`, `docs/changelog/2026-07-15.mdx`:
Explain Hermes dashboard convergence after in-place inference changes.
- [#6711](#6711) ->
`docs/manage-sandboxes/run-sandboxes.mdx`,
`docs/manage-sandboxes/uninstall-nemoclaw.mdx`,
`docs/reference/architecture.mdx`, `docs/reference/commands.mdx`,
`docs/changelog/2026-07-15.mdx`: Summarize port-scoped host state and
uninstall preservation.
- [#6767](#6767) ->
`docs/inference/configure-model-limits.mdx`,
`docs/inference/set-up-ollama.mdx`,
`docs/reference/troubleshooting.mdx`, `docs/changelog/2026-07-15.mdx`:
Record the Hermes `64000`-token Ollama floor and unchanged OpenClaw
floor.
- [#6862](#6862) ->
`docs/get-started/quickstart.mdx`,
`docs/inference/verify-inference-route.mdx`,
`docs/changelog/2026-07-15.mdx`: Explain retryable not-ready
finalization for unhealthy inference routes.
- [#6766](#6766) ->
`docs/security/tcb-boundary.mdx`, `docs/changelog/2026-07-15.mdx`:
Document definitive stale transition-lock recovery and fail-closed
ambiguous cases.
- [#6948](#6948) ->
`docs/manage-sandboxes/manage-mcp-servers.mdx`,
`docs/changelog/2026-07-15.mdx`: Include Hermes MCP apply-state race
recovery in the release entry without changing the established user
workflow.
- [#6964](#6964) ->
`docs/reference/troubleshooting.mdx`, `docs/changelog/2026-07-15.mdx`:
Record complete agent-specific fresh-install and resume recovery
commands.
- [#6883](#6883) ->
`docs/get-started/quickstart.mdx`, `docs/inference/set-up-vllm.mdx`,
`docs/reference/platform-support.mdx`, `docs/changelog/2026-07-15.mdx`:
Summarize the DGX Station Nemotron Ultra express path and pinned
managed-vLLM recipe.
- [#6985](#6985) ->
`docs/inference/set-up-vllm.mdx`, `docs/reference/commands.mdx`,
`docs/changelog/2026-07-15.mdx`: Capture the final automated and
interactive storage-warning behavior.

## Type of Change

- [ ] Code change (feature, bug fix, or refactor)
- [ ] Code change with doc updates
- [x] Doc only (prose changes, no code sample modifications)
- [ ] Doc only (includes code sample changes)

## Quality Gates

- [ ] Tests added or updated for changed behavior
- [x] Existing tests cover changed behavior —
`test/changelog-docs.test.ts` validates the dated-entry structure, exact
version heading, and preserved history.
- [ ] Tests not applicable — justification:
- [x] Docs updated for user-facing behavior changes
- [ ] Docs not applicable — justification:
- [ ] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [ ] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification:
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification

- [x] PR description includes a `Signed-off-by:` line and every commit
appears as `Verified` in GitHub
- [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or
`npm run check:diff` passed when hooks were skipped or unavailable
- [x] Targeted behavior tests pass for the current change set, or tests
are marked not applicable above — `npx vitest run
test/changelog-docs.test.ts` (6 passed)
- [ ] Applicable broad gate passed — `npm test` for broad
runtime/test-harness changes; `npm run check` for repo-wide
validation/coverage changes — not run for this doc-only change.
- [x] Quality Gates section completed with required justifications or
waivers
- [x] No secrets, API keys, or credentials committed
- [ ] `npm run docs` builds without warnings (doc changes only) —
completed with 0 errors; Fern reported the unchanged unauthenticated
redirect-check and light-theme contrast warnings.
- [x] Doc pages follow the [style
guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md)
(doc changes only)
- [ ] New doc pages include SPDX header and frontmatter (new pages only)
— the native changelog entry uses the required parser-safe MDX SPDX
comment and intentionally has no frontmatter.

---
Signed-off-by: Prekshi Vyas <prekshiv@nvidia.com>


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

## Summary by CodeRabbit

* **Documentation**
* Added the v0.0.84 changelog entry covering setup, endpoint onboarding,
model handling, sandbox readiness, recovery, channel status, and
configuration safeguards.
* Clarified that sandbox health checks validate configured models
against local Ollama and vLLM provider inventories without generating
completions or consuming tokens.
* Documented that invalid runtime configuration changes are rejected
while preserving the existing working configuration.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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 bug-fix PR fixes a bug or regression integration: openclaw OpenClaw integration behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[All Platforms][CLI&UX] config set --restart hangs on the gateway restart — config written but never applied to the running agent

4 participants