{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://getzero.dev/contracts/zero.pricing_contract.v1.schema.json",
  "title": "ZERO Pricing Contract v1",
  "description": "Machine-readable product, pricing, fee, and execution-boundary contract for public and operator pricing surfaces.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "schema",
    "kind",
    "public",
    "status",
    "generated_at",
    "source_refs",
    "execution_boundary",
    "products",
    "revenue_model",
    "blockers"
  ],
  "properties": {
    "schema_version": { "const": "zero.pricing_contract.v1" },
    "schema": { "const": "https://getzero.dev/contracts/zero.pricing_contract.v1.schema.json" },
    "kind": { "const": "pricing_contract" },
    "public": { "const": true },
    "status": { "enum": ["contract_ready", "degraded"] },
    "generated_at": { "type": "string", "format": "date-time" },
    "source_refs": {
      "type": "array",
      "minItems": 3,
      "uniqueItems": true,
      "items": { "type": "string", "minLength": 8 }
    },
    "execution_boundary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "pricing_contract_can_execute_orders",
        "auto_execution_enabled",
        "paper_can_submit_exchange_orders",
        "paper_can_move_funds",
        "live_trading_subscription_required",
        "live_execution_requires_builder_fee_approval",
        "fee_revenue_requires_builder_fill_reconciliation",
        "stripe_gates_intelligence_during_growth_mode"
      ],
      "properties": {
        "pricing_contract_can_execute_orders": { "const": false },
        "auto_execution_enabled": { "const": false },
        "paper_can_submit_exchange_orders": { "const": false },
        "paper_can_move_funds": { "const": false },
        "live_trading_subscription_required": { "const": false },
        "live_execution_requires_builder_fee_approval": { "const": true },
        "fee_revenue_requires_builder_fill_reconciliation": { "const": true },
        "stripe_gates_intelligence_during_growth_mode": { "const": false }
      }
    },
    "products": {
      "type": "object",
      "additionalProperties": false,
      "required": ["paper_runtime", "hosted_pro", "credits", "intelligence_api", "autonomy_fee"],
      "properties": {
        "paper_runtime": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sku", "label", "price_usd", "billing", "exchange_orders", "custody", "charged_on_refusals", "proof_required"],
          "properties": {
            "sku": { "const": "paper_runtime" },
            "label": { "type": "string" },
            "price_usd": { "const": 0 },
            "billing": { "const": "free_forever" },
            "exchange_orders": { "const": false },
            "custody": { "const": false },
            "charged_on_refusals": { "const": false },
            "proof_required": { "$ref": "#/$defs/string_list" }
          }
        },
        "hosted_pro": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sku", "label", "monthly_usd", "billing", "status", "live_trading_subscription_required", "features"],
          "properties": {
            "sku": { "const": "hosted_pro" },
            "label": { "type": "string" },
            "monthly_usd": { "type": "number", "minimum": 0 },
            "billing": { "const": "subscription" },
            "status": { "enum": ["growth_mode_free", "paid"] },
            "live_trading_subscription_required": { "const": false },
            "features": { "$ref": "#/$defs/string_list" }
          }
        },
        "credits": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sku", "label", "billing", "growth_grant_credits", "free_daily_evals", "never_expire", "packages"],
          "properties": {
            "sku": { "const": "credits" },
            "label": { "type": "string" },
            "billing": { "const": "one_time" },
            "growth_grant_credits": { "type": "integer", "minimum": 0 },
            "free_daily_evals": { "type": "integer", "minimum": 0 },
            "never_expire": { "type": "boolean" },
            "packages": {
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": false,
                "required": ["id", "label", "credits", "price_usd", "billing"],
                "properties": {
                  "id": { "type": "string" },
                  "label": { "type": "string" },
                  "credits": { "type": "integer", "minimum": 1 },
                  "price_usd": { "type": "number", "minimum": 0 },
                  "billing": { "const": "one_time" }
                }
              }
            }
          }
        },
        "intelligence_api": {
          "type": "object",
          "additionalProperties": false,
          "required": ["sku", "label", "billing", "growth_mode_realtime_enabled", "stripe_required_during_growth_mode", "plans"],
          "properties": {
            "sku": { "const": "intelligence_api" },
            "label": { "type": "string" },
            "billing": { "const": "growth_mode_access" },
            "growth_mode_realtime_enabled": { "const": true },
            "stripe_required_during_growth_mode": { "const": false },
            "plans": {
              "type": "object",
              "required": ["free", "pro", "scale", "api"],
              "additionalProperties": {
                "type": "object",
                "additionalProperties": false,
                "required": ["id", "realtime", "monthly_units", "retention_days", "sla", "stripe_required_during_growth_mode"],
                "properties": {
                  "id": { "enum": ["free", "pro", "scale", "api"] },
                  "realtime": { "type": "boolean" },
                  "monthly_units": { "type": "integer", "minimum": 0 },
                  "retention_days": { "type": "integer", "minimum": 0 },
                  "sla": { "enum": ["none", "best_effort", "standard", "enterprise"] },
                  "stripe_required_during_growth_mode": { "const": false }
                }
              }
            }
          }
        },
        "autonomy_fee": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "sku",
            "label",
            "billing",
            "requested_fee_tenth_bps",
            "requested_fee_bps",
            "cap_tenth_bps",
            "cap_bps",
            "paper_fee_usd",
            "charged_on_refusals",
            "requires_main_wallet_builder_fee_approval",
            "requires_active_builder_order_attribution",
            "requires_no_secret_fill_reconciliation",
            "receipt_surface",
            "public_readback"
          ],
          "properties": {
            "sku": { "const": "autonomy_fee" },
            "label": { "type": "string" },
            "billing": { "const": "per_live_fill" },
            "requested_fee_tenth_bps": { "type": "integer", "minimum": 1, "maximum": 100 },
            "requested_fee_bps": { "type": "number", "minimum": 0, "maximum": 10 },
            "cap_tenth_bps": { "type": "integer", "minimum": 1, "maximum": 100 },
            "cap_bps": { "type": "number", "minimum": 0, "maximum": 10 },
            "paper_fee_usd": { "const": 0 },
            "charged_on_refusals": { "const": false },
            "requires_main_wallet_builder_fee_approval": { "const": true },
            "requires_active_builder_order_attribution": { "const": true },
            "requires_no_secret_fill_reconciliation": { "const": true },
            "receipt_surface": { "const": "/studio#fee-statement" },
            "public_readback": { "const": "/api/runtime/capability-state" }
          }
        }
      }
    },
    "revenue_model": {
      "type": "array",
      "minItems": 3,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["rail", "status", "proof_required"],
        "properties": {
          "rail": { "type": "string" },
          "status": { "enum": ["available", "growth_mode_access", "proof_required", "future"] },
          "revenue_claim_allowed_without_reconciliation": { "type": "boolean" },
          "proof_required": { "$ref": "#/$defs/string_list" }
        }
      }
    },
    "blockers": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "severity", "description"],
        "properties": {
          "id": { "type": "string" },
          "severity": { "type": "string" },
          "description": { "type": "string", "minLength": 20 }
        }
      }
    }
  },
  "$defs": {
    "string_list": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    }
  }
}
