{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://optinrouter.ai/docs/schemas/action-graph.schema.json",
  "title": "OptinRouter action-graph preview contract",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "version": {
      "const": "2026-10-19-preview"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "max_parallel": {
      "type": "integer",
      "minimum": 1,
      "maximum": 8
    },
    "nodes": {
      "type": "array",
      "minItems": 1,
      "maxItems": 32,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "phase": {
            "enum": [
              "input",
              "output"
            ]
          },
          "placement": {
            "enum": [
              "managed",
              "customer_server",
              "end_device"
            ]
          },
          "trigger": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "field": {
                "enum": [
                  "context.data_class",
                  "context.task",
                  "result.format",
                  "result.validation"
                ]
              },
              "equals": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              }
            },
            "required": [
              "field",
              "equals"
            ]
          },
          "tool": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160,
            "pattern": "^[a-zA-Z0-9_.@:/-]+$"
          },
          "input_projection": {
            "type": "array",
            "maxItems": 12,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160,
              "pattern": "^[a-zA-Z0-9_.@:/-]+$"
            }
          },
          "depends_on": {
            "type": "array",
            "maxItems": 16,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            }
          },
          "required": {
            "type": "boolean"
          },
          "timeout_ms": {
            "type": "integer",
            "minimum": 1,
            "maximum": 30000
          },
          "output_slot": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "on_failure": {
            "enum": [
              "block",
              "hold",
              "continue_without_result"
            ]
          }
        },
        "required": [
          "id",
          "phase",
          "placement",
          "trigger",
          "tool",
          "input_projection",
          "depends_on",
          "required",
          "timeout_ms",
          "output_slot",
          "on_failure"
        ]
      }
    },
    "join": {
      "const": "all_required_before_release"
    },
    "external_side_effects": {
      "const": false
    }
  },
  "required": [
    "version",
    "name",
    "max_parallel",
    "nodes",
    "join",
    "external_side_effects"
  ]
}
