"""Improvement-discovery phase SSOT: lens enum and cap constants.

profile / brief skill / validator / wizard MUST import from this module.
Re-defining the enum anywhere else violates the single-reference-point rule
and is rejected by tests/test_okstra_improvement_lenses.py.
"""
from __future__ import annotations

LENSES: tuple[str, ...] = (
    "performance",
    "security",
    "readability",
    "architecture",
    "test-coverage",
    "dx",
    "observability",
    "accessibility",
)

DEFAULT_CANDIDATE_CAP = 8
ABSOLUTE_CANDIDATE_CAP = 12
MIN_PRIORITY_LENSES = 1
MAX_PRIORITY_LENSES = 4

# report-writer is the AUTHOR of the final report; it never produces source
# findings. validators reject `report-writer:<id>` entries in Source workers.
SOURCE_WORKERS: tuple[str, ...] = ("claude", "codex", "antigravity")


def is_valid_lens(value: str) -> bool:
    return value in LENSES


def is_valid_lens_subset(values: list[str]) -> bool:
    if not (MIN_PRIORITY_LENSES <= len(values) <= MAX_PRIORITY_LENSES):
        return False
    if len(set(values)) != len(values):
        return False
    return all(v in LENSES for v in values)


def is_within_candidate_cap(count: int, *, brief_cap: int | None) -> bool:
    cap = brief_cap if brief_cap is not None else DEFAULT_CANDIDATE_CAP
    if cap < 1 or cap > ABSOLUTE_CANDIDATE_CAP:
        return False
    return 1 <= count <= cap
