{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://awooop.platform/contracts/v1/project_tenant",
  "title": "ProjectTenant Contract",
  "description": "AwoooP 租戶/專案合約 — 定義一個 project 的能力邊界與預算配額",
  "type": "object",
  "required": ["project_id", "display_name", "migration_mode"],
  "additionalProperties": false,
  "properties": {
    "project_id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9_-]{1,63}$",
      "description": "全局唯一租戶識別符，只允許小寫字母/數字/底線/連字號"
    },
    "display_name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "人類可讀名稱"
    },
    "migration_mode": {
      "type": "string",
      "enum": ["legacy_awoooi_default", "shadow", "canary", "active"],
      "description": "Strangler Fig 遷移階段（ADR-106）"
    },
    "budget_limit_usd": {
      "type": ["number", "null"],
      "minimum": 0,
      "description": "每日 LLM 費用上限（USD）；null = 無上限"
    },
    "allowed_channels": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["telegram", "slack", "webhook", "api"]
      },
      "uniqueItems": true,
      "description": "此租戶允許使用的 channel 類型清單"
    },
    "is_active": {
      "type": "boolean",
      "default": true,
      "description": "租戶是否啟用"
    },
    "metadata": {
      "type": "object",
      "description": "擴充欄位（自由 JSON）"
    }
  }
}
