{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://leviathan.talmbout.ai/distribution-ledger.schema.json",
  "title": "Permissioned de-identified distribution evidence",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "study_id",
    "events",
    "coverage",
    "placements"
  ],
  "properties": {
    "schema": {
      "const": "leviathan.distribution.v1"
    },
    "study_id": {
      "const": "distribution-2026-10-v1"
    },
    "events": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "unit",
          "channel",
          "cohort",
          "stage",
          "at",
          "basis",
          "evidence",
          "consented"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,80}$"
          },
          "unit": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,80}$"
          },
          "channel": {
            "enum": [
              "directory",
              "skill",
              "publication",
              "community",
              "service",
              "unknown"
            ]
          },
          "cohort": {
            "enum": [
              "project",
              "hosted",
              "external",
              "unknown"
            ]
          },
          "stage": {
            "enum": [
              "arrival",
              "useful_action",
              "interaction",
              "return",
              "purchase",
              "refund",
              "cost"
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "Z$"
          },
          "basis": {
            "enum": [
              "reported",
              "reviewed"
            ]
          },
          "evidence": {
            "type": "string",
            "maxLength": 300,
            "pattern": "^(https://[^\\s?#@]+|local:[a-zA-Z0-9_./-]+)$"
          },
          "consented": {
            "const": true
          },
          "amount_usd": {
            "type": "number",
            "minimum": 0,
            "maximum": 1000000
          },
          "order": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9_-]{1,80}$"
          }
        }
      }
    },
    "coverage": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "channel",
          "metric",
          "value",
          "start",
          "end"
        ],
        "properties": {
          "channel": {
            "enum": [
              "directory",
              "skill",
              "publication",
              "community",
              "service",
              "unknown"
            ]
          },
          "metric": {
            "enum": [
              "impressions",
              "requests",
              "views"
            ]
          },
          "value": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "start": {
            "type": "string",
            "format": "date-time",
            "pattern": "Z$"
          },
          "end": {
            "type": "string",
            "format": "date-time",
            "pattern": "Z$"
          },
          "evidence": {
            "type": "string",
            "maxLength": 300,
            "pattern": "^(https://[^\\s?#@]+|local:[a-zA-Z0-9_./-]+)$"
          }
        }
      }
    },
    "placements": {
      "type": "array",
      "maxItems": 500,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "channel",
          "status",
          "at",
          "evidence"
        ],
        "properties": {
          "channel": {
            "enum": [
              "directory",
              "skill",
              "publication",
              "community",
              "service",
              "unknown"
            ]
          },
          "status": {
            "enum": [
              "prepared",
              "submitted",
              "confirmed",
              "unavailable"
            ]
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "pattern": "Z$"
          },
          "evidence": {
            "type": "string",
            "maxLength": 300,
            "pattern": "^(https://[^\\s?#@]+|local:[a-zA-Z0-9_./-]+)$"
          }
        }
      }
    }
  }
}
