{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://pgwitness.com/evidence.schema.json",
  "title": "pg-witness evidence, v1",
  "description": "One JSON object per `pg-witness verify` run. Field names are part of the v1 contract.",
  "type": "object",
  "required": ["dump_sha256", "format", "started_at", "finished_at", "duration_ms", "restore_exit_code", "object_counts", "status", "reasons"],
  "additionalProperties": false,
  "properties": {
    "dump_sha256": {
      "description": "SHA-256 of the dump file as read from disk. Empty string when the file was not hashed (missing path, or a non-custom format rejected before hashing).",
      "type": "string",
      "pattern": "^([0-9a-f]{64})?$"
    },
    "format": {
      "description": "Detected archive layout. Only custom is verified; the others are rejected with status error.",
      "type": "string",
      "enum": ["custom", "plain", "directory", ""]
    },
    "started_at": { "type": "string", "format": "date-time" },
    "finished_at": { "type": "string", "format": "date-time" },
    "duration_ms": { "type": "integer", "minimum": 0 },
    "restore_exit_code": {
      "description": "Exit code of `pg_restore --exit-on-error` into the throwaway database. null when the run stopped before that restore started (for example the archive failed `pg_restore --list`, or the local server was unreachable).",
      "type": ["integer", "null"]
    },
    "object_counts": {
      "description": "Counts of archive TOC entries from `pg_restore --list`, keyed by entry type (tables, indexes, table_data, constraints, fk_constraints, sequences, views, ...). These are TOC entries, not row counts and not a catalog query of the restored database. Empty object when the TOC could not be read.",
      "type": "object",
      "additionalProperties": { "type": "integer", "minimum": 0 }
    },
    "status": {
      "description": "ok = exit 0, dump_bad = exit 1, environment = exit 2, error = exit 3.",
      "type": "string",
      "enum": ["ok", "dump_bad", "environment", "error"]
    },
    "reasons": {
      "description": "Short reason strings. A line prefixed `detail: ` is the first pg_restore/psql error line, cut at 400 characters. Empty array on ok.",
      "type": "array",
      "items": { "type": "string" }
    }
  }
}
