{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "L01 authorization_packet input schema",
  "description": "Strict input shape. Blank templates are preparation scaffolds, not runnable inputs.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "matter_id",
    "packet_type",
    "subject_alias",
    "reviewer_id",
    "approved_requirements",
    "documents"
  ],
  "properties": {
    "matter_id": {
      "type": "string",
      "minLength": 1
    },
    "packet_type": {
      "const": "records_request"
    },
    "subject_alias": {
      "type": "string",
      "minLength": 1
    },
    "reviewer_id": {
      "type": "string",
      "minLength": 1
    },
    "approved_requirements": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "requirement_id",
          "label",
          "applicability",
          "evidence_rule",
          "approval_ref"
        ],
        "properties": {
          "requirement_id": {
            "type": "string",
            "minLength": 1
          },
          "label": {
            "type": "string",
            "minLength": 1
          },
          "applicability": {
            "type": "string",
            "enum": [
              "required",
              "not_required"
            ]
          },
          "evidence_rule": {
            "type": "string",
            "minLength": 1
          },
          "approval_ref": {
            "type": "string",
            "minLength": 1
          }
        }
      }
    },
    "documents": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "file_id",
          "declared_type",
          "extracts"
        ],
        "properties": {
          "file_id": {
            "type": "string",
            "minLength": 1
          },
          "declared_type": {
            "type": "string"
          },
          "extracts": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "source_id",
                "page",
                "text"
              ],
              "properties": {
                "source_id": {
                  "type": "string",
                  "minLength": 1
                },
                "page": {
                  "type": "integer",
                  "minimum": 1
                },
                "text": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
