bursar.config module
Pricing config loading with pydantic validation and expression validation.
exception bursar.config.ConfigError
Bases: Exception
Raised on config parsing or validation failures.
class bursar.config.PricingConfig(*, version: ~typing.Literal[1] = 1, models: dict[str, str], tools: dict[str, str] = , search: str | None = None, cache: str | None = None, min_balance: ~typing.Annotated[~decimal.Decimal, ~annotated_types.Ge(ge=0)] = Decimal('0'), signup_bonus: ~typing.Annotated[int, ~annotated_types.Ge(ge=0)] = 50, fixed: dict[str, ~decimal.Decimal] = , plans: dict[str, ~bursar.interface.models.PlanDefinition] | None = None, tiers: dict[str, ~bursar.interface.models.TierDefinition] | None = None)
Bases: BaseModel
Validated pricing configuration.
version must be 1 (current/latest). Optional plans key carries
subscription-plan definitions for allowance-based features.
cache : str | None
fixed : dict[str, Decimal]
min_balance : Decimal
model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
models : dict[str, str]
plans : dict[str, PlanDefinition] | None
search : str | None
signup_bonus : int
tiers : dict[str, TierDefinition] | None
tools : dict[str, str]
validate_expressions() → PricingConfig
Validate all expression strings in the config.
Variable names are checked against the canonical metric set
(METRIC_VARIABLES) so a typo’d variable fails here, at config-load
time, rather than at first runtime evaluation (M5).
classmethod validate_fixed_non_negative(value: dict[str, Decimal]) → dict[str, Decimal]
Each fixed-cost value must be >= 0 (Decimal dict values need a validator).
classmethod validate_structure(data: Any) → Any
Validate top-level structure before field validation.
version : Literal[1]
bursar.config.load_config_from_dict(data: dict) → PricingConfig
Load and validate a pricing config from a dictionary.
Args: : data: Dictionary representation of a pricing config.
Returns: : Validated PricingConfig instance.
Raises: : ConfigError: If the config structure or expressions are invalid.