{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "devon.scan_contract.schema.v1",
  "title": "DEVON Operational Scan Contract Schema",
  "description": "Schema for operational scans used by the Execution and Operational Verification Panel to observe real server, category, item, service, container, port, file, directory and resource state.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "scan_contract_id",
    "version",
    "status",
    "source",
    "scan_id",
    "target_scope",
    "scan_interval_seconds",
    "scan_command",
    "expected_state",
    "observed_state",
    "evidence_path",
    "last_scan_at",
    "scan_status",
    "missing_items",
    "progress_rules",
    "progress_percent",
    "blocks_execution"
  ],
  "properties": {
    "scan_contract_id": {
      "type": "string",
      "minLength": 1
    },
    "version": {
      "type": "string",
      "const": "v1"
    },
    "status": {
      "type": "string",
      "enum": ["DRAFT", "ACTIVE", "FAIL", "MISSING"]
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "source_phase_id",
        "source_category_id",
        "source_item_id",
        "source_contract_path"
      ],
      "properties": {
        "source_phase_id": {
          "type": "string",
          "pattern": "^phase-[0-9]{2}$"
        },
        "source_category_id": {
          "type": "string",
          "minLength": 1
        },
        "source_item_id": {
          "type": "string"
        },
        "source_contract_path": {
          "type": "string",
          "pattern": "^/home/yeff/public_html/devon/canon/execution/.+\\.json$"
        }
      }
    },
    "scan_id": {
      "type": "string",
      "minLength": 1
    },
    "target_scope": {
      "type": "string",
      "enum": [
        "server",
        "phase",
        "category",
        "item",
        "technology",
        "service",
        "port",
        "container",
        "file",
        "directory",
        "resource"
      ]
    },
    "scan_interval_seconds": {
      "type": "integer",
      "minimum": 1
    },
    "scan_command": {
      "type": "string"
    },
    "expected_state": {
      "type": "string"
    },
    "observed_state": {
      "type": "string"
    },
    "evidence_path": {
      "type": "string"
    },
    "last_scan_at": {
      "type": "string"
    },
    "scan_status": {
      "type": "string",
      "enum": ["PASS", "FAIL", "MISSING", "STALE", "DEGRADED"]
    },
    "missing_items": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "progress_rules": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "progress_percent": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100
    },
    "blocks_execution": {
      "type": "boolean"
    }
  }
}
