{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://manaurum.com/standards/manifest_v1.schema.json",
  "title": "Manaurum Application Manifest v1",
  "description": "Canonical schema for Manaurum tenant application manifests, version 1. Published by Foundation track W2.2 per IMPLEMENTATION_B2B_TENANCY.md §4.2. Tenants validate against this file in their CI; the Manaurum Deploy API (W3.4) validates against the same JSON Schema using the jsonschema Python library. Pydantic mirror in backend/app/schemas/manifest_v1.py exists for type safety in server-side code only — it is NOT the source of truth.",
  "type": "object",
  "required": [
    "manifest_version",
    "manaurum_sdk_version",
    "slug",
    "name",
    "version",
    "entry_point"
  ],
  "additionalProperties": false,
  "properties": {
    "manifest_version": {
      "const": "1",
      "description": "Manifest schema version — pinned at \"1\" for the lifetime of v1. Breaking changes require manifest_version=\"2\" and a major SDK release."
    },
    "manaurum_sdk_version": {
      "enum": ["1"],
      "description": "Major SDK version the application is built against."
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9-]{2,49}$",
      "description": "URL-safe identifier, 3–50 chars, lowercase ASCII letters/digits/hyphens; must start with a letter."
    },
    "name": {
      "type": "string",
      "maxLength": 100,
      "description": "Human-readable name shown in shell UI."
    },
    "version": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+$",
      "description": "Semver MAJOR.MINOR.PATCH (no pre-release/build metadata in v1)."
    },
    "icon": {
      "type": "string",
      "description": "Either an emoji or a path inside the bundle (e.g. 'icons/app.svg')."
    },
    "window": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "default_width": {
          "type": "integer",
          "minimum": 320,
          "maximum": 4000
        },
        "default_height": {
          "type": "integer",
          "minimum": 240,
          "maximum": 4000
        }
      }
    },
    "entry_point": {
      "type": "string",
      "description": "Path to the application entry HTML or script inside the bundle."
    },
    "permissions": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": [
          "auth.read_user",
          "auth.read_workspace_members",
          "navigation.open_app",
          "navigation.close_self",
          "events.subscribe",
          "db.read_own_entities",
          "db.write_own_entities"
        ]
      }
    },
    "entities": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["type", "fields"],
        "additionalProperties": false,
        "properties": {
          "type": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9_]*$",
            "description": "Entity name, lowercase snake_case."
          },
          "storage": {
            "enum": ["shared"],
            "default": "shared",
            "description": "v1: shared only. 'dedicated' is reserved and rejected by the validator until enabled."
          },
          "fields": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "required": ["type"],
              "additionalProperties": false,
              "properties": {
                "type": {
                  "enum": [
                    "string",
                    "uuid",
                    "timestamp",
                    "integer",
                    "decimal",
                    "boolean",
                    "json"
                  ]
                },
                "indexed": {
                  "type": "boolean",
                  "default": false
                },
                "required": {
                  "type": "boolean",
                  "default": false
                }
              }
            }
          }
        }
      }
    },
    "integrations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["name", "kind"],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string"
          },
          "kind": {
            "enum": ["cdn", "external_service"]
          },
          "url": {
            "type": "string",
            "format": "uri"
          }
        }
      }
    },
    "metadata": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "category": {
          "type": "string"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}
