{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://abdess.github.io/retrobios/api/v1/schemas/campaign-run.schema.json",
  "title": "RetroBIOS campaign run",
  "description": "One line of measurements/campaign-runs.jsonl: one pass of scripts/campaign.py, what it left done, failed and pending, and the records and findings it added. Lines are appended, never rewritten.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "id", "started_at", "ended_at", "result", "detail", "counts",
               "pending_reasons", "failed", "records", "findings"],
  "properties": {
    "schema_version": { "const": 1 },
    "id": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}-[0-9a-f]{12}$" },
    "started_at": { "type": "string", "format": "date-time" },
    "ended_at": { "type": "string", "format": "date-time" },
    "result": {
      "enum": ["complete", "budget", "paused", "stopped", "refused"],
      "description": "complete: nothing runnable was left. budget: the time budget ended the pass. paused: a busy host or a full disk ended it, the next pass resumes. stopped: interrupted. refused: no sandbox for third-party code, nothing ran."
    },
    "detail": { "type": "string" },
    "counts": {
      "type": "object",
      "additionalProperties": false,
      "required": ["done", "failed", "pending"],
      "properties": {
        "done": { "type": "integer", "minimum": 0 },
        "failed": { "type": "integer", "minimum": 0 },
        "pending": { "type": "integer", "minimum": 0 }
      }
    },
    "pending_reasons": {
      "type": "object",
      "additionalProperties": { "type": "integer", "minimum": 1 },
      "description": "Pending checks counted by reason."
    },
    "failed": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["emulator", "check", "reason"],
        "properties": {
          "emulator": { "type": "string" },
          "check": { "type": "string" },
          "reason": { "type": "string" }
        }
      }
    },
    "records": {
      "type": "array",
      "items": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}-[0-9a-f]{12}$" }
    },
    "findings": {
      "type": "object",
      "additionalProperties": { "type": "integer", "minimum": 0 },
      "description": "Finding lines added by this pass, counted by status."
    }
  }
}
