{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://guidecheck.org/schemas/verifier-output.schema.json",
  "title": "Verifier Output",
  "description": "Machine-readable output for the GuideCheck Verifier Conformance Profile.",
  "type": "object",
  "required": ["verifier", "input", "guide", "summary", "findings"],
  "additionalProperties": true,
  "properties": {
    "verifier": {
      "type": "object",
      "required": [
        "name",
        "version",
        "verifier_profile",
        "verifier_profile_version",
        "guide_profile",
        "guide_profile_version"
      ],
      "additionalProperties": true,
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+].*)?$" },
        "verifier_profile": { "type": "string", "minLength": 1 },
        "verifier_profile_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+].*)?$" },
        "guide_profile": { "type": "string", "minLength": 1 },
        "guide_profile_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+].*)?$" },
        "build_id": { "type": "string" },
        "fixture_suite_version": { "type": "string" }
      }
    },
    "input": {
      "type": "object",
      "required": ["evaluation_mode"],
      "additionalProperties": true,
      "properties": {
        "url": { "type": "string", "format": "uri" },
        "evaluation_mode": { "type": "string", "enum": ["public-web", "local-file"] },
        "path": { "type": "string", "minLength": 1 },
        "manifest_path": { "type": "string", "minLength": 1 },
        "expected_canonical_url": { "type": "string", "format": "uri" },
        "expected_guide_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "expected_max_level": { "type": "integer", "minimum": 0, "maximum": 5 }
      }
    },
    "fetch": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "final_url": { "type": "string", "format": "uri" },
        "fetched_at": { "type": "string", "format": "date-time" },
        "http_status": { "type": "integer", "minimum": 100, "maximum": 599 },
        "headers": { "type": "object", "additionalProperties": { "type": "string" } },
        "redirects": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["from", "to", "status"],
            "additionalProperties": true,
            "properties": {
              "from": { "type": "string", "format": "uri" },
              "to": { "type": "string", "format": "uri" },
              "status": { "type": "integer", "minimum": 300, "maximum": 399 }
            }
          }
        },
        "tls_valid": { "type": "boolean" }
      }
    },
    "guide": {
      "type": "object",
      "required": ["bytes", "sha256", "achieved_level"],
      "additionalProperties": true,
      "properties": {
        "bytes": { "type": "integer", "minimum": 0 },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "claimed_level": { "type": "integer", "minimum": 0, "maximum": 5 },
        "achieved_level": { "type": "integer", "minimum": 0, "maximum": 4 },
        "level5_ready": { "type": "boolean" }
      }
    },
    "manifest": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "url": { "type": "string", "format": "uri" },
        "path": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
        "fetched": { "type": "boolean" },
        "hash_match": { "type": "boolean" },
        "bytes_match": { "type": "boolean" }
      }
    },
    "local_evaluation": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "evaluated_at": { "type": "string", "format": "date-time" },
        "staleness_threshold_days": { "type": "integer", "minimum": 0 }
      }
    },
    "cross_channel_anchors": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["channel", "status"],
        "additionalProperties": true,
        "properties": {
          "channel": {
            "type": "string",
            "enum": [
              "dns-txt",
              "package-registry",
              "repository-file",
              "signed-security-txt"
            ]
          },
          "status": {
            "type": "string",
            "enum": ["present-matches", "present-mismatch", "unreachable", "absent"]
          },
          "evidence_url": { "type": "string", "format": "uri" },
          "observed_sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
        }
      }
    },
    "summary": {
      "type": "object",
      "required": ["blocking_findings", "warnings", "infos"],
      "additionalProperties": true,
      "properties": {
        "blocking_findings": { "type": "integer", "minimum": 0 },
        "warnings": { "type": "integer", "minimum": 0 },
        "infos": { "type": "integer", "minimum": 0 }
      }
    },
    "findings": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["id", "severity", "message"],
        "additionalProperties": true,
        "properties": {
          "id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]*$" },
          "severity": { "type": "string", "enum": ["error", "warning", "info"] },
          "section": { "type": "string" },
          "line": { "type": "integer", "minimum": 1 },
          "column": { "type": "integer", "minimum": 1 },
          "message": { "type": "string", "minLength": 1 },
          "remediation": { "type": "string" },
          "evidence": { "type": "string" }
        }
      }
    },
    "compact_report": {
      "type": "string",
      "description": "Human-readable compact report rendered as plain text."
    }
  }
}
