{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Greentic YGTC Flow (self-describing nodes)",
  "type": "object",
  "required": ["id", "type", "nodes"],
  "properties": {
    "id": { "type": "string", "minLength": 1 },
    "title": { "type": "string" },
    "description": { "type": "string" },
    "type": {
      "type": "string",
      "enum": ["messaging", "webhook", "timer", "websocket", "pubsub"]
    },
    "start": { "type": "string" },
    "parameters": { "type": "object", "additionalProperties": true },
    "nodes": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": false,
      "patternProperties": {
        "^[a-zA-Z_][\\w-]*$": {
          "type": "object",
          "description": "A node must have exactly one component key like qa.process/tool.exec/templating.handlebars plus optional routing.",
          "minProperties": 1,
          "maxProperties": 2,
          "properties": {
            "routing": {
              "type": "array",
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "to": { "type": "string" },
                  "out": { "type": "boolean" }
                }
              }
            }
          },
          "patternProperties": {
            "^[a-zA-Z][\\w.-]*\\.[\\w.-]+$": {
              "type": "object",
              "description": "Opaque component payload – validated by the component itself.",
              "additionalProperties": true
            }
          },
          "additionalProperties": false
        }
      }
    }
  }
}
