{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "const": "skillflux-health/v1"
    },
    "skillId": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "commitSha": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$"
    },
    "checkerVersion": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$"
    },
    "changedAt": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
    },
    "resultHash": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "checks": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z]+(?:\\.[a-zA-Z]+)+$"
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "warn",
              "fail",
              "info"
            ]
          },
          "value": {
            "type": [
              "string",
              "number",
              "boolean",
              "null"
            ]
          },
          "detail": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "value",
          "detail"
        ],
        "additionalProperties": false
      }
    },
    "metrics": {
      "type": "object",
      "properties": {
        "descriptionChars": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "bodyTokensApprox": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "bodyLines": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "fileCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "totalBytes": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "scriptCount": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "lastCommitAt": {
          "anyOf": [
            {
              "type": "string",
              "format": "date-time",
              "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
            },
            {
              "type": "null"
            }
          ]
        },
        "commitsSincePin": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "descriptionChars",
        "bodyTokensApprox",
        "bodyLines",
        "fileCount",
        "totalBytes",
        "scriptCount",
        "lastCommitAt",
        "commitsSincePin"
      ],
      "additionalProperties": false
    },
    "repo": {
      "type": "object",
      "properties": {
        "stars": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 0,
              "maximum": 9007199254740991
            },
            {
              "type": "null"
            }
          ]
        },
        "archived": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "checkedAt": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "required": [
        "stars",
        "archived",
        "checkedAt"
      ],
      "additionalProperties": false
    },
    "flags": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "executes-code",
          "network-calls",
          "destructive-commands",
          "risky-instructions",
          "possible-secret",
          "no-license",
          "stale",
          "archived-repo",
          "upstream-changed"
        ]
      }
    }
  },
  "required": [
    "schema",
    "skillId",
    "commitSha",
    "checkerVersion",
    "changedAt",
    "resultHash",
    "checks",
    "metrics",
    "repo",
    "flags"
  ],
  "additionalProperties": false
}
