{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://omnibuster.com/schema/omnibus-provision-1.0.json",
  "title": "Omnibus Provision",
  "description": "One typed action in a U.S. omnibus or consolidated appropriations bill. Version 1.0.0.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "id",
    "bill_id",
    "text_version_id",
    "node_id",
    "citation",
    "source_span",
    "action_type",
    "confidence",
    "extraction_method",
    "audience",
    "payload"
  ],
  "properties": {
    "schema_version": { "const": "1.0.0" },
    "id": { "type": "string", "minLength": 8 },
    "bill_id": { "type": "string", "minLength": 3 },
    "text_version_id": { "type": "string", "minLength": 3 },
    "node_id": { "type": "string", "minLength": 3 },
    "parent_id": { "type": ["string", "null"] },
    "citation": { "$ref": "#/$defs/citation" },
    "source_span": { "$ref": "#/$defs/sourceSpan" },
    "action_type": {
      "enum": [
        "APPROPRIATE",
        "RESCIND",
        "TRANSFER",
        "LIMIT",
        "AMEND",
        "EXTEND",
        "DIRECT",
        "DEFINE",
        "WAIVE",
        "EMERGENCY_DESIGNATION",
        "OTHER"
      ]
    },
    "confidence": { "enum": ["high", "medium", "low"] },
    "extraction_method": { "enum": ["model", "manual"] },
    "effective_date": { "type": ["string", "null"] },
    "expiration_date": { "type": ["string", "null"] },
    "audience": { "$ref": "#/$defs/audience" },
    "notes": { "type": "string" },
    "payload": { "type": "object" }
  },
  "allOf": [
    { "if": { "properties": { "action_type": { "const": "APPROPRIATE" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/appropriate" } } } },
    { "if": { "properties": { "action_type": { "const": "RESCIND" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/rescind" } } } },
    { "if": { "properties": { "action_type": { "const": "TRANSFER" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/transfer" } } } },
    { "if": { "properties": { "action_type": { "const": "LIMIT" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/limit" } } } },
    { "if": { "properties": { "action_type": { "const": "AMEND" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/amend" } } } },
    { "if": { "properties": { "action_type": { "const": "EXTEND" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/extend" } } } },
    { "if": { "properties": { "action_type": { "const": "DIRECT" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/direct" } } } },
    { "if": { "properties": { "action_type": { "const": "DEFINE" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/define" } } } },
    { "if": { "properties": { "action_type": { "const": "WAIVE" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/waive" } } } },
    { "if": { "properties": { "action_type": { "const": "EMERGENCY_DESIGNATION" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/emergency" } } } },
    { "if": { "properties": { "action_type": { "const": "OTHER" } }, "required": ["action_type"] }, "then": { "properties": { "payload": { "$ref": "#/$defs/other" } } } }
  ],
  "$defs": {
    "citation": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "label"],
      "properties": {
        "division": { "type": ["string", "null"] },
        "title": { "type": ["string", "null"] },
        "section": { "type": ["string", "null"] },
        "subsection": { "type": ["string", "null"] },
        "path": { "type": "string" },
        "label": { "type": "string" },
        "uslm_id": { "type": "string" }
      }
    },
    "sourceSpan": {
      "type": "object",
      "additionalProperties": false,
      "required": ["start", "end", "verbatim", "sha256"],
      "properties": {
        "start": { "type": "integer", "minimum": 0 },
        "end": { "type": "integer", "minimum": 0 },
        "verbatim": { "type": "string", "minLength": 1 },
        "sha256": { "type": "string", "minLength": 64, "maxLength": 64 }
      }
    },
    "audience": {
      "type": "object",
      "additionalProperties": false,
      "required": ["categories"],
      "properties": {
        "categories": {
          "type": "array",
          "items": {
            "enum": [
              "veteran",
              "military",
              "federal_employee",
              "student",
              "dependents",
              "farmer",
              "business_owner",
              "homeowner",
              "renter",
              "tribal",
              "medicare",
              "medicaid",
              "snap",
              "wic",
              "social_security",
              "head_of_household"
            ]
          }
        },
        "states": { "type": "array", "items": { "type": "string" } },
        "age_min": { "type": ["integer", "null"] },
        "age_max": { "type": ["integer", "null"] },
        "income_min_usd": { "type": ["number", "null"] },
        "income_max_usd": { "type": ["number", "null"] }
      }
    },
    "appropriate": {
      "type": "object",
      "additionalProperties": false,
      "required": ["amount_usd", "purpose"],
      "properties": {
        "agency": { "type": "string" },
        "bureau": { "type": "string" },
        "account": { "type": "string" },
        "treasury_account": { "type": ["string", "null"] },
        "amount_usd": { "type": "number" },
        "fiscal_years": { "type": "array", "items": { "type": "string" } },
        "availability": { "enum": ["one-year", "multi-year", "until-expended", "until-date", "unspecified"] },
        "available_until": { "type": ["string", "null"] },
        "purpose": { "type": "string" },
        "provisos": { "type": "array", "items": { "type": "string" } }
      }
    },
    "rescind": {
      "type": "object",
      "additionalProperties": false,
      "required": ["amount_usd"],
      "properties": {
        "account": { "type": "string" },
        "amount_usd": { "type": "number" },
        "source_law": { "type": "string" },
        "source_year": { "type": "string" }
      }
    },
    "transfer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["from", "to"],
      "properties": {
        "from": { "type": "string" },
        "to": { "type": "string" },
        "amount_usd": { "type": ["number", "null"] },
        "percent_cap": { "type": ["number", "null"] },
        "conditions": { "type": "string" }
      }
    },
    "limit": {
      "type": "object",
      "additionalProperties": false,
      "required": ["subject", "scope"],
      "properties": {
        "subject": { "type": "string" },
        "scope": { "type": "string" },
        "exceptions": { "type": "string" }
      }
    },
    "amend": {
      "type": "object",
      "additionalProperties": false,
      "required": ["target", "operation"],
      "properties": {
        "target": { "type": "string" },
        "operation": { "enum": ["strike", "insert", "strike-and-insert", "redesignate", "add"] },
        "old_text": { "type": "string" },
        "new_text": { "type": "string" }
      }
    },
    "extend": {
      "type": "object",
      "additionalProperties": false,
      "required": ["program"],
      "properties": {
        "program": { "type": "string" },
        "old_date": { "type": ["string", "null"] },
        "new_date": { "type": ["string", "null"] }
      }
    },
    "direct": {
      "type": "object",
      "additionalProperties": false,
      "required": ["required_action"],
      "properties": {
        "agency": { "type": "string" },
        "required_action": { "type": "string" },
        "deadline": { "type": ["string", "null"] },
        "recipient": { "type": "string" }
      }
    },
    "define": {
      "type": "object",
      "additionalProperties": false,
      "required": ["term", "definition"],
      "properties": {
        "term": { "type": "string" },
        "definition": { "type": "string" }
      }
    },
    "waive": {
      "type": "object",
      "additionalProperties": false,
      "required": ["requirement"],
      "properties": {
        "requirement": { "type": "string" },
        "beneficiary": { "type": "string" }
      }
    },
    "emergency": {
      "type": "object",
      "additionalProperties": false,
      "required": ["designation"],
      "properties": {
        "designation": { "type": "string" },
        "statute": { "type": "string" }
      }
    },
    "other": {
      "type": "object",
      "additionalProperties": false,
      "required": ["reason"],
      "properties": {
        "reason": { "type": "string", "minLength": 8 }
      }
    }
  }
}
