"""Membership-tier parameters for the shared optimization pipeline.""" from __future__ import annotations import os from dataclasses import dataclass from typing import Any @dataclass(frozen=True, slots=True) class TierConfig: tier: str deep_allowed: bool max_questions: int min_questions: int gap_threshold: float include_gap_report: bool TIER_CONFIGS: dict[str, TierConfig] = { "free": TierConfig( tier="free", deep_allowed=False, max_questions=0, min_questions=0, gap_threshold=5.0, include_gap_report=True, ), "vip": TierConfig( tier="vip", deep_allowed=True, max_questions=6, min_questions=2, gap_threshold=8.0, include_gap_report=True, ), } def tier_config_for_session(session: dict[str, Any]) -> TierConfig: """Resolve an explicit entitlement first, then the local development default.""" raw = str( (session.get("profile") or {}).get("entitlement_tier") or _default_tier() ).strip().lower() return TIER_CONFIGS.get(raw, TIER_CONFIGS["free"]) def _default_tier() -> str: """Use a local-only default tier when RESUME_AGENT_DEFAULT_TIER is configured. Explicit session entitlements always take precedence. Production deployments must leave this environment variable unset so the default remains ``free``. """ value = os.environ.get("RESUME_AGENT_DEFAULT_TIER", "free").strip().lower() return value if value in TIER_CONFIGS else "free"