{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wp-content.ru/schemas/px320-rendered-cli-observation-1.0.0.json",
  "title": "320px Site Audit rendered CLI observation",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "schema_version", "artifact_id", "created_at", "generator", "duration_ms", "scope", "pages", "limitations"],
  "properties": {
    "schema": {"const": "px320-rendered-cli-observation"},
    "schema_version": {"const": "1.0.0"},
    "artifact_id": {"type": "string", "format": "uuid"},
    "created_at": {"type": "string", "format": "date-time"},
    "generator": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name", "version", "engine", "browser", "accessibility_engine"],
      "properties": {
        "name": {"const": "320px Site Audit browser CLI"},
        "version": {"const": "0.1.1"},
        "engine": {"const": "playwright-chromium-1.62.1"},
        "browser": {"oneOf": [{"const": "chromium-151.0.7922.34"}, {"type": "null"}]},
        "accessibility_engine": {"const": "axe-core-4.10.3"}
      }
    },
    "duration_ms": {"$ref": "#/$defs/count300000"},
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "required": ["target_count", "viewport_widths", "browser_load_attempts"],
      "properties": {
        "target_count": {"type": "integer", "minimum": 1, "maximum": 5},
        "viewport_widths": {"const": [360, 390, 768, 1024, 1440]},
        "browser_load_attempts": {"type": "integer", "minimum": 0, "maximum": 5}
      }
    },
    "pages": {
      "type": "array",
      "minItems": 1,
      "maxItems": 5,
      "items": {"$ref": "#/$defs/result"}
    },
    "limitations": {
      "const": [
        "aggregate_only",
        "cookies_not_observed",
        "downloads_cancelled",
        "form_submission_blocked",
        "interaction_activation_not_tested",
        "no_authentication",
        "no_dom_excerpts",
        "no_screenshots",
        "page_script_interference_possible",
        "popup_navigation_blocked",
        "storage_values_not_read",
        "webrtc_blocked",
        "websockets_blocked",
        "webtransport_blocked",
        "workers_blocked"
      ]
    }
  },
  "$defs": {
    "count100000": {"type": "integer", "minimum": 0, "maximum": 100000},
    "count300000": {"type": "integer", "minimum": 0, "maximum": 300000},
    "count500000": {"type": "integer", "minimum": 0, "maximum": 500000},
    "count10000000": {"type": "integer", "minimum": 0, "maximum": 10000000},
    "result": {
      "type": "object",
      "additionalProperties": false,
      "required": ["capability", "page"],
      "properties": {
        "capability": {
          "type": "object",
          "additionalProperties": false,
          "required": ["state", "reason"],
          "properties": {
            "state": {"enum": ["available", "blocked"]},
            "reason": {"enum": ["available", "browser_unavailable", "browser_version_mismatch", "inspection_failed", "navigation_blocked", "navigation_failed", "navigation_timeout", "request_budget_exceeded", "target_timeout", "transfer_budget_exceeded"]}
          }
        },
        "page": {"oneOf": [{"$ref": "#/$defs/page"}, {"type": "null"}]}
      },
      "allOf": [
        {
          "if": {"properties": {"capability": {"type": "object", "properties": {"state": {"const": "available"}}}}},
          "then": {"properties": {"page": {"$ref": "#/$defs/page"}}},
          "else": {"properties": {"page": {"type": "null"}}}
        }
      ]
    },
    "page": {
      "type": "object",
      "additionalProperties": false,
      "required": ["page_ref", "viewports", "dom", "javascript", "network", "accessibility", "focus", "motion", "storage", "runtime"],
      "properties": {
        "page_ref": {"type": "string", "pattern": "^page:[a-f0-9]{24}$"},
        "viewports": {
          "type": "array",
          "minItems": 5,
          "maxItems": 5,
          "prefixItems": [
            {"allOf": [{"$ref": "#/$defs/viewport"}, {"type": "object", "properties": {"width": {"const": 360}}}]},
            {"allOf": [{"$ref": "#/$defs/viewport"}, {"type": "object", "properties": {"width": {"const": 390}}}]},
            {"allOf": [{"$ref": "#/$defs/viewport"}, {"type": "object", "properties": {"width": {"const": 768}}}]},
            {"allOf": [{"$ref": "#/$defs/viewport"}, {"type": "object", "properties": {"width": {"const": 1024}}}]},
            {"allOf": [{"$ref": "#/$defs/viewport"}, {"type": "object", "properties": {"width": {"const": 1440}}}]}
          ],
          "items": false
        },
        "dom": {"$ref": "#/$defs/dom"},
        "javascript": {"$ref": "#/$defs/javascript"},
        "network": {"$ref": "#/$defs/network"},
        "accessibility": {"$ref": "#/$defs/accessibility"},
        "focus": {"$ref": "#/$defs/focus"},
        "motion": {"$ref": "#/$defs/motion"},
        "storage": {"$ref": "#/$defs/storage"},
        "runtime": {"$ref": "#/$defs/runtime"}
      }
    },
    "viewport": {
      "type": "object",
      "additionalProperties": false,
      "required": ["width", "height", "document_width", "document_height", "overflow_element_count", "clipped_fixed_count", "truncated"],
      "properties": {
        "width": {"enum": [360, 390, 768, 1024, 1440]},
        "height": {"const": 900},
        "document_width": {"$ref": "#/$defs/count10000000"},
        "document_height": {"$ref": "#/$defs/count10000000"},
        "overflow_element_count": {"type": "integer", "minimum": 0, "maximum": 20000},
        "clipped_fixed_count": {"type": "integer", "minimum": 0, "maximum": 20000},
        "truncated": {"type": "boolean"}
      }
    },
    "dom": {
      "type": "object",
      "additionalProperties": false,
      "required": ["node_count", "max_depth", "duplicate_id_count", "empty_id_count", "heading_level_skips", "heading_counts", "main_count", "nav_count", "title_present", "lang_present", "truncated"],
      "properties": {
        "node_count": {"$ref": "#/$defs/count100000"},
        "max_depth": {"type": "integer", "minimum": 0, "maximum": 1000},
        "duplicate_id_count": {"$ref": "#/$defs/count100000"},
        "empty_id_count": {"$ref": "#/$defs/count100000"},
        "heading_level_skips": {"$ref": "#/$defs/count100000"},
        "heading_counts": {"type": "array", "minItems": 6, "maxItems": 6, "items": {"$ref": "#/$defs/count100000"}},
        "main_count": {"$ref": "#/$defs/count100000"},
        "nav_count": {"$ref": "#/$defs/count100000"},
        "title_present": {"type": "boolean"},
        "lang_present": {"type": "boolean"},
        "truncated": {"type": "boolean"}
      }
    },
    "javascript": {
      "type": "object",
      "additionalProperties": false,
      "required": ["console_error_count", "console_warning_count", "page_error_count"],
      "properties": {
        "console_error_count": {"$ref": "#/$defs/count10000000"},
        "console_warning_count": {"$ref": "#/$defs/count10000000"},
        "page_error_count": {"$ref": "#/$defs/count10000000"}
      }
    },
    "network": {
      "type": "object",
      "additionalProperties": false,
      "required": ["request_count", "failed_request_count", "blocked_mutating_request_count", "blocked_main_frame_navigation_count", "blocked_nested_navigation_count", "blocked_popup_count", "blocked_websocket_count", "blocked_webrtc_count", "blocked_webtransport_count", "blocked_worker_count", "transfer_bytes", "external_origin_refs", "truncated"],
      "properties": {
        "request_count": {"$ref": "#/$defs/count10000000"},
        "failed_request_count": {"$ref": "#/$defs/count10000000"},
        "blocked_mutating_request_count": {"$ref": "#/$defs/count10000000"},
        "blocked_main_frame_navigation_count": {"$ref": "#/$defs/count10000000"},
        "blocked_nested_navigation_count": {"$ref": "#/$defs/count10000000"},
        "blocked_popup_count": {"$ref": "#/$defs/count10000000"},
        "blocked_websocket_count": {"$ref": "#/$defs/count10000000"},
        "blocked_webrtc_count": {"$ref": "#/$defs/count10000000"},
        "blocked_webtransport_count": {"$ref": "#/$defs/count10000000"},
        "blocked_worker_count": {"$ref": "#/$defs/count10000000"},
        "transfer_bytes": {"type": "integer", "minimum": 0, "maximum": 67108864},
        "external_origin_refs": {"type": "array", "maxItems": 64, "uniqueItems": true, "items": {"type": "string", "pattern": "^origin:[a-f0-9]{24}$"}},
        "truncated": {"type": "boolean"}
      }
    },
    "accessibility": {
      "type": "object",
      "additionalProperties": false,
      "required": ["violation_rules", "truncated"],
      "properties": {
        "violation_rules": {
          "type": "array",
          "maxItems": 100,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["rule_id", "impact", "node_count"],
            "properties": {
              "rule_id": {"type": "string", "pattern": "^[a-z0-9-]{1,100}$"},
              "impact": {"enum": ["minor", "moderate", "serious", "critical", "unknown"]},
              "node_count": {"$ref": "#/$defs/count500000"}
            }
          }
        },
        "truncated": {"type": "boolean"}
      }
    },
    "focus": {
      "type": "object",
      "additionalProperties": false,
      "required": ["steps_observed", "body_focus_count", "visible_indicator_count", "truncated"],
      "properties": {
        "steps_observed": {"type": "integer", "minimum": 0, "maximum": 80},
        "body_focus_count": {"type": "integer", "minimum": 0, "maximum": 80},
        "visible_indicator_count": {"type": "integer", "minimum": 0, "maximum": 80},
        "truncated": {"type": "boolean"}
      }
    },
    "motion": {
      "type": "object",
      "additionalProperties": false,
      "required": ["normal_animated_count", "reduced_animated_count"],
      "properties": {
        "normal_animated_count": {"type": "integer", "minimum": 0, "maximum": 20000},
        "reduced_animated_count": {"type": "integer", "minimum": 0, "maximum": 20000}
      }
    },
    "storage": {
      "type": "object",
      "additionalProperties": false,
      "required": ["cookie_count", "cookie_coverage", "local_storage_count", "session_storage_count", "values_read"],
      "properties": {
        "cookie_count": {"type": "null"},
        "cookie_coverage": {"const": "not_tested"},
        "local_storage_count": {"$ref": "#/$defs/count10000000"},
        "session_storage_count": {"$ref": "#/$defs/count10000000"},
        "values_read": {"const": false}
      }
    },
    "runtime": {
      "type": "object",
      "additionalProperties": false,
      "required": ["layout_shift_micros", "layout_shift_entry_count"],
      "properties": {
        "layout_shift_micros": {"$ref": "#/$defs/count10000000"},
        "layout_shift_entry_count": {"$ref": "#/$defs/count10000000"}
      }
    }
  }
}
