{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Tax Agent Knowledge Graph Schema",
  "description": "Schema for nodes and relationships in the AI Tax Agent knowledge graph",
  "type": "object",
  "properties": {
    "nodes": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Unique identifier for the node" },
          "type": {
            "type": "string",
            "description": "Type of the node (e.g., TaxpayerProfile, IncomeItem)",
            "enum": [
              "TaxpayerProfile",
              "TaxYear",
              "Jurisdiction",
              "TaxForm",
              "Schedule",
              "FormBox",
              "Document",
              "Evidence",
              "Party",
              "Account",
              "IncomeItem",
              "ExpenseItem",
              "PropertyAsset",
              "BusinessActivity",
              "Allowance",
              "Relief",
              "PensionContribution",
              "StudentLoanPlan",
              "Payment",
              "ExchangeRate",
              "Calculation",
              "Rule",
              "NormalizationEvent",
              "Reconciliation",
              "Consent",
              "LegalBasis",
              "ImportJob",
              "ETLRun"
            ]
          },
          "properties": {
            "type": "object",
            "description": "Key-value properties of the node",
            "additionalProperties": true
          }
        },
        "required": ["id", "type", "properties"],
        "additionalProperties": false
      }
    },
    "relationships": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Unique identifier for the relationship" },
          "type": {
            "type": "string",
            "description": "Type of the relationship (e.g., BELONGS_TO, HAS_BOX)",
            "enum": [
              "BELONGS_TO",
              "OF_TAX_YEAR",
              "IN_JURISDICTION",
              "HAS_SECTION",
              "HAS_BOX",
              "REPORTED_IN",
              "COMPUTES",
              "DERIVED_FROM",
              "SUPPORTED_BY",
              "PAID_BY",
              "PAID_TO",
              "OWNS",
              "RENTED_BY",
              "EMPLOYED_BY",
              "APPLIES_TO",
              "APPLIES",
              "VIOLATES",
              "NORMALIZED_FROM",
              "HAS_VALID_BASIS",
              "PRODUCED_BY",
              "CITES",
              "DESCRIBES"
            ]
          },
          "sourceId": { "type": "string", "description": "ID of the source node" },
          "targetId": { "type": "string", "description": "ID of the target node" },
          "properties": {
            "type": "object",
            "description": "Key-value properties of the relationship",
            "additionalProperties": true
          }
        },
        "required": ["id", "type", "sourceId", "targetId"],
        "additionalProperties": false
      }
    }
  },
  "required": ["nodes", "relationships"]
}