{
  "$schema": "https://stravica.ai/schemas/runbook/1.0",
  "id": "hq-dave-v1-to-v2",
  "target": "hq-dave",
  "description": "Migrate HQ Dave instance from v1 fork to v2 operator-repo.",
  "version": "1.0.0",
  "inspectionRef": "inspection-hq-dave.json",
  "steps": [
    {
      "id": "step-1",
      "intent": "snapshot-v1-fork",
      "description": "Preserve the v1 fork as rollback point.",
      "params": { "snapshotSuffix": "pre-v2-{{inspectedAt|date}}" },
      "preconditions": [
        { "assert": "workingTreeClean" },
        { "assert": "onBranch", "value": "main" }
      ],
      "expect": { "produces": ["{{daveRoot}}-pre-v2-{{inspectedAt|date}}/"] },
      "rollback": { "trigger": "v2 instance fails 24h soak", "action": "restore-from-snapshot" }
    },
    {
      "id": "step-2",
      "intent": "run-migrate-to-v2",
      "description": "Run migrate-to-v2 CLI against the v1 fork.",
      "params": {
        "source": "{{daveRoot}}",
        "target": "{{daveRoot}}-v2",
        "dryRun": false
      },
      "preconditions": [
        { "assert": "snapshotExists" },
        { "assert": "nodeVersion", "value": ">=24" },
        { "assert": "pnpmOnPath" }
      ],
      "expect": { "produces": ["{{daveRoot}}-v2/package.json", "{{daveRoot}}-v2/operator/"] },
      "rollback": { "trigger": "migrate-to-v2 exits non-zero", "action": "restore-from-snapshot" }
    },
    {
      "id": "step-3",
      "intent": "update-host-service",
      "description": "Update the workspace launchd plist to point to the v2 instance.",
      "params": {
        "label": "com.dave.workspace",
        "workingDirectory": "{{daveRoot}}-v2"
      },
      "preconditions": [
        { "assert": "hostService", "value": "com.dave.workspace" }
      ],
      "expect": { "produces": ["~/Library/LaunchAgents/com.dave.workspace.plist"] },
      "rollback": { "trigger": "workspace fails to start", "action": "restore-previous-plist" }
    },
    {
      "id": "step-4",
      "intent": "verify-boot-health",
      "description": "Verify pa status exits 0 in the v2 instance.",
      "params": { "daveRoot": "{{daveRoot}}-v2" },
      "preconditions": [
        { "assert": "directoryExists", "value": "{{daveRoot}}-v2" }
      ],
      "expect": { "exitCode": 0 }
    },
    {
      "id": "step-5",
      "intent": "define-roster-entry",
      "description": "Register hq-dave in the operator roster as a v2 instance.",
      "params": { "hostId": "hq-dave", "layoutVersion": "v2", "daveRoot": "{{daveRoot}}-v2" }
    }
  ]
}
