{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://example.com/schemas/performance-budgets.schema.json",
  "title": "Performance Budgets",
  "type": "object",
  "required": ["description", "objective", "performance"],
  "properties": {
    "description": { "type": "string", "minLength": 1 },
    "objective": { "type": "string", "minLength": 1 },
    "performance": {
      "type": "object",
      "required": ["objective", "why", "coreWebVitals", "assetBudgets", "pageRules", "measurement", "passCriteria", "failCriteria", "objectiveAlignment"],
      "properties": {
        "objective": { "type": "string", "minLength": 1 },
        "why": { "type": "string", "minLength": 1 },
        "coreWebVitals": {
          "type": "array",
          "minItems": 3,
          "items": {
            "type": "object",
            "required": ["id", "name", "fieldBudget", "severity", "why", "improvementLevers"],
            "properties": {
              "id": { "enum": ["lcp", "cls", "inp"] },
              "name": { "type": "string", "minLength": 1 },
              "fieldBudget": { "type": "string", "minLength": 1 },
              "severity": { "enum": ["critical", "high", "medium"] },
              "why": { "type": "string", "minLength": 1 },
              "improvementLevers": { "type": "array", "minItems": 2, "items": { "type": "string", "minLength": 1 } }
            }
          }
        },
        "assetBudgets": {
          "type": "array",
          "minItems": 4,
          "items": {
            "type": "object",
            "required": ["id", "limit", "severity", "why"],
            "properties": {
              "id": { "type": "string", "minLength": 1 },
              "limit": { "type": "number", "minimum": 0 },
              "severity": { "enum": ["critical", "high", "medium"] },
              "why": { "type": "string", "minLength": 1 }
            }
          }
        },
        "pageRules": {
          "type": "array",
          "minItems": 3,
          "items": {
            "type": "object",
            "required": ["id", "severity", "rule", "why"],
            "properties": {
              "id": { "type": "string", "minLength": 1 },
              "severity": { "enum": ["critical", "high", "medium"] },
              "rule": { "type": "string", "minLength": 1 },
              "why": { "type": "string", "minLength": 1 }
            }
          }
        },
        "measurement": {
          "type": "object",
          "required": ["command", "reportPath", "method", "localCaveat"],
          "properties": {
            "command": { "type": "string", "minLength": 1 },
            "reportPath": { "type": "string", "minLength": 1 },
            "method": { "type": "string", "minLength": 20 },
            "localCaveat": { "type": "string", "minLength": 20 }
          }
        },
        "passCriteria": { "type": "array", "minItems": 3, "items": { "type": "string", "minLength": 1 } },
        "failCriteria": { "type": "array", "minItems": 3, "items": { "type": "string", "minLength": 1 } },
        "objectiveAlignment": { "type": "string", "minLength": 1 }
      }
    }
  }
}
