{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "MAT- Workspace v3",
  "description": "AI-generated portable workspace specification. Additional geometry, reference, binding and value checks are enforced by the importer.",
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
      "maxLength": 64
    },
    "check": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "text": {
          "type": "string",
          "maxLength": 500,
          "minLength": 1
        },
        "done": {
          "type": "boolean"
        }
      },
      "required": [
        "id",
        "text"
      ],
      "additionalProperties": false
    },
    "image": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "pattern": "^https?://",
          "maxLength": 2048
        },
        "caption": {
          "type": "string",
          "maxLength": 500,
          "minLength": 0
        }
      },
      "required": [
        "url"
      ],
      "additionalProperties": false
    },
    "content": {
      "type": "object",
      "properties": {
        "description": {
          "type": "string",
          "maxLength": 20000,
          "minLength": 0
        },
        "notes": {
          "type": "string",
          "maxLength": 20000,
          "minLength": 0
        },
        "references": {
          "type": "string",
          "maxLength": 20000,
          "minLength": 0
        },
        "prompt": {
          "type": "string",
          "maxLength": 20000,
          "minLength": 0
        },
        "result": {
          "type": "string",
          "maxLength": 20000,
          "minLength": 0
        },
        "status": {
          "enum": [
            "not_started",
            "in_progress",
            "waiting",
            "completed"
          ]
        },
        "type": {
          "enum": [
            "task",
            "decision",
            "data",
            "milestone"
          ]
        },
        "marked": {
          "type": "boolean"
        },
        "checklist": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/check"
          },
          "maxItems": 100,
          "minItems": 0
        }
      },
      "required": [],
      "additionalProperties": false
    },
    "field": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "text"
            },
            "value": {
              "type": "string",
              "maxLength": 20000,
              "minLength": 0
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "checkbox"
            },
            "value": {
              "type": "boolean"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "number"
            },
            "value": {
              "type": "number"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "date"
            },
            "value": {
              "type": "string",
              "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "url"
            },
            "value": {
              "type": "string",
              "pattern": "^https?://",
              "maxLength": 2048
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "select"
            },
            "value": {
              "type": "string",
              "maxLength": 60,
              "minLength": 0
            },
            "options": {
              "type": "array",
              "items": {
                "type": "string",
                "maxLength": 60,
                "minLength": 1
              },
              "maxItems": 50,
              "minItems": 1
            }
          },
          "required": [
            "id",
            "label",
            "type",
            "options"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "image"
            },
            "value": {
              "$ref": "#/$defs/image"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "checklist"
            },
            "value": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/check"
              },
              "maxItems": 100,
              "minItems": 0
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "heading"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "bind": {
              "enum": [
                "description",
                "notes",
                "references",
                "prompt",
                "result",
                "status",
                "type",
                "checklist"
              ]
            },
            "type": {
              "const": "flow"
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "label": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "scope": {
              "enum": [
                "shared",
                "run"
              ]
            },
            "type": {
              "const": "attachment"
            },
            "value": {
              "type": "array",
              "maxItems": 0
            }
          },
          "required": [
            "id",
            "label",
            "type"
          ],
          "additionalProperties": false
        }
      ]
    },
    "tab": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "title": {
          "type": "string",
          "maxLength": 60,
          "minLength": 1
        },
        "fields": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/field"
          },
          "maxItems": 30,
          "minItems": 0
        }
      },
      "required": [
        "id",
        "title",
        "fields"
      ],
      "additionalProperties": false
    },
    "stage": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "name": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "color": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "x": {
              "type": "integer",
              "minimum": 1,
              "maximum": 60
            },
            "y": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12
            },
            "width": {
              "type": "integer",
              "minimum": 1,
              "maximum": 60
            },
            "height": {
              "type": "integer",
              "minimum": 1,
              "maximum": 12
            }
          },
          "required": [
            "id",
            "name",
            "color",
            "x",
            "y",
            "width",
            "height"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string",
              "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
              "maxLength": 64
            },
            "name": {
              "type": "string",
              "maxLength": 60,
              "minLength": 1
            },
            "color": {
              "type": "string",
              "pattern": "^#[0-9a-fA-F]{6}$"
            },
            "cells": {
              "type": "array",
              "items": {
                "type": "array",
                "items": false,
                "prefixItems": [
                  {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 60
                  },
                  {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 12
                  }
                ],
                "minItems": 2,
                "maxItems": 2
              },
              "maxItems": 720,
              "minItems": 1
            }
          },
          "required": [
            "id",
            "name",
            "color",
            "cells"
          ],
          "additionalProperties": false
        }
      ]
    },
    "node": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "title": {
          "type": "string",
          "maxLength": 60,
          "minLength": 1
        },
        "x": {
          "type": "integer",
          "minimum": 1,
          "maximum": 60
        },
        "y": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        },
        "size": {
          "type": "integer",
          "minimum": 1,
          "maximum": 4
        },
        "content": {
          "$ref": "#/$defs/content"
        },
        "tabs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tab"
          },
          "maxItems": 12,
          "minItems": 1
        }
      },
      "required": [
        "id",
        "title",
        "x",
        "y",
        "size"
      ],
      "additionalProperties": false
    },
    "connection": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "from": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "to": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        }
      },
      "required": [
        "id",
        "from",
        "to"
      ],
      "additionalProperties": false
    },
    "round": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "name": {
          "type": "string",
          "maxLength": 60,
          "minLength": 1
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "repeatFlow": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        },
        "name": {
          "type": "string",
          "maxLength": 60,
          "minLength": 1
        },
        "nodeIds": {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
            "maxLength": 64
          },
          "maxItems": 720,
          "minItems": 1
        },
        "rounds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/round"
          },
          "maxItems": 50,
          "minItems": 1
        },
        "activeRoundId": {
          "type": "string",
          "pattern": "^[A-Za-z][A-Za-z0-9_-]{0,63}$",
          "maxLength": 64
        }
      },
      "required": [
        "id",
        "name",
        "nodeIds",
        "rounds"
      ],
      "additionalProperties": false
    },
    "tag": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 20,
          "minLength": 1
        },
        "color": {
          "type": "string",
          "pattern": "^#[0-9a-fA-F]{6}$"
        }
      },
      "required": [
        "name",
        "color"
      ],
      "additionalProperties": false
    }
  },
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "maxLength": 2048,
      "minLength": 0
    },
    "format": {
      "const": "universal-workflow"
    },
    "version": {
      "const": 3
    },
    "workspace": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "maxLength": 60,
          "minLength": 1
        },
        "tags": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/tag"
          },
          "maxItems": 20,
          "minItems": 0
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "grid": {
      "type": "object",
      "properties": {
        "columns": {
          "const": 60
        },
        "rows": {
          "const": 12
        }
      },
      "required": [
        "columns",
        "rows"
      ],
      "additionalProperties": false
    },
    "nodes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/node"
      },
      "maxItems": 720,
      "minItems": 0
    },
    "stages": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/stage"
      },
      "maxItems": 40,
      "minItems": 0
    },
    "connections": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/connection"
      },
      "maxItems": 1000,
      "minItems": 0
    },
    "repeatFlows": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/repeatFlow"
      },
      "maxItems": 40,
      "minItems": 0
    }
  },
  "required": [
    "format",
    "version",
    "workspace",
    "nodes"
  ],
  "additionalProperties": false,
  "$id": ""
}
