{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://palimpsest.info/protocol/dragon-whispers-v1.schema.json",
  "title": "Palimpsest Dragon Whispers v1",
  "description": "Human-reviewed, privacy-minimized individual Telegram pattern context that never counts as evidence or corroboration.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "generated_at",
    "status",
    "relation",
    "input_provenance",
    "method",
    "scope",
    "publication_policy",
    "n_entries",
    "entries"
  ],
  "properties": {
    "schema_version": {"const": "palimpsest-dragon-whispers.v1"},
    "generated_at": {"$ref": "#/$defs/timestamp"},
    "status": {"enum": ["AWAITING_REVIEW", "REVIEWED_SIGNALS"]},
    "relation": {"const": "unverified-context-only-not-evidence"},
    "input_provenance": {"$ref": "#/$defs/text500"},
    "method": {"$ref": "#/$defs/text500"},
    "scope": {"$ref": "#/$defs/text500"},
    "publication_policy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "human_review_required",
        "raw_messages_included",
        "source_identifiers_included",
        "exact_iocs_included",
        "named_allegations_included",
        "counts_as_corroboration"
      ],
      "properties": {
        "human_review_required": {"const": true},
        "raw_messages_included": {"const": false},
        "source_identifiers_included": {"const": false},
        "exact_iocs_included": {"const": false},
        "named_allegations_included": {"const": false},
        "counts_as_corroboration": {"const": false}
      }
    },
    "n_entries": {"type": "integer", "minimum": 0, "maximum": 10000},
    "entries": {
      "type": "array",
      "maxItems": 10000,
      "items": {"$ref": "#/$defs/entry"}
    }
  },
  "allOf": [
    {
      "if": {"properties": {"status": {"const": "AWAITING_REVIEW"}}},
      "then": {
        "properties": {
          "n_entries": {"const": 0},
          "entries": {"maxItems": 0}
        }
      }
    },
    {
      "if": {"properties": {"status": {"const": "REVIEWED_SIGNALS"}}},
      "then": {
        "properties": {
          "n_entries": {"minimum": 1},
          "entries": {"minItems": 1}
        }
      }
    }
  ],
  "$defs": {
    "timestamp": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
    },
    "text180": {"type": "string", "minLength": 1, "maxLength": 180},
    "text500": {"type": "string", "minLength": 1, "maxLength": 500},
    "text1200": {"type": "string", "minLength": 1, "maxLength": 1200},
    "text1800": {"type": "string", "minLength": 1, "maxLength": 1800},
    "label": {
      "type": "string",
      "pattern": "^[A-Z][A-Z0-9_-]{0,63}$"
    },
    "count": {"type": "integer", "minimum": 0, "maximum": 1000000},
    "entry": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "whisper_id",
        "observed_at",
        "published_at",
        "review",
        "signal",
        "analysis",
        "limitations"
      ],
      "properties": {
        "whisper_id": {
          "type": "string",
          "pattern": "^whisper-[0-9a-f]{24}$"
        },
        "observed_at": {"$ref": "#/$defs/timestamp"},
        "published_at": {"$ref": "#/$defs/timestamp"},
        "review": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "status",
            "reviewed_at",
            "reviewer_role",
            "source_capsule_sha256",
            "note"
          ],
          "properties": {
            "status": {"const": "HUMAN_REVIEWED"},
            "reviewed_at": {"$ref": "#/$defs/timestamp"},
            "reviewer_role": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9-]{2,63}$"
            },
            "source_capsule_sha256": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "note": {"$ref": "#/$defs/text500"}
          }
        },
        "signal": {
          "type": "object",
          "additionalProperties": false,
          "required": ["tier", "families", "ioc_counts", "script_hints"],
          "properties": {
            "tier": {
              "enum": ["CLEAN", "WATCH", "LIKELY_SCAM", "CONFIRMED_PATTERN"]
            },
            "families": {
              "type": "array",
              "maxItems": 32,
              "uniqueItems": true,
              "items": {"$ref": "#/$defs/label"}
            },
            "ioc_counts": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "handles": {"$ref": "#/$defs/count"},
                "phones": {"$ref": "#/$defs/count"},
                "channels": {"$ref": "#/$defs/count"},
                "wallets": {"$ref": "#/$defs/count"},
                "emails": {"$ref": "#/$defs/count"},
                "urls": {"$ref": "#/$defs/count"}
              }
            },
            "script_hints": {
              "type": "array",
              "maxItems": 8,
              "uniqueItems": true,
              "items": {
                "enum": [
                  "latin",
                  "devanagari",
                  "han",
                  "arabic",
                  "cyrillic",
                  "undetermined"
                ]
              }
            }
          }
        },
        "analysis": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "headline",
            "summary",
            "why_it_matters",
            "uncertainty",
            "next_checks"
          ],
          "properties": {
            "headline": {"$ref": "#/$defs/text180"},
            "summary": {"$ref": "#/$defs/text1200"},
            "why_it_matters": {"$ref": "#/$defs/text1800"},
            "uncertainty": {"$ref": "#/$defs/text1200"},
            "next_checks": {
              "type": "array",
              "minItems": 2,
              "maxItems": 8,
              "items": {"$ref": "#/$defs/text500"}
            }
          }
        },
        "limitations": {
          "type": "array",
          "minItems": 3,
          "maxItems": 8,
          "items": {"$ref": "#/$defs/text500"}
        }
      }
    }
  }
}
