{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Adam Knowledge Graph Schema",
  "description": "Defines the formal schema for nodes and relationships (edges) in the Adam Knowledge Graph, including extensions for Causal Inference.",
  "version": "2.0.0",
  "type": "object",
  "properties": {
    "node_labels": {
      "description": "Defines the allowed node types in the graph.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": { "type": "string", "description": "The name of the node label." },
          "description": { "type": "string" },
          "properties": {
            "type": "object",
            "description": "Key-value pairs defining the properties for this node type."
          }
        },
        "required": ["label", "properties"]
      },
      "examples": [
        {
          "label": "Company",
          "description": "A publicly traded company.",
          "properties": {
            "name": { "type": "string" },
            "ticker": { "type": "string" },
            "sector": { "type": "string" }
          }
        },
        {
          "label": "Event",
          "description": "A significant occurrence, such as a market crash or policy change.",
          "properties": {
            "name": { "type": "string" },
            "date": { "type": "string", "format": "date" }
          }
        },
        {
            "label": "Macroeconomic_Indicator",
            "description": "An indicator of macroeconomic trends (e.g., CPI, GDP).",
            "properties": {
              "name": { "type": "string" },
              "frequency": { "type": "string" }
            }
        }
      ]
    },
    "relationship_types": {
      "description": "Defines the allowed relationship types (edges) in the graph.",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": { "type": "string", "description": "The name of the relationship type in uppercase." },
          "description": { "type": "string" },
          "properties": {
            "type": "object",
            "description": "Key-value pairs defining the properties for this relationship type."
          }
        },
        "required": ["type", "properties"]
      },
      "examples": [
        {
          "type": "IS_RELATED_TO",
          "description": "A generic, non-causal relationship between two nodes.",
          "properties": {
            "source": { "type": "string" }
          }
        },
        {
          "type": "CAUSES",
          "description": "A directed relationship where Node A is a direct cause of Node B.",
          "properties": {
            "strength": { "type": "number", "minimum": 0, "maximum": 1, "description": "The probabilistic strength of the causal link." },
            "time_lag_days": { "type": "integer", "description": "The average time delay in days." },
            "evidence_source": { "type": "string", "description": "The document or analysis supporting the claim." }
          }
        },
        {
            "type": "PREVENTS",
            "description": "A directed relationship where Node A reduces the likelihood of Node B.",
            "properties": {
              "strength": { "type": "number", "minimum": 0, "maximum": 1 },
              "evidence_source": { "type": "string" }
            }
        },
        {
            "type": "ENABLES",
            "description": "A directed relationship where Node A creates the conditions for Node B to occur.",
            "properties": {
                "condition": { "type": "string" },
                "evidence_source": { "type": "string" }
            }
        }
      ]
    }
  },
  "required": ["node_labels", "relationship_types"]
}
