config-guardian

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Config Guardian

配置守护程序

Overview

概述

Use this workflow whenever editing
~/.openclaw/openclaw.json
or running
openclaw config set/apply
. It prevents invalid config, creates backups, validates against schema, and enables rollback.
每当编辑
~/.openclaw/openclaw.json
或执行
openclaw config set/apply
命令时,均可使用此工作流。它能防止无效配置、创建备份、基于Schema验证配置,并支持回滚操作。

Workflow (use every time)

工作流(每次修改都需遵循)

  1. Preflight
    • Confirm the requested change and scope.
    • Check for sensitive keys (tokens, credentials).
  2. Backup
    • Run
      scripts/backup_config.sh
      to create a timestamped snapshot.
  3. Validate (before change)
    • Run
      scripts/validate_config.sh
      .
    • If validation fails, stop and report.
  4. Apply change
    • Prefer
      openclaw config set <path> <value>
      for small changes.
    • For complex edits, edit the file directly and keep diffs minimal.
  5. Validate (after change)
    • Run
      scripts/validate_config.sh
      again.
    • If it fails, restore from backup with
      scripts/restore_config.sh
      .
  6. Restart (only with explicit approval)
    • If change requires restart, ask for approval first.
    • Use
      openclaw gateway restart
      .
  1. 预检
    • 确认所需修改内容及范围。
    • 检查是否包含敏感密钥(令牌、凭证)。
  2. 备份
    • 执行
      scripts/backup_config.sh
      脚本创建带时间戳的快照。
  3. 验证(修改前)
    • 执行
      scripts/validate_config.sh
      脚本。
    • 若验证失败,立即停止操作并上报问题。
  4. 应用修改
    • 对于小范围修改,优先使用
      openclaw config set <path> <value>
      命令。
    • 对于复杂编辑,可直接修改配置文件,并尽量减少差异。
  5. 验证(修改后)
    • 再次执行
      scripts/validate_config.sh
      脚本。
    • 若验证失败,使用
      scripts/restore_config.sh
      脚本从备份恢复配置。
  6. 重启(仅在获得明确批准后执行)
    • 若修改需要重启,需先获得用户批准。
    • 使用
      openclaw gateway restart
      命令执行重启。

Guardrails

防护规则

  • Never restart or apply config without explicit user approval.
  • Never remove keys or reorder blocks unless requested.
  • Always keep a backup before edits.
  • If unsure about schema: run
    openclaw doctor --non-interactive
    and stop on errors.
  • 禁止在未获得用户明确批准的情况下重启或应用配置。
  • 禁止在未收到请求的情况下删除密钥或调整配置块顺序。
  • 必须在编辑前创建备份。
  • 若对Schema有疑问:执行
    openclaw doctor --non-interactive
    命令,遇到错误立即停止操作。

Scripts

脚本说明

  • scripts/backup_config.sh
    — create timestamped backup
  • scripts/validate_config.sh
    — validate config via OpenClaw doctor
  • scripts/diff_config.sh
    — diff current config vs backup
  • scripts/restore_config.sh
    — restore backup
  • scripts/backup_config.sh
    — 创建带时间戳的配置备份
  • scripts/validate_config.sh
    — 通过OpenClaw doctor验证配置
  • scripts/diff_config.sh
    — 对比当前配置与备份的差异
  • scripts/restore_config.sh
    — 从备份恢复配置

Validation

验证说明

  • Use
    openclaw doctor --non-interactive
    for schema validation
  • This checks against the actual schema that the gateway uses
  • Warns about unknown keys, invalid types, and security issues
  • 使用
    openclaw doctor --non-interactive
    命令进行Schema验证
  • 该命令会基于网关实际使用的Schema进行检查
  • 会针对未知密钥、无效类型及安全问题发出警告