{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://simdugas.github.io/retake/schema/ls-v1.schema.json",
  "title": "retake ls --json, version 1",
  "description": "The output of `retake ls --json` (ADR 0010 item 7). Fields may be added without changing the version; a breaking change raises it (ADR 0011 item 8).",
  "type": "object",
  "required": ["version", "takes_dir", "takes"],
  "properties": {
    "version": { "description": "The output version.", "const": 1 },
    "takes_dir": { "description": "The takes directory listed, as given.", "type": "string" },
    "takes": {
      "description": "Every take (*.take, *.take.zst) under takes_dir, sorted by path.",
      "type": "array",
      "items": { "$ref": "#/$defs/take" }
    }
  },
  "$defs": {
    "take": {
      "type": "object",
      "required": ["path", "test_id", "recorded_at", "age_seconds", "retake_version", "models", "complete", "stale"],
      "properties": {
        "path": { "description": "The take's path under takes_dir, with / separators.", "type": "string" },
        "test_id": { "description": "The test ID from the header: _main or _session for shared takes. null when the take cannot be read.", "type": ["string", "null"] },
        "recorded_at": { "description": "When the recording started, UTC (YYYY-MM-DDTHH:MM:SS.mmmZ). null when the take cannot be read.", "type": ["string", "null"] },
        "age_seconds": { "description": "Seconds since recorded_at (0 if it is in the future). null when the take cannot be read.", "type": ["integer", "null"], "minimum": 0 },
        "retake_version": { "description": "The Retake version that recorded the take; null when unknown (takes recorded before Retake recorded its version) or unreadable.", "type": ["string", "null"] },
        "models": { "description": "Requested and serving models found in the exchanges, sorted and distinct.", "type": "array", "items": { "type": "string" } },
        "outcome": { "description": "Per-test takes: how the test ended. Absent for shared takes and incomplete takes.", "enum": ["passed", "failed"] },
        "run_exit": { "description": "Shared takes (_main, _session): the wrapped command's exit code, or null when the run never finished. Absent for per-test takes and incomplete takes.", "type": ["integer", "null"] },
        "complete": { "description": "Whether the take has a footer. An incomplete take is not replayed.", "type": "boolean" },
        "stale": { "description": "Why the take is stale by Retake version (ADR 0010 item 4), or null. API version staleness is only known during replay.", "type": ["string", "null"] },
        "error": { "description": "Why the take could not be read (`retake check` says more). Absent when it was read. retake ls exits 1 when any take has an error.", "type": "string" }
      }
    }
  }
}
