{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://archrad.dev/schemas/archrad-ir-graph-v1.json",
  "title": "ArchRad blueprint IR (graph) v1",
  "description": "Contract for JSON consumed by @archrad/deterministic. Structural rules in code may be stricter (e.g. HTTP paths, cycles); this schema documents the expected shape.",
  "$comment": "OSS structural validation: use validateIrStructural() in @archrad/deterministic. Semantic/compliance checks are ArchRad Cloud.",
  "oneOf": [
    {
      "type": "object",
      "required": ["graph"],
      "properties": {
        "graph": { "$ref": "#/$defs/graph" }
      },
      "additionalProperties": true
    },
    {
      "$ref": "#/$defs/graph"
    }
  ],
  "$defs": {
    "graph": {
      "type": "object",
      "required": ["nodes"],
      "properties": {
        "metadata": {
          "type": "object",
          "additionalProperties": true
        },
        "nodes": {
          "type": "array",
          "items": { "$ref": "#/$defs/node" },
          "minItems": 1
        },
        "edges": {
          "type": "array",
          "items": { "$ref": "#/$defs/edge" }
        }
      },
      "additionalProperties": true
    },
    "node": {
      "type": "object",
      "required": ["id"],
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "type": { "type": "string" },
        "kind": { "type": "string" },
        "name": { "type": "string" },
        "config": { "type": "object", "additionalProperties": true },
        "schema": { "type": "object", "additionalProperties": true }
      },
      "additionalProperties": true
    },
    "edge": {
      "type": "object",
      "properties": {
        "id": { "type": "string" },
        "from": { "type": "string" },
        "to": { "type": "string" },
        "source": { "type": "string" },
        "target": { "type": "string" },
        "config": { "type": "object", "additionalProperties": true }
      },
      "additionalProperties": true
    }
  }
}
