{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "devon.refresh_event_contract.schema.v1",
  "title": "DEVON State Refresh Event Contract Schema",
  "description": "Schema for immediate state refresh events triggered by execution, validation, manual recheck, incident, recovery, rollback, service change or scheduled scans.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "refresh_event_contract_id",
    "version",
    "status",
    "refresh_event_id",
    "triggered_by_task_id",
    "trigger_type",
    "target_scope",
    "checks_to_run",
    "refresh_priority",
    "started_at",
    "completed_at",
    "result_status",
    "updated_items",
    "detected_changes",
    "missing_items",
    "next_required_action"
  ],
  "properties": {
    "refresh_event_contract_id": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "const": "v1"
    },
    "status": {
      "type": "string",
      "enum": ["DRAFT", "ACTIVE", "FAIL", "MISSING"]
    },
    "refresh_event_id": {
      "type": "string",
      "minLength": 1
    },
    "triggered_by_task_id": {
      "type": "string"
    },
    "trigger_type": {
      "type": "string",
      "enum": [
        "scheduled",
        "after_execution",
        "after_validation",
        "manual",
        "impact_watch",
        "incident",
        "recovery",
        "rollback",
        "service_change"
      ]
    },
    "target_scope": {
      "type": "string",
      "enum": [
        "server",
        "phase",
        "category",
        "item",
        "service",
        "container",
        "port",
        "resource",
        "file",
        "directory"
      ]
    },
    "checks_to_run": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "refresh_priority": {
      "type": "string",
      "enum": ["low", "normal", "high", "critical"]
    },
    "started_at": {
      "type": "string"
    },
    "completed_at": {
      "type": "string"
    },
    "result_status": {
      "type": "string",
      "enum": ["PASS", "FAIL", "MISSING", "STALE", "DEGRADED"]
    },
    "updated_items": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "detected_changes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "missing_items": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "next_required_action": {
      "type": "string"
    }
  }
}
