{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "pigeon/droppings/entry/v1",
  "title": "One legal-process request, as published (ADR-0015 (d) 1)",
  "description": "One file per request in data/entries/. Only cleared fields. No case reference, and nothing identifying a user or a requester's staff: the closed field list is how the build enforces that.",
  "type": "object",
  "additionalProperties": false,
  "required": ["format", "public_id", "published", "date", "date_precision", "type", "jurisdiction", "asked", "could_produce", "produced", "challenged", "status", "documents", "history"],
  "properties": {
    "format": {"const": "pigeon/droppings/entry/v1"},
    "public_id": {"type": "string", "pattern": "^DRP-[0-9]{4}-[1-9][0-9]*$", "description": "Assigned at publication, never at receipt: a receipt sequence would show gaps, and a gap is a disclosure."},
    "published": {"type": "string", "format": "date"},
    "date": {"type": "string", "format": "date", "description": "Date received, shown only at date_precision."},
    "date_precision": {"enum": ["day", "month", "quarter"]},
    "type": {"enum": ["subpoena", "court_order", "search_warrant", "prospective", "preservation", "emergency", "foreign", "assistance", "takedown_dmca", "takedown_tida", "takedown_other", "civil"], "description": "ADR-0015 (b), less nsl and fisa: those are never published per item."},
    "jurisdiction": {
      "type": "object",
      "additionalProperties": false,
      "required": ["country", "level"],
      "properties": {
        "country": {"type": "string", "pattern": "^[A-Z]{2}$"},
        "level": {"type": "string", "pattern": "^[A-Za-z .'-]{2,40}$", "description": "federal, or a state or region."},
        "issuer": {"type": "string", "pattern": "^[A-Za-z0-9 .,'()-]{2,80}$", "description": "The court or agency, only if cleared."}
      }
    },
    "asked": {"type": "array", "minItems": 1, "items": {"$ref": "#/$defs/category"}},
    "asked_note": {"type": "string", "maxLength": 280},
    "could_produce": {
      "type": "object",
      "additionalProperties": false,
      "required": ["table_version"],
      "description": "Derived, never typed: the build renders each asked category from this version of the could-give table.",
      "properties": {"table_version": {"type": "integer", "minimum": 1}}
    },
    "produced": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["category", "outcome"],
        "properties": {
          "category": {"$ref": "#/$defs/category"},
          "outcome": {"enum": ["none_held", "produced", "refused", "narrowed"]}
        }
      }
    },
    "challenged": {
      "type": "object",
      "additionalProperties": false,
      "required": ["result"],
      "properties": {
        "result": {"enum": ["no", "negotiated_narrower", "motion_filed", "gag_challenged"]},
        "outcome": {"type": "string", "maxLength": 280}
      }
    },
    "user_notice": {"enum": ["notified", "not_possible", "delayed_by_order", "not_yet"]},
    "status": {"enum": ["open", "complied", "partially_complied", "refused", "withdrawn", "closed"]},
    "documents": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["file", "sha256", "redaction_log"],
        "properties": {
          "file": {"type": "string", "pattern": "^[a-z0-9-]+\\.pdf$"},
          "title": {"type": "string", "maxLength": 120},
          "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
          "redaction_log": {"type": "string", "pattern": "^RL-[0-9]{4}-[1-9][0-9]*$"}
        }
      }
    },
    "approved_by": {"$ref": "#/$defs/approvals"},
    "history": {"$ref": "#/$defs/history"}
  },
  "$defs": {
    "category": {"enum": ["content", "social_graph", "contacts", "group_membership", "subscriber", "handle", "ip_logs", "timing", "media", "abuse_reports", "invites", "lookups", "payments", "keys", "prospective_logging", "preserve", "remove", "assistance"]},
    "approvals": {
      "type": "string",
      "pattern": "^[^ ]+ [0-9]{4}-[0-9]{2}-[0-9]{2}$",
      "description": "Nothing auto-publishes. The owner's sign-off: the name he signs with, then the date (ADR-0015 amendment 3); the build checks the name. Not required here, so a draft can omit it; the build refuses to publish anything without it. The published copy reads 'owner' for the name."
    },
    "history": {
      "type": "array",
      "description": "Append-only: a correction is added here, never edited over.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["date", "change"],
        "properties": {
          "date": {"type": "string", "format": "date"},
          "change": {"type": "string", "maxLength": 280}
        }
      }
    }
  }
}
