{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.aiamigos.org/schemas/workflow-evidence-record.schema.json",
  "title": "AI Amigos Workflow Evidence Record",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "methodVersion", "job", "ownerRole", "dataSensitivity", "baseline", "evaluationCases", "experiments", "humanDecision", "privacyStatus"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "methodVersion": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+$" },
    "job": { "type": "string", "minLength": 10, "maxLength": 500 },
    "ownerRole": { "type": "string", "minLength": 2, "maxLength": 120 },
    "dataSensitivity": { "enum": ["public", "internal", "confidential", "restricted"] },
    "baseline": { "$ref": "#/$defs/measurement" },
    "evaluationCases": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["caseKey", "criteria"], "properties": { "caseKey": { "type": "string" }, "criteria": { "type": "array", "minItems": 1, "items": { "type": "string" } } } } },
    "experiments": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["version", "system", "results", "failures", "humanOverrides"], "properties": { "version": { "type": "string" }, "system": { "type": "string" }, "results": { "type": "array" }, "failures": { "type": "array" }, "humanOverrides": { "type": "array" } } } },
    "humanDecision": { "type": "object", "required": ["ownerRole", "decision", "reason"], "properties": { "ownerRole": { "type": "string" }, "decision": { "enum": ["stop", "revise", "pilot", "deploy", "rollback"] }, "reason": { "type": "string" } } },
    "followUpOutcome": { "$ref": "#/$defs/measurement" },
    "privacyStatus": { "enum": ["not-run", "passed", "failed"] },
    "limitations": { "type": "array", "items": { "type": "string" } }
  },
  "$defs": {
    "measurement": {
      "type": "object",
      "additionalProperties": false,
      "required": ["metric", "value", "unit", "windowStart", "windowEnd", "sampleSize"],
      "properties": {
        "metric": { "type": "string" },
        "value": { "type": "number" },
        "unit": { "type": "string" },
        "windowStart": { "type": "string", "format": "date" },
        "windowEnd": { "type": "string", "format": "date" },
        "sampleSize": { "type": "integer", "minimum": 1 }
      }
    }
  }
}
