{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tabletwin.com/models/docs/schema.json",
  "title": "Tabletwin model v0.9",
  "description": "Een bordspel als YAML: flow, toestand, acties, effecten, einde. Zie docs/reference.md.",
  "type": "object",
  "required": [
    "game",
    "label",
    "flow",
    "actions",
    "end"
  ],
  "additionalProperties": false,
  "properties": {
    "game": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "players": {
      "type": "string"
    },
    "num_players": {
      "type": "integer",
      "minimum": 1
    },
    "mode": {
      "enum": [
        "competitive",
        "cooperative"
      ]
    },
    "summary": {
      "type": "string"
    },
    "demonstrates": {
      "type": "string"
    },
    "scope": {
      "type": "string"
    },
    "description": {
      "type": "string"
    },
    "constants": {
      "type": "object"
    },
    "boards": {
      "type": "object",
      "description": "(v0.9) Borden met geometrie: {naam: bord}. Zie docs/board-geometry.md",
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "kind": {
            "enum": [
              "square",
              "hex"
            ]
          },
          "width": {
            "type": "integer",
            "minimum": 1
          },
          "height": {
            "type": "integer",
            "minimum": 1
          },
          "names": {
            "enum": [
              "xy",
              "letters"
            ]
          },
          "neighbours": {
            "enum": [
              4,
              8
            ]
          },
          "radius": {
            "type": "integer",
            "minimum": 0
          },
          "cells": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "missing": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "walls": {
            "type": "array",
            "items": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 2,
              "maxItems": 2
            }
          },
          "label": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      }
    },
    "functions": {
      "type": "object",
      "description": "(v0.9) Eigen functies: {naam: {params, let?, x}}. Zie docs/board-geometry.md",
      "additionalProperties": {
        "type": "object",
        "required": [
          "x"
        ],
        "additionalProperties": false,
        "properties": {
          "params": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_]*\\??$"
            }
          },
          "let": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            }
          },
          "x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "text": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      }
    },
    "state": {
      "type": "object",
      "properties": {
        "zones": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "kind": {
                "enum": [
                  "grid",
                  "hexgrid",
                  "graph",
                  "plane",
                  "stack",
                  "set",
                  "bag",
                  "slot",
                  "track"
                ]
              },
              "owner": {
                "enum": [
                  "global",
                  "player",
                  "team",
                  "entity"
                ]
              },
              "visibility": {
                "enum": [
                  "public",
                  "owner",
                  "hidden"
                ]
              },
              "shuffled": {
                "type": "boolean"
              },
              "persist": {
                "const": "campaign"
              },
              "holds": {
                "type": "string"
              },
              "size": {},
              "init_x": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "note": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "drawn_from": {
                "type": "string",
                "description": "verborgen zone: waar de kaarten vandaan komen (een geschudde stapel); zoeken herverdeelt ze daarmee"
              }
            },
            "additionalProperties": false
          }
        },
        "vars": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "scope": {
                "enum": [
                  "global",
                  "player",
                  "team",
                  "entity"
                ]
              },
              "type": {
                "type": "string"
              },
              "init": {},
              "init_x": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "persist": {
                "const": "campaign"
              },
              "range": {},
              "note": {
                "type": "string"
              },
              "label": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        },
        "derived": {
          "type": "object",
          "additionalProperties": {
            "anyOf": [
              {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              {
                "type": "object",
                "properties": {
                  "text": {
                    "type": "string"
                  },
                  "x": {
                    "type": [
                      "string",
                      "number",
                      "boolean"
                    ]
                  },
                  "note": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            ]
          }
        },
        "entity_types": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "attrs": {
                "type": "object"
              },
              "extends": {
                "type": "string"
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "flow": {
      "$ref": "#/$defs/node"
    },
    "flows": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/node"
      }
    },
    "actions": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "actor": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "pre": {
            "type": "string"
          },
          "pre_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "cost": {
            "$ref": "#/$defs/ops"
          },
          "effect": {
            "$ref": "#/$defs/ops"
          },
          "speed": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "triggers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "event": {
            "type": "string"
          },
          "timing": {
            "enum": [
              "before",
              "after",
              "instead",
              "when"
            ]
          },
          "optional": {
            "type": "boolean"
          },
          "controller": {
            "type": "string"
          },
          "controller_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "if": {
            "type": "string"
          },
          "if_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "do": {
            "$ref": "#/$defs/ops"
          },
          "source": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "event"
        ]
      }
    },
    "modifiers": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "stat": {
            "type": "string"
          },
          "layer": {
            "type": "integer"
          },
          "target": {
            "type": "string"
          },
          "change": {
            "type": [
              "string",
              "number"
            ]
          },
          "change_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "if": {
            "type": "string"
          },
          "if_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "duration": {
            "enum": [
              "permanent",
              "round",
              "turn",
              "while"
            ]
          },
          "until": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "priority": {
      "type": "object",
      "properties": {
        "protocol": {
          "type": "object",
          "properties": {
            "first": {
              "type": "string"
            },
            "first_x": {
              "type": [
                "string",
                "number",
                "boolean"
              ]
            },
            "order": {
              "enum": [
                "clockwise_from_first",
                "any_order",
                "active_then_clockwise"
              ]
            },
            "closes": {
              "enum": [
                "all_pass_in_succession",
                "single_pass_each"
              ]
            },
            "resolution": {
              "enum": [
                "immediate",
                "nested",
                "lifo_stack"
              ]
            },
            "after_action": {
              "enum": [
                "next",
                "same"
              ]
            },
            "note": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        "windows": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string"
              },
              "allows": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "note": {
                "type": "string"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "outcomes": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "skill": {
            "type": "boolean"
          },
          "doc": {
            "type": "string"
          },
          "inputs": {
            "type": "object"
          },
          "params": {
            "type": "object"
          },
          "derived": {
            "type": "object"
          },
          "derived_x": {
            "type": "object"
          },
          "outcomes": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "p": {
                  "type": [
                    "string",
                    "number"
                  ]
                },
                "p_x": {
                  "type": [
                    "string",
                    "number",
                    "boolean"
                  ]
                },
                "effect": {
                  "$ref": "#/$defs/ops"
                },
                "note": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "id"
              ]
            }
          }
        },
        "additionalProperties": false
      }
    },
    "agents": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "kind": {
            "enum": [
              "search",
              "heuristic",
              "llm",
              "human"
            ]
          },
          "roles": {
            "type": "array"
          },
          "sees": {
            "type": "array"
          },
          "prompt": {
            "type": "string"
          },
          "policy_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "note": {
            "type": "string"
          }
        },
        "additionalProperties": false
      }
    },
    "content": {
      "type": "object",
      "description": "Catalogi met inhoudsitems; vrije structuur, zie referentie"
    },
    "code": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "lang": {
            "type": "string"
          },
          "ref": {
            "type": "string"
          },
          "doc": {
            "type": "string"
          },
          "kind": {
            "enum": [
              "content",
              "algorithm"
            ]
          }
        },
        "additionalProperties": false
      }
    },
    "open_questions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "about": {
            "type": "string"
          },
          "question": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "status": {
            "enum": [
              "open",
              "assumed",
              "answered"
            ]
          },
          "answer": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "question"
        ]
      }
    },
    "end": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "if": {
            "type": [
              "string",
              "boolean"
            ]
          },
          "if_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "result": {
            "enum": [
              "win",
              "loss",
              "draw",
              "score",
              "eliminate",
              "continue"
            ]
          },
          "who": {
            "type": "string"
          },
          "who_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "returns_x": {
            "type": [
              "string",
              "number",
              "boolean"
            ]
          },
          "scope": {
            "type": "string"
          },
          "check": {
            "enum": [
              "immediate",
              "end_of_turn",
              "end_of_round",
              "end_of_scenario"
            ]
          },
          "note": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "id",
          "result"
        ]
      }
    },
    "utility": {
      "type": "object",
      "properties": {
        "min": {
          "type": "number"
        },
        "max": {
          "type": "number"
        }
      },
      "additionalProperties": false,
      "description": "Bereik van de opbrengst per speler (standaard -1 tot 1); voor OpenSpiel"
    }
  },
  "$defs": {
    "node": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "kind": {
          "enum": [
            "sequence",
            "loop",
            "branch",
            "step",
            "subflow"
          ]
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/node"
          }
        },
        "over": {
          "type": "string"
        },
        "over_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "as": {
          "type": "string"
        },
        "order": {
          "enum": [
            "fixed",
            "clockwise_from_first",
            "initiative",
            "simultaneous",
            "deck_order",
            "players_choose"
          ]
        },
        "until": {
          "type": [
            "string",
            "boolean"
          ]
        },
        "until_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "switch": {
          "type": "string"
        },
        "cases": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "when": {
                "type": [
                  "string",
                  "boolean"
                ]
              },
              "when_x": {
                "type": [
                  "string",
                  "number",
                  "boolean"
                ]
              },
              "label": {
                "type": "string"
              },
              "note": {
                "type": "string"
              },
              "children": {
                "type": "array",
                "items": {
                  "$ref": "#/$defs/node"
                }
              }
            },
            "additionalProperties": false
          }
        },
        "ref": {
          "type": "string"
        },
        "do": {
          "type": [
            "string",
            "array"
          ],
          "items": {
            "type": "string"
          }
        },
        "actor": {
          "type": "string"
        },
        "actor_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "secret": {
          "type": "boolean"
        },
        "visible_to_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "window": {
          "type": [
            "string",
            "boolean"
          ]
        },
        "note": {
          "type": "string"
        },
        "once": {
          "type": "boolean",
          "description": "loop: één rondgang over over_x"
        },
        "end_event": {
          "description": "event(s) die de engine uitzendt als deze knoop klaar is (na zijn venster), bijvoorbeeld fase_einde",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "id",
        "kind"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "kind": {
                "const": "step"
              }
            }
          },
          "then": {
            "required": [
              "do"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "subflow"
              }
            }
          },
          "then": {
            "required": [
              "ref"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "kind": {
                "const": "branch"
              }
            }
          },
          "then": {
            "required": [
              "cases"
            ]
          }
        }
      ]
    },
    "op": {
      "type": "object",
      "properties": {
        "op": {
          "enum": [
            "place",
            "move",
            "create",
            "destroy",
            "set",
            "add",
            "draw",
            "shuffle",
            "reveal",
            "roll",
            "choose",
            "if",
            "repeat",
            "for_each",
            "emit",
            "call",
            "run",
            "sample",
            "say",
            "exec",
            "let",
            "window",
            "cancel",
            "modify",
            "reset",
            "look",
            "search"
          ]
        },
        "var": {
          "type": "string"
        },
        "value": {},
        "value_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "amount": {
          "type": [
            "number",
            "string"
          ]
        },
        "amount_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "what": {},
        "what_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "to": {
          "type": "string"
        },
        "from": {
          "type": "string"
        },
        "at": {},
        "at_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "n": {
          "type": [
            "integer",
            "string"
          ]
        },
        "n_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "zone": {
          "type": "string"
        },
        "die": {
          "type": [
            "array",
            "string"
          ]
        },
        "die_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "bind": {
          "type": "string"
        },
        "options": {
          "type": [
            "array",
            "string"
          ]
        },
        "options_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "actor": {
          "type": "string"
        },
        "actor_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "secret": {
          "type": "boolean"
        },
        "visible_to_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "agent": {
          "type": "string"
        },
        "min": {
          "type": [
            "integer",
            "string"
          ]
        },
        "max": {
          "type": [
            "integer",
            "string"
          ]
        },
        "min_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "max_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "cond": {
          "type": "string"
        },
        "cond_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "then": {
          "$ref": "#/$defs/ops"
        },
        "else": {
          "$ref": "#/$defs/ops"
        },
        "until": {
          "type": [
            "string",
            "boolean"
          ]
        },
        "until_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "body": {
          "$ref": "#/$defs/ops"
        },
        "items": {
          "type": [
            "array",
            "string"
          ]
        },
        "items_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "as": {
          "type": "string"
        },
        "event": {
          "type": "string"
        },
        "impact": {
          "$ref": "#/$defs/ops"
        },
        "code": {
          "type": "string"
        },
        "flow": {
          "type": "string"
        },
        "args": {},
        "model": {
          "type": "string"
        },
        "inputs": {},
        "channel": {
          "type": "string"
        },
        "constraint": {
          "type": "string"
        },
        "of": {
          "type": "string"
        },
        "of_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "content": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "target": {},
        "target_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "stat": {
          "type": "string"
        },
        "layer": {
          "type": "integer"
        },
        "change": {
          "type": "string"
        },
        "change_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "if_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ],
          "description": "modify: the temporary modifier is only active while this holds"
        },
        "scope": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "attr": {
          "type": "string"
        },
        "filter": {
          "type": "string"
        },
        "filter_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        },
        "position": {
          "enum": [
            "top",
            "bottom",
            "random"
          ]
        },
        "with_x": {
          "type": [
            "string",
            "number",
            "boolean"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "op"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "op": {
                "const": "set"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "var"
                    ]
                  },
                  {
                    "required": [
                      "attr"
                    ]
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "value"
                    ]
                  },
                  {
                    "required": [
                      "value_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "add"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "var"
                    ]
                  },
                  {
                    "required": [
                      "attr"
                    ]
                  }
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "amount"
                    ]
                  },
                  {
                    "required": [
                      "amount_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "place"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "to"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "what"
                    ]
                  },
                  {
                    "required": [
                      "what_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "create"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "to"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "what"
                    ]
                  },
                  {
                    "required": [
                      "what_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "move"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "from",
                  "to"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "what"
                    ]
                  },
                  {
                    "required": [
                      "what_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "destroy"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "what"
                    ]
                  },
                  {
                    "required": [
                      "what_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "draw"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "from",
                  "to"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "roll"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "die"
                    ]
                  },
                  {
                    "required": [
                      "die_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "choose"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "options"
                    ]
                  },
                  {
                    "required": [
                      "options_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "if"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "then"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "cond"
                    ]
                  },
                  {
                    "required": [
                      "cond_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "repeat"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "body"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "until"
                    ]
                  },
                  {
                    "required": [
                      "until_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "for_each"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "body"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "items"
                    ]
                  },
                  {
                    "required": [
                      "items_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "emit"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "event"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "call"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "code"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "run"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "flow"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "sample"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "model"
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "exec"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "of"
                    ]
                  },
                  {
                    "required": [
                      "of_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "let"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "bind"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "value"
                    ]
                  },
                  {
                    "required": [
                      "value_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "cancel"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "anyOf": [
                  {
                    "required": [
                      "target"
                    ]
                  },
                  {
                    "required": [
                      "target_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "modify"
              }
            }
          },
          "then": {
            "allOf": [
              {
                "required": [
                  "stat"
                ]
              },
              {
                "anyOf": [
                  {
                    "required": [
                      "change"
                    ]
                  },
                  {
                    "required": [
                      "change_x"
                    ]
                  }
                ]
              }
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "look"
              }
            }
          },
          "then": {
            "required": [
              "from"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "op": {
                "const": "search"
              }
            }
          },
          "then": {
            "required": [
              "from",
              "bind"
            ]
          }
        }
      ]
    },
    "ops": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/op"
      }
    }
  }
}
