{
  "$defs": {
    "BillingPeriod": {
      "description": "Billing period.",
      "oneOf": [
        {
          "enum": [
            "monthly",
            "quarterly",
            "annual",
            "triennial"
          ],
          "type": "string"
        },
        {
          "const": "biennial",
          "description": "Multi-year (typically 2-3 year with discount).",
          "type": "string"
        },
        {
          "const": "one_off",
          "description": "One-off / perpetual licence.",
          "type": "string"
        }
      ]
    },
    "IsoCurrency": {
      "description": "ISO 4217 currency code.",
      "pattern": "^[A-Z]{3}$",
      "type": "string"
    },
    "IsoDate": {
      "description": "ISO 8601 date (YYYY-MM-DD).",
      "format": "date",
      "type": "string"
    },
    "PathRef": {
      "description": "Path-based cross-reference relative to .corpospec/ root.\nPattern: `^[a-z0-9_-]+(/[a-z0-9_.-]+)+$`",
      "pattern": "^[a-z0-9_-]+(/[a-z0-9_.-]+)+$",
      "type": "string"
    },
    "PlanStatus": {
      "description": "Plan lifecycle.",
      "oneOf": [
        {
          "enum": [
            "draft",
            "active",
            "deprecated",
            "retired"
          ],
          "type": "string"
        },
        {
          "const": "sunset",
          "description": "Sunset (no new sales, existing customers grandfathered).",
          "type": "string"
        }
      ]
    },
    "PlanTier": {
      "description": "Plan tier (matches customer.rs::CustomerTier).",
      "oneOf": [
        {
          "enum": [
            "starter",
            "growth",
            "business",
            "enterprise",
            "strategic"
          ],
          "type": "string"
        },
        {
          "const": "free",
          "description": "Free / trial.",
          "type": "string"
        },
        {
          "const": "education",
          "description": "Education-discount tier.",
          "type": "string"
        },
        {
          "const": "non_profit",
          "description": "Non-profit-discount tier.",
          "type": "string"
        }
      ]
    },
    "PricingBracket": {
      "description": "Tiered pricing bracket.",
      "properties": {
        "from_units": {
          "description": "Minimum quantity for this bracket (inclusive).",
          "format": "double",
          "type": "number"
        },
        "to_units": {
          "description": "Maximum quantity (None ⇒ unbounded top).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "unit_price": {
          "description": "Unit price within this bracket.",
          "format": "double",
          "type": "number"
        }
      },
      "required": [
        "from_units",
        "unit_price"
      ],
      "type": "object"
    },
    "PricingDimension": {
      "description": "Per-unit pricing dimension.",
      "oneOf": [
        {
          "const": "flat",
          "description": "Flat fee.",
          "type": "string"
        },
        {
          "const": "per_seat",
          "description": "Per seat / user.",
          "type": "string"
        },
        {
          "const": "usage",
          "description": "Per usage unit (API call, MAU, GB).",
          "type": "string"
        },
        {
          "const": "tiered",
          "description": "Tiered (volume-bracket pricing).",
          "type": "string"
        },
        {
          "const": "volume",
          "description": "Volume (single rate for full quantity, descending).",
          "type": "string"
        },
        {
          "const": "custom",
          "description": "Custom (negotiated; per-line items).",
          "type": "string"
        }
      ]
    },
    "Semver": {
      "description": "Semantic version string (MAJOR.MINOR.PATCH).",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$",
      "type": "string"
    },
    "UsageLimit": {
      "description": "Usage cap (soft / hard / overage).",
      "properties": {
        "dimension": {
          "description": "Dimension label (e.g. \"seats\", \"monthly_active_users\",\n\"api_calls_per_month\", \"storage_gb\").",
          "type": "string"
        },
        "hard_limit": {
          "description": "Hard limit (enforced) — None ⇒ unlimited.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "overage_price_per_unit": {
          "description": "Overage price per extra unit (None ⇒ blocks).",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        },
        "soft_limit": {
          "description": "Soft limit (warning) — None ⇒ no soft limit.",
          "format": "double",
          "type": [
            "number",
            "null"
          ]
        }
      },
      "required": [
        "dimension"
      ],
      "type": "object"
    }
  },
  "$id": "https://corpospec.com/schemas/v0.16.0/pricing-plan.schema.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "Pricing plan record.",
  "properties": {
    "annual_escalation_pct": {
      "description": "Annual price-escalation pct (e.g. 5.0 for 5%/year on renewal).",
      "format": "double",
      "type": [
        "number",
        "null"
      ]
    },
    "base_price_per_period": {
      "description": "Base price per period (per dimensional unit if non-flat).",
      "format": "double",
      "type": "number"
    },
    "billing_period": {
      "$ref": "#/$defs/BillingPeriod"
    },
    "brackets": {
      "description": "Brackets for Tiered / Volume pricing (empty otherwise).",
      "items": {
        "$ref": "#/$defs/PricingBracket"
      },
      "type": "array"
    },
    "cancellation_notice": {
      "description": "Cancellation notice ISO 8601 duration.",
      "type": [
        "string",
        "null"
      ]
    },
    "currency": {
      "$ref": "#/$defs/IsoCurrency"
    },
    "description": {
      "type": "string"
    },
    "display_name": {
      "description": "Display name (e.g. \"Business — Annual 2026\").",
      "type": "string"
    },
    "effective_from": {
      "$ref": "#/$defs/IsoDate"
    },
    "effective_to": {
      "anyOf": [
        {
          "$ref": "#/$defs/IsoDate"
        },
        {
          "type": "null"
        }
      ]
    },
    "entity": {
      "$ref": "#/$defs/PathRef"
    },
    "features": {
      "description": "Feature gates included (capability flag strings).",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "id": {
      "$ref": "#/$defs/PathRef"
    },
    "lock_in_months": {
      "description": "Lock-in / minimum commitment period in months.",
      "format": "int32",
      "type": [
        "integer",
        "null"
      ]
    },
    "pricing_dimension": {
      "$ref": "#/$defs/PricingDimension"
    },
    "publicly_listed": {
      "description": "Whether the plan is publicly listed or sales-led only.",
      "type": "boolean"
    },
    "status": {
      "$ref": "#/$defs/PlanStatus"
    },
    "template_subscription_ref": {
      "anyOf": [
        {
          "$ref": "#/$defs/PathRef"
        },
        {
          "type": "null"
        }
      ],
      "description": "PathRef to legal templates (subscription agreement)."
    },
    "tier": {
      "$ref": "#/$defs/PlanTier"
    },
    "usage_limits": {
      "description": "Usage dimensions + limits.",
      "items": {
        "$ref": "#/$defs/UsageLimit"
      },
      "type": "array"
    },
    "version": {
      "$ref": "#/$defs/Semver",
      "description": "Plan version (Semver)."
    }
  },
  "required": [
    "id",
    "entity",
    "tier",
    "version",
    "display_name",
    "description",
    "publicly_listed",
    "currency",
    "billing_period",
    "pricing_dimension",
    "base_price_per_period",
    "usage_limits",
    "features",
    "status",
    "effective_from"
  ],
  "title": "PricingPlan",
  "type": "object",
  "x-corpospec-pillar": "market"
}