#!/usr/bin/env python3
"""
judgment.py — the professional-judgment refusal boundary for the auditor skill. Mirrors
skills/accounting/compliance.py's JUDGMENT_REFUSALS + judge() shape. Every mechanical tool in
rollforward.py / liabilities.py / leadsheet.py computes an EXACT arithmetic fact; none of them
render an opinion. These are the fieldwork questions this pack must never fake a verdict on.
"""

JUDGMENT_REFUSALS: list[tuple[str, str]] = [
    (
        "Is this rollforward reconciling difference material and does it need to be adjusted?",
        "Materiality is a function of the entity's size, the nature of the account, and "
        "qualitative context — the same absolute difference can be waived in one engagement "
        "and require adjustment in another. No formula substitutes for that judgment.",
    ),
    (
        "Is the unrecorded-liabilities search population complete — did we identify every "
        "post-period disbursement that should have been tested?",
        "Completeness of a search population is an assertion about the underlying records "
        "(cutoff, access to the full disbursements ledger, scope of the search window) that "
        "requires auditor judgment and corroborating procedures, not a count this tool can "
        "certify from the population it was handed.",
    ),
    (
        "Should the threshold used in the search for unrecorded liabilities be lowered for "
        "this engagement?",
        "The threshold is a risk-based judgment tied to overall and performance materiality "
        "for this specific engagement — it is a professional determination, not a computed "
        "output.",
    ),
    (
        "Does this trial-balance-to-lead-sheet mapping reflect the correct financial-statement "
        "presentation?",
        "Whether a given grouping is the RIGHT presentation (vs. merely a consistent one) is "
        "a classification and disclosure judgment under the applicable framework, not a "
        "mechanical tie-out fact.",
    ),
]


def judge(question: str) -> dict:
    """Return a refusal for any professional-judgment question. Never fakes an opinion."""
    q_lower = question.strip().lower()
    for jq, reason in JUDGMENT_REFUSALS:
        if jq.strip().lower() == q_lower:
            return {"refuse": reason}
    return {
        "refuse": (
            "This question requires professional audit judgment. No mechanical rollforward, "
            "search-threshold, or tie-out check can substitute for that assessment."
        )
    }
