{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ethotechnics.org/standards/decision-record.schema.json",
  "title": "Decision Record",
  "description": "A log entry that captures an automated decision, its owner, clocks, and evidence links.",
  "type": "object",
  "required": [
    "schema_version",
    "record_id",
    "receipt_id",
    "issued_at",
    "owner",
    "subject",
    "action",
    "decision",
    "clocks",
    "evidence_refs"
  ],
  "properties": {
    "schema_version": { "type": "string", "pattern": "^1\\.\\d+\\.\\d+$" },
    "record_id": { "type": "string" },
    "receipt_id": { "type": "string" },
    "issued_at": { "type": "string", "format": "date-time" },
    "owner": {
      "type": "object",
      "required": ["name", "role", "contact"],
      "properties": {
        "name": { "type": "string" },
        "role": { "type": "string" },
        "contact": { "type": "string" },
        "on_call": { "type": "boolean" }
      }
    },
    "subject": {
      "type": "object",
      "required": ["id", "type"],
      "properties": {
        "id": { "type": "string" },
        "type": { "type": "string" },
        "region": { "type": "string" }
      }
    },
    "action": {
      "type": "object",
      "required": ["class", "description", "reversible"],
      "properties": {
        "class": { "type": "string" },
        "description": { "type": "string" },
        "reversible": { "type": "boolean" },
        "tools": { "type": "array", "items": { "type": "string" } }
      }
    },
    "decision": {
      "type": "object",
      "required": ["decision_type", "reason_codes", "inputs"],
      "properties": {
        "decision_type": { "type": "string" },
        "reason_codes": { "type": "array", "items": { "type": "string" } },
        "inputs": { "type": "array", "items": { "type": "string" } },
        "confidence": { "type": "number" }
      }
    },
    "clocks": {
      "type": "object",
      "required": ["ack", "review", "remedy"],
      "properties": {
        "ack": {
          "type": "object",
          "properties": { "hours": { "type": "number" } }
        },
        "review": {
          "type": "object",
          "properties": { "hours": { "type": "number" } }
        },
        "remedy": {
          "type": "object",
          "properties": { "hours": { "type": "number" } }
        },
        "appeal": {
          "type": "object",
          "properties": { "hours": { "type": "number" } }
        }
      }
    },
    "status": {
      "type": "string",
      "enum": ["issued", "paused", "reversed", "upheld", "remedied"]
    },
    "evidence_refs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["type", "href"],
        "properties": {
          "type": { "type": "string" },
          "href": { "type": "string" },
          "description": { "type": "string" }
        }
      }
    },
    "appeal": {
      "type": "object",
      "properties": {
        "href": { "type": "string" },
        "status": { "type": "string" }
      }
    }
  }
}
