{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "start_rollout",
  "type": "object",
  "properties": {
    "service_contracts": {
      "description": "Optional service contracts: must pass before any change and after every wave. Probes originate from the MCP host, not the router. Unknown blocks the gate.",
      "maxItems": 10,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "device": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": ["id", "device"],
        "additionalProperties": false
      }
    },
    "commands": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "string"
        }
      ],
      "description": "RouterOS commands to apply to every device"
    },
    "targets": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        {
          "type": "object",
          "properties": {
            "all": {
              "description": "Every configured, enabled device",
              "type": "boolean"
            },
            "tags": {
              "description": "Devices carrying ALL of these config tags",
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "versionBelow": {
              "description": "Devices whose RouterOS version is below this, e.g. \"7.14\" (uses the capability cache)",
              "type": "string"
            },
            "exclude": {
              "description": "Device names to leave out — composable",
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "strategy": {
      "type": "object",
      "properties": {
        "canary": {
          "description": "Devices in wave 1 (default 1)",
          "type": "integer",
          "exclusiveMinimum": 0,
          "maximum": 9007199254740991
        },
        "wavePercent": {
          "description": "Percent of the remaining devices in wave 2 (default 25)",
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        },
        "soakSeconds": {
          "description": "Wait after each wave's health check before continuing (default 30)",
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "onFailure": {
          "description": "What to do when a wave's gate fails (default halt-and-revert)",
          "type": "string",
          "enum": ["halt-and-revert", "halt-and-hold", "continue"]
        }
      },
      "additionalProperties": false
    },
    "label": {
      "type": "string"
    },
    "confirm": {
      "default": false,
      "description": "Must be true to execute — false returns the plan instead",
      "type": "boolean"
    }
  },
  "required": ["commands", "targets", "confirm"],
  "additionalProperties": false
}
