{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://decantr.ai/schemas/decantr-ci-report.v1.json",
  "title": "Decantr CI Report",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "$schema",
        "generatedAt",
        "mode",
        "projectPath",
        "failOn",
        "status",
        "health",
        "localLaw"
      ],
      "properties": {
        "$schema": {
          "const": "https://decantr.ai/schemas/decantr-ci-report.v1.json"
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "mode": {
          "const": "project"
        },
        "projectPath": {
          "type": ["string", "null"]
        },
        "failOn": {
          "type": "string",
          "enum": ["error", "warn", "none"]
        },
        "status": {
          "type": "string",
          "enum": ["healthy", "warning", "error"]
        },
        "health": {
          "$ref": "https://decantr.ai/schemas/project-health-report.v1.json"
        },
        "localLaw": {
          "$ref": "#/$defs/localLaw"
        },
        "styleBridge": {
          "$ref": "#/$defs/styleBridge"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": ["$schema", "generatedAt", "mode", "failOn", "status", "workspace"],
      "properties": {
        "$schema": {
          "const": "https://decantr.ai/schemas/decantr-ci-report.v1.json"
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "mode": {
          "const": "workspace"
        },
        "failOn": {
          "type": "string",
          "enum": ["error", "warn", "none"]
        },
        "status": {
          "type": "string",
          "enum": ["healthy", "warning", "error"]
        },
        "workspace": {
          "$ref": "https://decantr.ai/schemas/workspace-health-report.v1.json"
        }
      },
      "additionalProperties": false
    }
  ],
  "$defs": {
    "localLaw": {
      "type": "object",
      "required": ["checked", "patternsPresent", "rulesPresent", "errorCount", "warnCount"],
      "properties": {
        "checked": {
          "type": "boolean"
        },
        "patternsPresent": {
          "type": "boolean"
        },
        "rulesPresent": {
          "type": "boolean"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "findings": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "ruleId",
              "severity",
              "file",
              "line",
              "column",
              "message",
              "suggestedFix"
            ],
            "properties": {
              "ruleId": {
                "type": "string"
              },
              "severity": {
                "type": "string",
                "enum": ["info", "warn", "error"]
              },
              "file": {
                "type": "string"
              },
              "line": {
                "type": "integer",
                "minimum": 1
              },
              "column": {
                "type": "integer",
                "minimum": 1
              },
              "message": {
                "type": "string"
              },
              "suggestedFix": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "errorCount": {
          "type": "integer",
          "minimum": 0
        },
        "warnCount": {
          "type": "integer",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "styleBridge": {
      "type": "object",
      "required": [
        "checked",
        "present",
        "status",
        "mappingCount",
        "stylingApproach",
        "themeModes",
        "warnings"
      ],
      "properties": {
        "checked": {
          "type": "boolean"
        },
        "present": {
          "type": "boolean"
        },
        "status": {
          "type": ["string", "null"]
        },
        "mappingCount": {
          "type": "integer",
          "minimum": 0
        },
        "stylingApproach": {
          "type": ["string", "null"]
        },
        "themeModes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false
    }
  }
}
