{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://simdugas.github.io/retake/schema/check-v1.schema.json",
  "title": "retake check --json, version 1",
  "description": "The output of `retake check --json` (ADR 0010 item 6). Fields may be added without changing the version; a breaking change raises it (ADR 0011 item 8).",
  "type": "object",
  "required": ["version", "takes_dir", "takes", "partials", "errors", "warnings", "stale", "fail_on_stale", "ok", "findings"],
  "properties": {
    "version": { "description": "The output version.", "const": 1 },
    "takes_dir": { "description": "The takes directory checked, as given.", "type": "string" },
    "takes": { "description": "How many takes (*.take, *.take.zst) were checked.", "type": "integer", "minimum": 0 },
    "partials": { "description": "How many leftover .partial files were found.", "type": "integer", "minimum": 0 },
    "errors": { "description": "Findings with severity error.", "type": "integer", "minimum": 0 },
    "warnings": { "description": "Findings with severity warning.", "type": "integer", "minimum": 0 },
    "stale": { "description": "Takes stale by Retake version (findings of kind stale).", "type": "integer", "minimum": 0 },
    "fail_on_stale": { "description": "Whether --fail-on-stale (RETAKE_FAIL_ON_STALE) was in force.", "type": "boolean" },
    "ok": { "description": "Whether the check passed: no errors, and no stale take when fail_on_stale is true. The exit code is 0 when true, 1 when false.", "type": "boolean" },
    "findings": {
      "description": "Every problem found, takes in path order, then .partial files.",
      "type": "array",
      "items": { "$ref": "#/$defs/finding" }
    }
  },
  "$defs": {
    "finding": {
      "type": "object",
      "required": ["path", "severity", "kind", "message"],
      "properties": {
        "path": { "description": "The take or .partial file, under takes_dir, with / separators.", "type": "string" },
        "line": { "description": "The 1-based line, for problems with one line.", "type": "integer", "minimum": 1 },
        "severity": { "description": "error findings make the check fail; warning findings do not, except stale ones with --fail-on-stale.", "enum": ["error", "warning"] },
        "kind": {
          "description": "What was checked. Errors: unreadable (cannot read, or compressed), json (a line is not JSON), format (a format or record type this Retake does not read), schema (a line violates the take schema), structure (a rule across lines, see schema/README.md), incomplete (no footer), blob (a missing or changed blob), guard (the current matching rules make two recordings indistinguishable), secret (the current redaction patterns match). Warnings: run (recorded from a run that exited non-zero or did not finish), failed_test (outcome failed), unfinished_stream, stale (recorded by an older Retake), partial (leftover .partial file), format (the previous take format).",
          "enum": ["unreadable", "json", "format", "schema", "structure", "incomplete", "blob", "guard", "secret", "run", "failed_test", "unfinished_stream", "stale", "partial"]
        },
        "message": { "description": "Human-readable description.", "type": "string" }
      }
    }
  }
}
