{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rangka-os.github.io/rangka-os/schema/0.5/features.json",
  "title": "Rangka features",
  "description": "Layer 4: plans and the entitlements they grant (apps, capabilities, limits). Cloud billing maps plans to prices; self-host can ignore it (everything on).",
  "type": "object",
  "required": [],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "plans": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": [
          "name",
          "label"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "$ref": "model.json#/$defs/name"
          },
          "label": {
            "$ref": "model.json#/$defs/label"
          },
          "extends": {
            "$ref": "model.json#/$defs/name"
          },
          "apps": {
            "type": "array",
            "items": {
              "$ref": "model.json#/$defs/name"
            }
          },
          "modules": {
            "type": "array",
            "items": {
              "$ref": "model.json#/$defs/name"
            },
            "description": "Modules the plan allows on their own (contract 0032), next to the closure of its apps. A plan chain with neither apps nor modules allows every module."
          },
          "capabilities": {
            "type": "array",
            "items": {
              "enum": [
                "realtime",
                "queue",
                "scheduler",
                "files",
                "search",
                "search_vectors",
                "notify_email",
                "notify_push",
                "notify_whatsapp",
                "sso",
                "api",
                "mcp",
                "ai"
              ]
            }
          },
          "limits": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "minimum": 0
            },
            "description": "users, outlets, ai_credits_month (contract 0028); apps, db_mb, files_mb, pdf_month, requests_month (contract 0057); records, storage_mb, api_calls_day (reported only); whole numbers. rate: traffic shaping (contract 0040 §9)",
            "properties": {
              "rate": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "rps",
                  "burst",
                  "max_wait_ms",
                  "max_waiting"
                ],
                "description": "Token bucket per tenant (contract 0040 §9): rps tokens a second, at most burst; a request without a token waits up to max_wait_ms, with at most max_waiting requests waiting; past that 429 rate_limited.",
                "properties": {
                  "rps": {
                    "type": "number",
                    "exclusiveMinimum": 0
                  },
                  "burst": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "max_wait_ms": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "max_waiting": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          },
          "flags": {
            "type": "object",
            "additionalProperties": {
              "type": "boolean"
            }
          }
        }
      }
    }
  }
}