{
  "schemaVersion": "1.0",
  "item": {
    "slug": "gateway-auto-rollback",
    "name": "Gateway Auto-Rollback",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "canonicalUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadMode": "redirect",
    "downloadUrl": "/downloads/gateway-auto-rollback",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gateway-auto-rollback",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "installMethod": "Manual import",
    "extraction": "Extract archive",
    "prerequisites": [
      "OpenClaw"
    ],
    "packageFormat": "ZIP package",
    "includedAssets": [
      "SKILL.md",
      "_meta.json",
      "gateway-auto-rollback.py",
      "test-rollback-mechanism.sh"
    ],
    "primaryDoc": "SKILL.md",
    "quickSetup": [
      "Download the package from Yavira.",
      "Extract the archive and review SKILL.md first.",
      "Import or place the package into your OpenClaw setup."
    ],
    "agentAssist": {
      "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
      "steps": [
        "Download the package from Yavira.",
        "Extract it into a folder your agent can access.",
        "Paste one of the prompts below and point your agent at the extracted folder."
      ],
      "prompts": [
        {
          "label": "New install",
          "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
        },
        {
          "label": "Upgrade existing",
          "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
        }
      ]
    },
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/gateway-auto-rollback"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    },
    "downloadPageUrl": "https://openagent3.xyz/downloads/gateway-auto-rollback",
    "agentPageUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent",
    "manifestUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.md"
  },
  "agentAssist": {
    "summary": "Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.",
    "steps": [
      "Download the package from Yavira.",
      "Extract it into a folder your agent can access.",
      "Paste one of the prompts below and point your agent at the extracted folder."
    ],
    "prompts": [
      {
        "label": "New install",
        "body": "I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete."
      },
      {
        "label": "Upgrade existing",
        "body": "I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run."
      }
    ]
  },
  "documentation": {
    "source": "clawhub",
    "primaryDoc": "SKILL.md",
    "sections": [
      {
        "title": "Gateway Auto-Rollback",
        "body": "Three-layer configuration protection for OpenClaw Gateway — never break your config again."
      },
      {
        "title": "What It Does",
        "body": "Automatically protects your OpenClaw configuration files with:\n\nPre-modification backup — SHA256 content-addressed snapshots before any change\nPost-modification validation — JSON syntax check + Gateway health probe\nAutomatic rollback — instant restore if validation fails"
      },
      {
        "title": "When to Use",
        "body": "Before modifying openclaw.json, exec-approvals.json, or skills.json\nWhen running automated config changes (cron jobs, scripts)\nAs a background safety net during development\nWhen you want peace of mind that a bad config won't take down your agent"
      },
      {
        "title": "One-shot check (before manual edits)",
        "body": "python3 gateway-auto-rollback.py\n\nThis initializes the backup directory, validates current config, and logs status."
      },
      {
        "title": "Watch mode (background daemon)",
        "body": "python3 gateway-auto-rollback.py --watch &\n\nMonitors critical config files every 3 minutes. Auto-exits after 3 consecutive healthy checks (config is stable)."
      },
      {
        "title": "How It Works",
        "body": "Before Modification        During              After Modification\n       ↓                    ↓                        ↓\n  Backup + Hash  ───→  Execute Change  ───→  JSON Validate + Health Check\n       │                                          │\n       └──────────────────────────────────────→ Auto-rollback on failure"
      },
      {
        "title": "Protected Files",
        "body": "FileDescriptionopenclaw.jsonMain Gateway configurationexec-approvals.jsonCommand execution approvalsskills.jsonSkills registry"
      },
      {
        "title": "Backup Naming",
        "body": "Backups are stored in ~/.openclaw/backup/ with content-addressed names:\n\nopenclaw.json.20260301_053612.a1b2c3d4.bak\n                 ↑ timestamp    ↑ SHA256 prefix (dedup)"
      },
      {
        "title": "Python Functions",
        "body": "from gateway_auto_rollback import (\n    pre_modification_check,   # Call before modifying config\n    post_modification_verify, # Call after modifying config\n    create_backup,            # Manual backup creation\n    validate_json,            # JSON syntax validation\n    check_gateway_health,     # Gateway health probe\n    rollback_to_backup,       # Manual rollback\n    watch_config_files,       # Start watch daemon\n)"
      },
      {
        "title": "Pre-modification flow",
        "body": "from pathlib import Path\n\nconfig = Path.home() / \".openclaw\" / \"openclaw.json\"\n\n# Returns backup path on success, False on failure\nbackup = pre_modification_check(config)\n\n# ... make your changes ...\n\n# Validates and auto-rolls back if needed\nsuccess = post_modification_verify(config, backup)"
      },
      {
        "title": "Watch mode details",
        "body": "The watcher:\n\nPolls every 3 minutes (gives Gateway time to restart)\nDetects changes via SHA256 hash comparison\nAuto-creates backup when change detected\nValidates JSON + health check after each change\nAuto-exits after 3 consecutive healthy checks (config stabilized)\nLogs all events to ~/.openclaw/logs/config-modification.log"
      },
      {
        "title": "Integration with Cron",
        "body": "Set up periodic health checks:\n\n# Cron job example: check every hour\n0 * * * * python3 /path/to/gateway-auto-rollback.py\n\nOr use OpenClaw's built-in cron:\n\n{\n  \"name\": \"Gateway-Auto-Rollback\",\n  \"schedule\": { \"kind\": \"cron\", \"expr\": \"0 */6 * * *\", \"tz\": \"Asia/Shanghai\" },\n  \"payload\": {\n    \"kind\": \"agentTurn\",\n    \"message\": \"Run gateway health check. If unhealthy, rollback to latest backup.\"\n  },\n  \"sessionTarget\": \"isolated\"\n}"
      },
      {
        "title": "Manual Rollback",
        "body": "If you need to manually restore a config:\n\n# List available backups (newest first)\nls -lt ~/.openclaw/backup/ | head -10\n\n# Restore a specific backup\ncp ~/.openclaw/backup/openclaw.json.20260301_053612.a1b2c3d4.bak \\\n   ~/.openclaw/openclaw.json\n\n# Restart Gateway\nopenclaw gateway restart\n\n# Verify\ncurl -s http://127.0.0.1:18789/api/health"
      },
      {
        "title": "Testing",
        "body": "Run the included test suite to verify the mechanism works:\n\nbash test-rollback-mechanism.sh\n\nTests cover:\n\nBackup directory existence\nJSON validation\nSHA256 hash computation\nBackup creation and restore\nWatch daemon status\nLog file integrity\nScript permissions"
      },
      {
        "title": "Logs",
        "body": "All events are logged to ~/.openclaw/logs/config-modification.log:\n\n[2026-03-01 05:37:00] INFO: ✅ 备份创建: openclaw.json.20260301_053612.a1b2c3d4.bak\n[2026-03-01 05:37:01] INFO: ✅ 修改验证通过\n[2026-03-01 05:40:00] WARN: ⚠️ 检测到修改: openclaw.json\n[2026-03-01 05:40:01] ERROR: JSON 验证失败 — 触发回滚"
      },
      {
        "title": "Requirements",
        "body": "Python 3.8+\nOpenClaw Gateway running (for health checks)\nNo additional pip packages needed (stdlib only)"
      },
      {
        "title": "File Structure",
        "body": "gateway-auto-rollback/\n├── SKILL.md                      # This file\n├── _meta.json                    # ClawHub metadata\n├── gateway-auto-rollback.py      # Main script (backup/validate/rollback/watch)\n└── test-rollback-mechanism.sh    # Test suite"
      }
    ],
    "body": "Gateway Auto-Rollback\n\nThree-layer configuration protection for OpenClaw Gateway — never break your config again.\n\nWhat It Does\n\nAutomatically protects your OpenClaw configuration files with:\n\nPre-modification backup — SHA256 content-addressed snapshots before any change\nPost-modification validation — JSON syntax check + Gateway health probe\nAutomatic rollback — instant restore if validation fails\nWhen to Use\nBefore modifying openclaw.json, exec-approvals.json, or skills.json\nWhen running automated config changes (cron jobs, scripts)\nAs a background safety net during development\nWhen you want peace of mind that a bad config won't take down your agent\nQuick Start\nOne-shot check (before manual edits)\npython3 gateway-auto-rollback.py\n\n\nThis initializes the backup directory, validates current config, and logs status.\n\nWatch mode (background daemon)\npython3 gateway-auto-rollback.py --watch &\n\n\nMonitors critical config files every 3 minutes. Auto-exits after 3 consecutive healthy checks (config is stable).\n\nHow It Works\nBefore Modification        During              After Modification\n       ↓                    ↓                        ↓\n  Backup + Hash  ───→  Execute Change  ───→  JSON Validate + Health Check\n       │                                          │\n       └──────────────────────────────────────→ Auto-rollback on failure\n\nProtected Files\nFile\tDescription\nopenclaw.json\tMain Gateway configuration\nexec-approvals.json\tCommand execution approvals\nskills.json\tSkills registry\nBackup Naming\n\nBackups are stored in ~/.openclaw/backup/ with content-addressed names:\n\nopenclaw.json.20260301_053612.a1b2c3d4.bak\n                 ↑ timestamp    ↑ SHA256 prefix (dedup)\n\nAPI Reference\nPython Functions\nfrom gateway_auto_rollback import (\n    pre_modification_check,   # Call before modifying config\n    post_modification_verify, # Call after modifying config\n    create_backup,            # Manual backup creation\n    validate_json,            # JSON syntax validation\n    check_gateway_health,     # Gateway health probe\n    rollback_to_backup,       # Manual rollback\n    watch_config_files,       # Start watch daemon\n)\n\nPre-modification flow\nfrom pathlib import Path\n\nconfig = Path.home() / \".openclaw\" / \"openclaw.json\"\n\n# Returns backup path on success, False on failure\nbackup = pre_modification_check(config)\n\n# ... make your changes ...\n\n# Validates and auto-rolls back if needed\nsuccess = post_modification_verify(config, backup)\n\nWatch mode details\n\nThe watcher:\n\nPolls every 3 minutes (gives Gateway time to restart)\nDetects changes via SHA256 hash comparison\nAuto-creates backup when change detected\nValidates JSON + health check after each change\nAuto-exits after 3 consecutive healthy checks (config stabilized)\nLogs all events to ~/.openclaw/logs/config-modification.log\nIntegration with Cron\n\nSet up periodic health checks:\n\n# Cron job example: check every hour\n0 * * * * python3 /path/to/gateway-auto-rollback.py\n\n\nOr use OpenClaw's built-in cron:\n\n{\n  \"name\": \"Gateway-Auto-Rollback\",\n  \"schedule\": { \"kind\": \"cron\", \"expr\": \"0 */6 * * *\", \"tz\": \"Asia/Shanghai\" },\n  \"payload\": {\n    \"kind\": \"agentTurn\",\n    \"message\": \"Run gateway health check. If unhealthy, rollback to latest backup.\"\n  },\n  \"sessionTarget\": \"isolated\"\n}\n\nManual Rollback\n\nIf you need to manually restore a config:\n\n# List available backups (newest first)\nls -lt ~/.openclaw/backup/ | head -10\n\n# Restore a specific backup\ncp ~/.openclaw/backup/openclaw.json.20260301_053612.a1b2c3d4.bak \\\n   ~/.openclaw/openclaw.json\n\n# Restart Gateway\nopenclaw gateway restart\n\n# Verify\ncurl -s http://127.0.0.1:18789/api/health\n\nTesting\n\nRun the included test suite to verify the mechanism works:\n\nbash test-rollback-mechanism.sh\n\n\nTests cover:\n\nBackup directory existence\nJSON validation\nSHA256 hash computation\nBackup creation and restore\nWatch daemon status\nLog file integrity\nScript permissions\nLogs\n\nAll events are logged to ~/.openclaw/logs/config-modification.log:\n\n[2026-03-01 05:37:00] INFO: ✅ 备份创建: openclaw.json.20260301_053612.a1b2c3d4.bak\n[2026-03-01 05:37:01] INFO: ✅ 修改验证通过\n[2026-03-01 05:40:00] WARN: ⚠️ 检测到修改: openclaw.json\n[2026-03-01 05:40:01] ERROR: JSON 验证失败 — 触发回滚\n\nRequirements\nPython 3.8+\nOpenClaw Gateway running (for health checks)\nNo additional pip packages needed (stdlib only)\nFile Structure\ngateway-auto-rollback/\n├── SKILL.md                      # This file\n├── _meta.json                    # ClawHub metadata\n├── gateway-auto-rollback.py      # Main script (backup/validate/rollback/watch)\n└── test-rollback-mechanism.sh    # Test suite"
  },
  "trust": {
    "sourceLabel": "tencent",
    "provenanceUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "publisherUrl": "https://clawhub.ai/halfmoon82/gateway-auto-rollback",
    "owner": "halfmoon82",
    "version": "1.1.0",
    "license": null,
    "verificationStatus": "Indexed source record"
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/gateway-auto-rollback",
    "downloadUrl": "https://openagent3.xyz/downloads/gateway-auto-rollback",
    "agentUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent",
    "manifestUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/gateway-auto-rollback/agent.md"
  }
}