{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.cuddler.dev/standards/artifact-definitions/codefactory-app/1.0.0/data.schema.json",
  "title": "CodeFactory App Data Schema",
  "type": "object",
  "cuddler": {
    "specVersion": "1.0.0",
    "documentTypeId": "codefactory-app",
    "schemaVersion": "1.0.0",
    "output": {
      "primaryContentType": "application/json",
      "supportedContentTypes": ["application/json"]
    },
    "profile": {
      "id": "codefactory-app",
      "version": "1.0.0",
      "for-ai": [
        {
          "instruction": "Explain what this Cuddler schema profile governs so AI consumers understand when to use this schema family.",
          "input": "",
          "output": "CodeFactory App schema family for publishing app-level JSON definitions with menu, page catalog, component hierarchy, data source, and command metadata."
        }
      ]
    },
    "schemaLinks": [
      {
        "rel": "self",
        "targetSchema": "https://www.cuddler.dev/standards/artifact-definitions/codefactory-app/1.0.0/data.schema.json",
        "targetDocumentTypeId": "codefactory-app",
        "for-ai": [
          {
            "instruction": "Explain why this related schema is linked here and when an AI consumer should follow it.",
            "input": "",
            "output": "Use the canonical CodeFactory App data schema at this immutable URL when validating or generating a CodeFactory app document."
          }
        ]
      }
    ],
    "artifactType": "CodeFactory App",
    "status": "Public normative publication",
    "publisher": "IdeaTilt Inc.",
    "sourceUrl": "https://www.cuddler.dev/standards/artifact-definitions/codefactory-app/",
    "attributionNotice": "© 2026 IdeaTilt. This work is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0). See https://www.cuddler.dev/license/ for the site license summary. You are free to share, use, adapt, and modify this material, including for commercial purposes, provided you give appropriate attribution and include a link to the original source URL and the CC BY 4.0 license at https://creativecommons.org/licenses/by/4.0/.",
    "governingDomainSpecification": {
      "title": "Data Document Role",
      "url": "https://www.cuddler.dev/standards/document-role/data/v1.0.0/"
    },
    "governingArtifactSpecification": {
      "title": "Cuddler Artifact Specification",
      "version": "1.0.0",
      "url": "https://www.cuddler.dev/standards/artifact-specification/v1.0.0/"
    }
  },
  "for-ai": [
    {
      "instruction": "Create one complete CodeFactory app document per app. Put identity, menu, page catalog, page component hierarchy documents, data sources, and commands in content.documentModel.",
      "input": "",
      "output": "Use this schema to generate a single CodeFactory app JSON data document."
    }
  ],
  "required": ["$schema", "meta", "content"],
  "properties": {
    "$schema": {
      "const": "https://www.cuddler.dev/standards/artifact-definitions/codefactory-app/1.0.0/data.schema.json",
      "for-ai": [
        {
          "instruction": "Set instance $schema exactly equal to the canonical CodeFactory app schema id.",
          "input": "",
          "output": "https://www.cuddler.dev/standards/artifact-definitions/codefactory-app/1.0.0/data.schema.json"
        }
      ]
    },
    "meta": {
      "$ref": "#/definitions/DocumentMeta",
      "for-ai": [
        {
          "instruction": "Describe the app JSON document and its authorship.",
          "input": "",
          "output": "Cuddler document metadata."
        }
      ]
    },
    "content": {
      "$ref": "#/definitions/DocumentContent",
      "for-ai": [
        {
          "instruction": "Put the app runtime contract in content.documentModel.",
          "input": "",
          "output": "CodeFactory app document model."
        }
      ]
    },
    "assets": {
      "type": "object",
      "additionalProperties": true,
      "for-ai": [
        {
          "instruction": "Use assets only for app-owned static resources that the renderer needs by id.",
          "input": "",
          "output": "Optional app asset catalog."
        }
      ]
    },
    "references": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/Reference"
      },
      "for-ai": [
        {
          "instruction": "Use this guidance when preparing a valid value for this schema node.",
          "input": "",
          "output": "Optional references that support the CodeFactory app document."
        }
      ]
    }
  },
  "additionalProperties": false,
  "definitions": {
    "DocumentMeta": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "documentTypeId", "documentId", "title", "createdAt", "authors"],
      "properties": {
        "schemaVersion": {
          "const": "1.0.0"
        },
        "documentTypeId": {
          "const": "codefactory-app"
        },
        "documentId": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "authors": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/Author"
          }
        },
        "status": {
          "type": "string",
          "enum": ["Draft", "Review", "Approved", "Published", "Deprecated"]
        },
        "summary": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true
        }
      }
    },
    "Author": {
      "type": "object",
      "additionalProperties": false,
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "email": {
          "type": "string",
          "format": "email"
        }
      }
    },
    "DocumentContent": {
      "type": "object",
      "additionalProperties": false,
      "required": ["documentModel"],
      "properties": {
        "sections": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "documentModel": {
          "$ref": "#/definitions/CodeFactoryAppModel"
        }
      }
    },
    "CodeFactoryAppModel": {
      "type": "object",
      "additionalProperties": false,
      "required": ["schemaVersion", "sourceKind", "identity", "menu", "pages"],
      "properties": {
        "schemaVersion": {
          "const": "1.0.0"
        },
        "sourceKind": {
          "type": "string",
          "enum": ["EmbeddedApp", "UserApp"]
        },
        "identity": {
          "$ref": "#/definitions/AppIdentity"
        },
        "menuOrder": {
          "type": "integer"
        },
        "isBuilderEditable": {
          "type": "boolean"
        },
        "shellSurfaces": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": ["StartPage", "Footer"]
          },
          "uniqueItems": true,
          "default": [],
          "for-ai": [
            {
              "instruction": "Declare where the Desktop shell should surface this app. Use StartPage for the app dashboard and Footer for the footer navigation strip. Omit or use an empty array for legacy default start-page visibility.",
              "input": "",
              "output": "[\"StartPage\"]"
            }
          ]
        },
        "icon": {
          "$ref": "#/definitions/Icon"
        },
        "menu": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/MenuItem"
          }
        },
        "pages": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/definitions/Page"
          }
        },
        "dataSources": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/DataSource"
          },
          "default": []
        },
        "commands": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Command"
          },
          "default": []
        }
      }
    },
    "AppIdentity": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pluginId", "toolKey", "displayName"],
      "properties": {
        "pluginId": {
          "type": "string",
          "minLength": 1
        },
        "toolKey": {
          "type": "string",
          "minLength": 1
        },
        "displayName": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        },
        "author": {
          "type": "string"
        },
        "pluginType": {
          "type": "string",
          "enum": ["App"]
        },
        "menuPlacement": {
          "type": "string",
          "enum": ["EmbeddedApp", "UserApp"]
        }
      }
    },
    "Icon": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "glyph": {
          "type": "string"
        },
        "fontFamily": {
          "type": "string"
        }
      }
    },
    "MenuItem": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "label"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string",
          "minLength": 1
        },
        "pageId": {
          "type": "string"
        },
        "order": {
          "type": "integer"
        },
        "isEnabled": {
          "type": "boolean",
          "default": true
        },
        "icon": {
          "$ref": "#/definitions/Icon"
        },
        "description": {
          "type": "string"
        },
        "tooltip": {
          "type": "string"
        },
        "badgeText": {
          "type": "string"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/MenuItem"
          },
          "default": []
        }
      }
    },
    "Page": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pageId", "title", "document"],
      "properties": {
        "pageId": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "route": {
          "type": "string"
        },
        "artifactUrl": {
          "type": "string"
        },
        "artifactSource": {
          "type": "string",
          "default": "inline"
        },
        "requiredCapabilities": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "default": []
        },
        "document": {
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "DataSource": {
      "type": "object",
      "additionalProperties": false,
      "required": ["key"],
      "properties": {
        "key": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "type": "string",
          "enum": ["inline", "handler"],
          "default": "inline"
        },
        "handlerKey": {
          "type": "string"
        },
        "rows": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": true
          },
          "default": []
        }
      }
    },
    "Command": {
      "type": "object",
      "additionalProperties": false,
      "required": ["commandId", "kind"],
      "properties": {
        "commandId": {
          "type": "string",
          "minLength": 1
        },
        "kind": {
          "type": "string",
          "enum": ["workflow", "handler"]
        },
        "toolKey": {
          "type": "string"
        },
        "workflowId": {
          "type": "string"
        },
        "configurationId": {
          "type": "string"
        },
        "handlerKey": {
          "type": "string"
        }
      }
    },
    "Reference": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "url"],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "url": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  }
}
