{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://preparedboard.com/decision-record.schema.json",
  "title": "prepared-board.decision-record.v1",
  "description": "Canonical sealed decision record. Docs: https://preparedboard.com/docs/decision-record-format",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "decisionId",
    "boardId",
    "version",
    "title",
    "motionText",
    "outcome",
    "closedAt",
    "votes",
    "voteMethod",
    "meetingId",
    "evidence"
  ],
  "properties": {
    "schema": {
      "const": "prepared-board.decision-record.v1"
    },
    "decisionId": {
      "type": "string"
    },
    "boardId": {
      "type": "string"
    },
    "version": {
      "type": "integer",
      "minimum": 1
    },
    "title": {
      "type": "string"
    },
    "motionText": {
      "type": [
        "string",
        "null"
      ]
    },
    "outcome": {
      "enum": [
        "ADOPTED",
        "RATIFIED",
        "DEFEATED",
        "WITHDRAWN",
        "CLOSED",
        "SUPERSEDED"
      ]
    },
    "closedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "votes": {
      "oneOf": [
        {
          "type": "null"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "for",
            "against",
            "abstain",
            "recused"
          ],
          "properties": {
            "for": {
              "type": "integer",
              "minimum": 0
            },
            "against": {
              "type": "integer",
              "minimum": 0
            },
            "abstain": {
              "type": "integer",
              "minimum": 0
            },
            "recused": {
              "type": "integer",
              "minimum": 0
            }
          }
        }
      ]
    },
    "voteMethod": {
      "type": [
        "string",
        "null"
      ]
    },
    "meetingId": {
      "type": [
        "string",
        "null"
      ]
    },
    "evidence": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "documentId",
          "sha256"
        ],
        "properties": {
          "documentId": {
            "type": "string"
          },
          "sha256": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          }
        }
      }
    }
  }
}
