{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "reversa-pricing-profile-v1.1",
  "title": "Reversa Pricing Profile",
  "description": "Billing profile generated by the reversa-pricing-profile agent, consumed by the reversa-pricing-size and reversa-pricing-estimate agents.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "created_at",
    "country",
    "currency",
    "seniority",
    "hourly_rate",
    "hourly_rate_mode",
    "margin_percent",
    "tax_regime",
    "tax_factor",
    "tax_factor_kind",
    "tax_factor_source",
    "includes_vat",
    "vat_pass_through_warning",
    "tax_regime_confidence",
    "pricing_models"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "1.1",
      "description": "Schema version. v1 = 1.0."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 UTC timestamp of the profile creation or last regeneration."
    },
    "country": {
      "type": "string",
      "pattern": "^[A-Z]{2}$",
      "description": "ISO 3166-1 alpha-2 country code of the operating country."
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$",
      "description": "ISO 4217 local currency code."
    },
    "seniority": {
      "type": "string",
      "enum": ["junior", "mid", "senior", "staff_lead", "principal"]
    },
    "hourly_rate": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Net hourly rate in local currency."
    },
    "hourly_rate_mode": {
      "type": "string",
      "enum": ["direto", "derivado"],
      "description": "direto = user provided the value directly; derivado = calculated from monthly_target_income and billable_hours_per_month."
    },
    "monthly_target_income": {
      "type": ["number", "null"],
      "exclusiveMinimum": 0,
      "description": "Desired net monthly income in local currency. Required when hourly_rate_mode = derivado, null otherwise."
    },
    "billable_hours_per_month": {
      "type": ["number", "null"],
      "minimum": 1,
      "maximum": 720,
      "description": "Estimated billable hours per month. Required when hourly_rate_mode = derivado, null otherwise."
    },
    "margin_percent": {
      "type": "number",
      "minimum": 0,
      "maximum": 200,
      "description": "Project markup over direct cost, as a percentage. The historical field name margin_percent is kept for compatibility."
    },
    "tax_regime": {
      "type": "string",
      "minLength": 1,
      "description": "Canonical key of the tax regime documented in references/tax-regimes.md, or 'outro'."
    },
    "tax_factor": {
      "type": "number",
      "minimum": 0,
      "maximum": 1,
      "description": "Approximate tax factor associated with the regime. Applied by the Pricer over direct cost."
    },
    "tax_factor_kind": {
      "type": "string",
      "enum": ["effective_reserve_estimate", "statutory_proxy", "not_computed"],
      "description": "Factor type: approximate effective reserve, simplified statutory proxy, or tax not computed."
    },
    "tax_factor_source": {
      "type": "string",
      "minLength": 1,
      "description": "Public source or internal catalog entry that justifies the approximate factor."
    },
    "includes_vat": {
      "type": "boolean",
      "description": "Indicates whether the factor combines income tax/contribution with VAT/IVA/ISS itemized on the invoice."
    },
    "vat_pass_through_warning": {
      "type": "boolean",
      "description": "Indicates whether the estimate should warn that part of the tax may be passed through to the client and does not necessarily reduce margin."
    },
    "tax_regime_confidence": {
      "type": "string",
      "enum": ["high", "low"],
      "description": "high = user chose explicitly; low = fallback suggestion or 'outro'."
    },
    "pricing_models": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "escopo_fechado",
          "time_and_materials",
          "sprint",
          "retainer",
          "valor_fixo_por_entrega"
        ]
      }
    },
    "client_profile": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string",
        "enum": [
          "microempresa",
          "pequena_empresa",
          "media_empresa",
          "enterprise",
          "governo",
          "cliente_internacional"
        ]
      },
      "description": "May be empty when the user chooses to skip this question."
    },
    "billing_currency": {
      "type": ["string", "null"],
      "pattern": "^[A-Z]{3}$",
      "description": "Currency in which the user bills the client when different from currency. null when billing in local currency."
    },
    "exchange_rate_to_local": {
      "type": ["number", "null"],
      "exclusiveMinimum": 0,
      "description": "Manual exchange rate: how many units of currency equal 1 unit of billing_currency. null when not billing in foreign currency."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "hourly_rate_mode": { "const": "derivado" }
        }
      },
      "then": {
        "required": ["monthly_target_income", "billable_hours_per_month"]
      }
    }
  ]
}
