{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://healthcareaiops.com/standards/mgr-v0.1.schema.json",
  "title": "Model Governance Record (MGR) v0.1",
  "description": "An open, vendor-neutral interchange format for AI governance evidence in healthcare. Published by the Healthcare AI Institute under CC BY 4.0. One MGR document = one model or agent's complete governed history.",
  "type": "object",
  "required": ["mgr_version", "subject", "accountability", "approval"],
  "properties": {
    "mgr_version": { "const": "0.1" },
    "subject": {
      "type": "object",
      "required": ["name", "kind", "purpose"],
      "properties": {
        "name": { "type": "string" },
        "kind": { "enum": ["predictive_model", "generative_model", "agent"] },
        "vendor": { "type": "string" },
        "purpose": { "type": "string" },
        "deployment_context": { "type": "string" }
      }
    },
    "accountability": {
      "type": "object",
      "required": ["accountable_owner"],
      "properties": {
        "accountable_owner": {
          "type": "object",
          "required": ["name", "role"],
          "properties": { "name": { "type": "string" }, "role": { "type": "string" } }
        },
        "oversight_body": { "type": "string" }
      }
    },
    "approval": {
      "type": "object",
      "required": ["approved_on", "approved_by", "baseline"],
      "properties": {
        "approved_on": { "type": "string", "format": "date" },
        "approved_by": { "type": "string" },
        "scope_of_use": { "type": "string" },
        "baseline": {
          "type": "object",
          "properties": {
            "metric": { "type": "string" },
            "value": { "type": "number" },
            "decay_threshold": { "type": "number" },
            "parity_gap_threshold": { "type": "number" }
          }
        }
      }
    },
    "agent_privileging": {
      "type": "object",
      "description": "Required when subject.kind = 'agent'.",
      "properties": {
        "scope_of_action": { "type": "array", "items": { "type": "string" } },
        "autonomy_level": { "enum": ["suggest", "supervised", "autonomous"] },
        "proctoring": {
          "type": "object",
          "properties": {
            "started_on": { "type": "string", "format": "date" },
            "ended_on": { "type": "string", "format": "date" },
            "graduated": { "type": "boolean" }
          }
        }
      }
    },
    "monitoring": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["date", "metric", "value"],
        "properties": {
          "date": { "type": "string", "format": "date" },
          "metric": { "type": "string" },
          "value": { "type": "number" },
          "subgroup": { "type": "string" },
          "within_threshold": { "type": "boolean" },
          "attested_by": { "type": "string" }
        }
      }
    },
    "incidents": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["date", "summary"],
        "properties": {
          "date": { "type": "string", "format": "date" },
          "summary": { "type": "string" },
          "resolution": { "type": "string" }
        }
      }
    },
    "status_history": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["date", "status"],
        "properties": {
          "date": { "type": "string", "format": "date" },
          "status": { "type": "string" },
          "decided_by": { "type": "string" },
          "rationale": { "type": "string" }
        }
      }
    },
    "integrity": {
      "type": "object",
      "description": "Optional tamper-evidence: a hash chain over the record's entries.",
      "properties": {
        "algorithm": { "const": "sha256-chain" },
        "head_hash": { "type": "string" }
      }
    }
  }
}
