{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/krobar-ai/json-schema/krobar-ai-graph-response-schema.json",
  "title": "GraphResponse",
  "description": "Schema for graph response.",
  "x-generated": "2026-11-14",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/krobar-ai-openapi.json#/components/schemas/GraphResponse",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "title": "Id"
    },
    "name": {
      "type": "string",
      "title": "Name"
    },
    "description": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Description"
    },
    "project_id": {
      "type": "string",
      "format": "uuid",
      "title": "Project Id"
    },
    "created_by": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Created By"
    },
    "nodes": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Nodes"
    },
    "edges": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Edges"
    },
    "graph_metadata": {
      "anyOf": [
        {
          "additionalProperties": true,
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Graph Metadata"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "title": "Created At"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "title": "Updated At"
    },
    "updated_by": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid"
        },
        {
          "type": "null"
        }
      ],
      "title": "Updated By"
    },
    "version_count": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Version Count",
      "description": "Total number of versions for this graph"
    },
    "latest_version": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Latest Version",
      "description": "Latest version number for this graph"
    },
    "time_period_unit": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Time Period Unit",
      "description": "Unit of time for simulation periods (e.g., 'month')"
    },
    "estimation_percentile": {
      "type": "number",
      "title": "Estimation Percentile",
      "description": "Percentile used for estimation calculations"
    },
    "simulation_trials": {
      "type": "integer",
      "title": "Simulation Trials",
      "description": "Number of simulation trials to run"
    },
    "simulation_time_periods": {
      "type": "integer",
      "title": "Simulation Time Periods",
      "description": "Number of time periods to simulate"
    },
    "simulation_goal_node": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Simulation Goal Node",
      "description": "Node ID used as the simulation goal"
    },
    "simulation_goal_value": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Simulation Goal Value",
      "description": "Value to reach for the goal node"
    },
    "simulation_goal_direction": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "MAXIMIZE",
            "MINIMIZE"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Simulation Goal Direction",
      "description": "Direction for the simulation goal ('MAXIMIZE' or 'MINIMIZE')"
    },
    "simulation_goal_time_period": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Simulation Goal Time Period",
      "description": "Time period to use for goal calculation (1-based index)"
    },
    "starting_time_period": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "title": "Starting Time Period",
      "description": "Actual start date/time for the simulation"
    },
    "display_timezone": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Display Timezone",
      "description": "IANA timezone identifier for displaying the start time (e.g., 'America/New_York', 'Europe/London')"
    },
    "parameter_display_mode": {
      "type": "string",
      "title": "Parameter Display Mode",
      "description": "How parameters are displayed in the UI"
    },
    "canvas_view": {
      "type": "string",
      "title": "Canvas View",
      "description": "Current view mode of the canvas"
    },
    "illustration_style": {
      "type": "string",
      "title": "Illustration Style",
      "description": "Style of illustrations"
    },
    "illustrations": {
      "additionalProperties": {
        "type": "string"
      },
      "type": "object",
      "title": "Illustrations",
      "description": "Deprecated top-level illustration field retained for compatibility. Public read payloads use nodes[].illustration_urls."
    },
    "illustration_urls": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "string"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Illustration Urls",
      "description": "Deprecated top-level illustration URL field retained for compatibility. Public read payloads use nodes[].illustration_urls."
    },
    "errors_by_element": {
      "anyOf": [
        {
          "additionalProperties": {
            "items": {
              "anyOf": [
                {
                  "$ref": "#/$defs/NodeValidationResult"
                },
                {
                  "$ref": "#/$defs/EdgeValidationResult"
                }
              ]
            },
            "type": "array"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Errors By Element",
      "description": "Validation errors organized by graph element type (nodes, edges)"
    },
    "errors_by_ruleset": {
      "anyOf": [
        {
          "additionalProperties": {
            "items": {
              "$ref": "#/$defs/RulesetError"
            },
            "type": "array"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Errors By Ruleset",
      "description": "Validation errors organized by ruleset"
    },
    "is_valid": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Is Valid",
      "description": "Whether the graph is valid overall"
    },
    "journey_columns": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Journey Columns",
      "description": "Number of journey columns for the graph"
    },
    "canvas_view_filters": {
      "anyOf": [
        {
          "additionalProperties": {
            "type": "boolean"
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Canvas View Filters",
      "description": "Filters for the canvas view"
    },
    "tags": {
      "anyOf": [
        {
          "items": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "boolean"
                }
              ]
            },
            "type": "array"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Tags",
      "description": "Tags for the graph as a list of [string, boolean] pairs, e.g. [['journey', true], ['costs', true]]"
    },
    "team_role": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Team Role",
      "description": "The user's team role for this graph (OWNER, ADMIN, MEMBER, VIEWER)"
    },
    "created_by_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Created By Name",
      "description": "Name of the user who created this graph"
    },
    "updated_by_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Updated By Name",
      "description": "Name of the user who last updated this graph"
    },
    "client_change_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Client Change Id",
      "description": "Client-supplied change ID used to correlate SSE chains to a specific local edit"
    },
    "client_edit_at": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Client Edit At",
      "description": "Client local edit timestamp (ISO) echoed back from write requests"
    }
  },
  "type": "object",
  "required": [
    "id",
    "name",
    "project_id",
    "nodes",
    "edges",
    "created_at",
    "updated_at",
    "estimation_percentile",
    "simulation_trials",
    "simulation_time_periods",
    "parameter_display_mode",
    "canvas_view",
    "illustration_style",
    "illustrations"
  ],
  "$defs": {
    "EdgeValidationResult": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "ID of the edge with validation errors"
        },
        "validation_errors": {
          "items": {
            "$ref": "#/$defs/ElementValidationError"
          },
          "type": "array",
          "title": "Validation Errors",
          "description": "List of validation errors for this edge"
        }
      },
      "type": "object",
      "required": [
        "id",
        "validation_errors"
      ],
      "title": "EdgeValidationResult",
      "description": "Schema for validation errors for a specific edge."
    },
    "ElementValidationError": {
      "properties": {
        "rule": {
          "type": "string",
          "title": "Rule",
          "description": "Specific validation rule that was violated"
        },
        "severity": {
          "$ref": "#/$defs/ValidationSeverity",
          "description": "Severity of the error (error, warning, info)"
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Human-readable error message describing the validation issue"
        },
        "technical_message": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Technical Message",
          "description": "Technical error message with element IDs and debugging details for developers/LLM"
        },
        "error_code": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error Code",
          "description": "Machine-readable error code for programmatic handling"
        },
        "affected_elements": {
          "$ref": "#/$defs/GraphElements",
          "description": "Graph elements affected by this error"
        },
        "ruleset": {
          "type": "string",
          "title": "Ruleset",
          "description": "Name of the ruleset that generated this error"
        }
      },
      "type": "object",
      "required": [
        "rule",
        "severity",
        "message",
        "affected_elements",
        "ruleset"
      ],
      "title": "ElementValidationError",
      "description": "Enhanced schema for validation errors with detailed element information."
    },
    "GraphElements": {
      "properties": {
        "nodes": {
          "items": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "type": "array",
          "title": "Nodes",
          "description": "List of affected nodes with id and name pairs"
        },
        "edges": {
          "items": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object"
          },
          "type": "array",
          "title": "Edges",
          "description": "List of affected edges with id and name pairs"
        }
      },
      "type": "object",
      "title": "GraphElements",
      "description": "Schema for affected graph elements in validation."
    },
    "NodeValidationResult": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "ID of the node with validation errors"
        },
        "validation_errors": {
          "items": {
            "$ref": "#/$defs/ElementValidationError"
          },
          "type": "array",
          "title": "Validation Errors",
          "description": "List of validation errors for this node"
        }
      },
      "type": "object",
      "required": [
        "id",
        "validation_errors"
      ],
      "title": "NodeValidationResult",
      "description": "Schema for validation errors for a specific node."
    },
    "RulesetError": {
      "properties": {
        "rule": {
          "type": "string",
          "title": "Rule",
          "description": "Specific validation rule that was violated"
        },
        "severity": {
          "$ref": "#/$defs/ValidationSeverity",
          "description": "Severity of the error (error, warning, info)"
        },
        "message": {
          "type": "string",
          "title": "Message",
          "description": "Error message describing the validation issue"
        },
        "affected_elements": {
          "$ref": "#/$defs/GraphElements",
          "description": "Graph elements affected by this error"
        }
      },
      "type": "object",
      "required": [
        "rule",
        "severity",
        "message",
        "affected_elements"
      ],
      "title": "RulesetError",
      "description": "Schema for errors grouped by ruleset."
    },
    "ValidationSeverity": {
      "type": "string",
      "enum": [
        "error",
        "warning",
        "info"
      ],
      "title": "ValidationSeverity",
      "description": "Enum for validation error severity levels."
    }
  }
}