fix(openclaw): merge restored config with runtime state#5174
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds ownership-aware merging for ChangesOpenClaw Config Restore with Selective Merge
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
E2E Scenario Advisor RecommendationRequired scenario E2E: None Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
PR Review AdvisorFindings: 1 needs attention, 5 worth checking, 0 nice ideas Review findings🛠️ Needs attention
🔎 Worth checking
🌱 Nice ideas
Consider writing more tests for
Since last review detailsCurrent findings:
This is an automated advisory review. A human maintainer must make the final merge decision. |
Selective E2E Results — ✅ All requested jobs passedRun: 27303738999
|
Selective E2E Results — ❌ Some jobs failedRun: 27304497923
|
|
The regression came from treating I opened the stacked follow-up with focused unit/fake-SSH coverage and a fail-closed guard here: #5178. It covers the restore boundary cases without adding another expensive E2E. |
prekshivyas
left a comment
There was a problem hiding this comment.
Reviewed (code + 9-cat security) — scrutinized as a real code fix, not just tests. Replaces the wholesale overwrite of the rebuilt openclaw.json during restoreSandboxState with an ownership-aware merge (new openclaw-config-merge.ts): runtime-owned sections (gateway/proxy/diagnostics) + managed channel/provider/plugin state come from the live rebuilt config, while durable user settings (mcpServers, customAgents, agents, custom providers/plugins, non-managed channels) inherit from the sanitized backup.
✅ Approve — fixes the #5101 regression where a sanitized/stale backup clobbered fresh runtime state. Verified: managed channels are never resurrected, current provider/plugin wins by id while backup-only entries survive, arrays replace wholesale, and the snapshot assertion flip (kimi-k2→nemotron) correctly reflects the intended behavior.
Security: all 9 pass — the merge writes back to the sandbox while the on-disk backup stays sanitized (no stale real secret reintroduced; placeholders preserved); the new SSH read rejects symlinks (-f && ! -L) and shell-quotes paths; on parse/read error it fails safe to the sanitized backup. Nit: shouldMergeOpenClawConfig matches with .endsWith("/.openclaw") while the sibling guard uses exact === — align for consistency. Non-blocking: no test exercises the parse-error fallback path.
Selective E2E Results — ❌ Some jobs failedRun: 27306478566
|
Follow-up to PR #5174 addressing PR Review Advisor feedback that unsafe fallback paths could wholesale restore sanitized backup openclaw.json over fresh runtime-owned config. Changes: - fail OpenClaw openclaw.json restore when current rebuilt config is missing/unreadable or either JSON parse fails - move restore input/read/source-of-truth policy into a focused helper module - keep current provider/plugin entries for matching keys while preserving backup-only custom entries, including absent current entry-map coverage - add regression tests for missing current config, invalid current JSON, invalid backup JSON, provider/plugin edge cases, and fake-SSH restore behavior Validation: - npm run build:cli - npx vitest run src/lib/state/openclaw-config-merge.test.ts src/lib/state/openclaw-config-restore-input.test.ts - npx vitest run test/snapshot.test.ts -t "backs up and restores openclaw.json settings|excludes tar-failed" --testTimeout=15000 - npm run checks -- --changed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Selective-merge for OpenClaw restores: prefers current runtime-generated config, preserves backup-only entries, and recomputes/stores sandbox config hash on successful restores. * **Bug Fixes** * Prevent stale backup data from overwriting rebuilt/runtime-managed OpenClaw settings; restore now fails if a safe merge cannot be constructed. * **Tests** * Added extensive tests for merge logic, restore-input generation, sandbox restore flows, and snapshot/ssh restore scenarios. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary - Add the v0.0.63 release-note section using the published development note as source context. - Update source docs for sandbox recovery, OpenClaw config restore safety, managed vLLM selection, Slack Socket Mode conflict handling, and host diagnostics. - Refresh generated `nemoclaw-user-*` skills from the updated Fern MDX docs. - Update the release-doc refresh skill so post-release docs for version `n` look up the matching announcement discussion and use the `n+1` patch release label. - Fix CLI/docs parity by avoiding a `--from <Dockerfile>` flag mention inside the `upgrade-sandboxes` command section. ## Source summary - #5034 -> `docs/reference/troubleshooting.mdx`, `docs/about/release-notes.mdx`: Document safer stale-sandbox recovery through `rebuild --yes` before recreating from scratch. - #5091 -> `docs/reference/troubleshooting.mdx`, `docs/about/release-notes.mdx`: Document Docker-driver post-reboot recovery from OpenShell container labels. - #5101, #5174, #5177 -> `docs/manage-sandboxes/backup-restore.mdx`, `docs/about/release-notes.mdx`: Document OpenClaw `openclaw.json` preservation, merge behavior, and fail-safe restore handling. - #5102 -> `docs/reference/commands.mdx`, `docs/reference/commands-nemohermes.mdx`, `docs/manage-sandboxes/lifecycle.mdx`, `docs/about/release-notes.mdx`: Document `upgrade-sandboxes` image-fingerprint drift detection. - #4201 -> `docs/reference/troubleshooting.mdx`, `docs/about/release-notes.mdx`: Document the installer diagnostic for unexpected Docker daemon access outside the `docker` group. - #5038 -> `docs/inference/inference-options.mdx`, `docs/inference/use-local-inference.mdx`, `docs/about/release-notes.mdx`: Document the interactive managed-vLLM model picker and non-interactive override behavior. - #5040, #5041 -> `docs/reference/troubleshooting.mdx`, `docs/about/release-notes.mdx`: Document Ollama auth-proxy recovery and host DNS preflight diagnostics. - #4986, #5039 -> `docs/manage-sandboxes/messaging-channels.mdx`, `docs/about/release-notes.mdx`: Document Slack validation and duplicate Slack Socket Mode sandbox handling. - #4981, #5168 -> `docs/about/release-notes.mdx`: Capture Hermes gateway secret-guard and wrapped-argv startup hardening in the release surface. - Follow-up -> `.agents/skills/nemoclaw-contributor-update-docs/SKILL.md`: Record the post-release docs workflow, discussion-announcement lookup, and next-patch release label rule. - Follow-up -> `docs/reference/commands.mdx`, `docs/reference/commands-nemohermes.mdx`: Reword custom Dockerfile sandbox text so CLI parity does not treat `--from` as an `upgrade-sandboxes` flag. ## Verification - `python3 scripts/docs-to-skills.py docs/ .agents/skills/ --prefix nemoclaw-user --doc-platform fern-mdx` - `npm run docs` - `npm run build:cli` - `bash test/e2e/e2e-cloud-experimental/check-docs.sh --only-cli` - Skip-term scan for `docs/.docs-skip` blocked terms across generated user skills <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Enhanced local inference setup with interactive model selection prompts and environment variable overrides * Improved sandbox upgrade detection using build fingerprints and version checks * Clarified configuration restore behavior preserving user settings during rebuild/restore * Added gateway authentication as fifth security layer * Expanded Slack messaging validation with live credential checking * Enhanced troubleshooting guidance for Docker access, DNS issues, and sandbox recovery * Updated release notes for v0.0.63 featuring sandbox recovery and inference improvements <!-- end of auto-generated comment: release notes by coderabbit.ai -->
## Summary Follow-up to #5174 that pins the risky OpenClaw config restore fallback cases. The restore now fails closed when selective merging cannot read or parse the current rebuilt config, or cannot parse the backup, leaving the fresh runtime config intact instead of writing a stale sanitized backup wholesale. ## Related Issue Follow-up to #5174. ## Changes - Treat OpenClaw config selective-merge failures as state-file restore failures rather than falling back to the backup contents. - Add focused fake-SSH coverage for missing/invalid current `openclaw.json` and invalid backed-up `openclaw.json`. - Document provider/plugin merge behavior when the rebuilt config lacks generated maps. - Update snapshot fake SSH fixtures to model absent `openclaw.json` state files instead of zero-byte successful reads. ## Type of Change - [x] 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) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] 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) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit **New Features** - OpenClaw config hash now automatically refreshes after sandbox restore operations, ensuring configuration consistency **Tests** - Added comprehensive test coverage for config restore failure scenarios - Added tests validating config hash refresh functionality - Extended regression test coverage for configuration integrity validation <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Julie Yaunches <jyaunches@nvidia.com>
Summary
Validation
Notes
Summary by CodeRabbit
New Features
Tests