{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/zzh-newlearner/dsh-postmortem/schemas/verified-paired-run-v1.schema.json",
  "title": "DSH Postmortem verified paired-run record v1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "protocolId", "pairId", "taskId", "arm", "success", "taskFingerprint", "environmentFingerprint", "successCriterionFingerprint", "intervention", "toolCalls"],
  "properties": {
    "schemaVersion": { "const": "1" },
    "protocolId": { "type": "string", "minLength": 1 },
    "pairId": { "type": "string", "minLength": 1 },
    "taskId": { "type": "string", "minLength": 1 },
    "arm": { "enum": ["baseline", "postmortem"] },
    "success": { "type": "boolean" },
    "taskFingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "environmentFingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "successCriterionFingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "intervention": { "enum": ["none", "repair_plan"] },
    "repairPlanFingerprint": { "type": "string", "pattern": "^sha256:[a-f0-9]{64}$" },
    "toolCalls": { "type": "integer", "minimum": 0 },
    "elapsedMs": { "type": "number", "minimum": 0 }
  },
  "allOf": [
    { "if": { "properties": { "arm": { "const": "baseline" } } }, "then": { "properties": { "intervention": { "const": "none" } }, "not": { "required": ["repairPlanFingerprint"] } } },
    { "if": { "properties": { "arm": { "const": "postmortem" } } }, "then": { "properties": { "intervention": { "const": "repair_plan" } }, "required": ["repairPlanFingerprint"] } }
  ]
}
