{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://law.arxo.io/schema/case-proposals.schema.json",
  "title": "Arxo case proposals 0.1",
  "description": "History of fact proposals for a case package, kept by the operator; outside the input and the proof of case preparation. contentHash is self-pinned with no field of its own.",
  "$comment": "DECISION-0399; SPEC §168.4; SPEC §208",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "package", "case", "proposals", "contentHash"],
  "properties": {
    "schemaVersion": {"const": "law.case-proposals/0.1"},
    "package": {"type": "string", "minLength": 1},
    "case": {"type": "string", "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"},
    "proposals": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "fact", "author", "at", "contentHash", "events"],
        "properties": {
          "id": {"type": "string", "pattern": "^p-[0-9]{4,}$"},
          "fact": {"$ref": "evaluation-request.schema.json#/$defs/FactInput"},
          "author": {"type": "string", "minLength": 1},
          "at": {"type": "string", "format": "date-time", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$"},
          "source": {"type": "string", "minLength": 1},
          "contentHash": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"},
          "events": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": ["kind", "by", "at", "proposalHash"],
              "properties": {
                "kind": {"enum": ["accepted", "revoked", "replaced"]},
                "by": {"type": "string", "minLength": 1},
                "at": {"type": "string", "format": "date-time", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$"},
                "reason": {"type": "string", "minLength": 1},
                "replaces": {"type": "string", "pattern": "^p-[0-9]{4,}$"},
                "proposalHash": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
              }
            }
          }
        }
      }
    },
    "contentHash": {"type": "string", "pattern": "^sha256:[0-9a-f]{64}$"}
  }
}
