# File: src/noveler/domain/utils/line_length_classifier.py
# Purpose: Classify line lengths against warn/critical thresholds.
# Context: Allows tests to verify boundary behaviour (e.g., 80/120) without enforcing wrapping.
"""
Line length classification utility for domain analysis.

Purpose:
    Classify line lengths into severity categories (ok, warn, critical) based on
    configurable thresholds, without enforcing any policy or side-effects.

Side Effects:
    None (pure utility functions).
"""
from __future__ import annotations

from typing import Literal

Severity = Literal["ok","warn","critical"]


def classify_length(length: int, warn: int = 80, critical: int = 120) -> Severity:
    """
    Classify a line length into severity category based on thresholds.

    Purpose:
        Categorize numeric line length against configurable warning and critical
        thresholds for use in analysis and testing without enforcing policies.

    Args:
        length: Measured length (non-negative integer).
        warn: Lower threshold (inclusive) for warnings (default 80).
        critical: Upper threshold (inclusive) for warnings; above triggers critical (default 120).

    Returns:
        Severity: 'ok' if length < warn; 'warn' if warn <= length <= critical;
        'critical' if length > critical.

    Side Effects:
        None (pure function).
    """
    if length < warn:
        return "ok"
    if length <= critical:
        return "warn"
    return "critical"
