{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://complyedge.io/rulebook/0.1.0/producer-profile.schema.json",
  "title": "ADCR producer profile 0.1.0",
  "description": "The profile a producer publishes at a stable URL (PRF-01). The reference verifier checks these fields and checks an export against them with --profile; what the profile states about the producer's processes stays the producer's attestation. Licensed Apache-2.0.",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "rulebook",
    "producer_id",
    "classes",
    "clock_source",
    "anchoring",
    "retention_classes",
    "copies",
    "event_types",
    "reason_codes",
    "rule_set_index_url",
    "interpretation_guide_url",
    "commitment_domain",
    "pseudonym_domain",
    "verification_interface_url"
  ],
  "properties": {
    "rulebook": {
      "const": "https://complyedge.io/rulebook/0.1.0"
    },
    "producer_id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "$comment": "the producer_id every export envelope carries"
    },
    "classes": {
      "type": "array",
      "items": {
        "enum": [
          "Record",
          "Law",
          "Chain",
          "Anchor",
          "Oversight",
          "Rights",
          "Export"
        ]
      },
      "uniqueItems": true,
      "$comment": "the classes claimed (PRF-03)"
    },
    "clock_source": {
      "type": "object",
      "required": [
        "reference",
        "tolerance_ms"
      ],
      "properties": {
        "reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "tolerance_ms": {
          "type": "integer",
          "minimum": 0
        }
      },
      "$comment": "equal to every export envelope's clock_source"
    },
    "anchoring": {
      "type": "object",
      "required": [
        "cadence",
        "providers"
      ],
      "properties": {
        "cadence": {
          "type": "string",
          "minLength": 1,
          "maxLength": 255
        },
        "providers": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^https://\\S+$",
            "maxLength": 255
          }
        }
      }
    },
    "retention_classes": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "class",
          "period_days",
          "high_risk"
        ],
        "properties": {
          "class": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "period_days": {
            "type": "integer",
            "minimum": 1
          },
          "high_risk": {
            "type": "boolean"
          }
        },
        "if": {
          "properties": {
            "high_risk": {
              "const": true
            }
          }
        },
        "then": {
          "properties": {
            "period_days": {
              "minimum": 184
            }
          }
        },
        "$comment": "REC-19, REC-20: six months for high-risk records, 184 days so it holds from any start date"
      }
    },
    "copies": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "what",
          "gone_after_days"
        ],
        "properties": {
          "what": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
          },
          "gone_after_days": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "$comment": "CMT-05: every copy of records and keys and when a key destruction is complete in it"
    },
    "event_types": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 255
      },
      "uniqueItems": true
    },
    "reason_codes": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:/-]*$"
      },
      "uniqueItems": true
    },
    "rule_set_index_url": {
      "type": "string",
      "pattern": "^https://\\S+$",
      "maxLength": 255
    },
    "interpretation_guide_url": {
      "type": "string",
      "pattern": "^https://\\S+$",
      "maxLength": 255
    },
    "commitment_domain": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255,
      "$comment": "CMT-02: the domain tag on commitment inputs; neither tag may be a prefix of the other"
    },
    "pseudonym_domain": {
      "type": "string",
      "minLength": 1,
      "maxLength": 255
    },
    "verification_interface_url": {
      "type": "string",
      "pattern": "^https://\\S+$",
      "maxLength": 255,
      "$comment": "CMT-06"
    }
  }
}
