"""
Canonical labeled (query, expected_intent) dataset for intent-classification
evaluation, covering every label in services.hr_graph._VALID_INTENT_LABELS.

Consolidates and extends what existed before this dataset:
  - services/nlp_service.py's fast_classify has its own regression tests in
    tests/test_nlp_service.py (leave_balance/apply_leave/leave_status only,
    ~110 cases) — that file stays as-is; it tests the regex/keyword layer
    specifically, a different concern from this dataset.
  - tests/multi_prompt_report.py has ~113 hand-curated cases across
    apply_leave / leave_balance / leave_status / a leave_status "applied"
    variant / a negative control — reused here via the CATEGORIES import
    below rather than duplicated. That script's own docstring says the LLM
    classification fallback and non-leave intents are "not covered" — this
    dataset is what closes that gap.

New coverage added here, sourced two ways:
  - REAL query text pulled from the hr_query_logs table (grep the "source"
    field below for "real") — actual phrasing real users typed, re-labeled
    against the CURRENT intent taxonomy (the labels stored in that table
    predate/diverge from it — e.g. "regularisation"/"punch" aren't in
    _VALID_INTENT_LABELS at all, so those rows aren't usable here).
  - Reasoned, hand-authored examples for every intent with zero historical
    coverage in that table (payroll, recruitment, benefits, performance,
    employee_management, onboarding, training, compliance, job_description,
    interview_questions, skills, experience, general_hr, capabilities_inquiry,
    conversation_meta) — several of these overlap with cases already present
    in multi_prompt_report.py's own NEGATIVE_CONTROL_CASES list (written
    there to prove they're NOT a leave intent; reused here as POSITIVE
    examples for their actual intent — complementary use of the same
    queries, not duplication of purpose).

Each entry: {"query": str, "intent": str, "source": "real" | "authored"}.
"real" entries came from actual logged queries (hr_query_logs.query);
"authored" entries are reasoned examples for intents with no historical data.
"""

from tests.multi_prompt_report import CATEGORIES as _LEAVE_CATEGORIES

# ── Leave-related intents — reused from multi_prompt_report.py ────────────────
# apply_leave / leave_balance / leave_status already have ~93 cases there
# (Applied Leave Status also maps to leave_status). The negative-control
# category is intentionally excluded here — this dataset only needs positive
# (query, expected_intent) pairs; non_hr negative-control coverage lives in
# its own dedicated section below instead, sourced from real hr_query_logs
# non_hr rows plus the negative-control queries multi_prompt_report already
# curated for a different intent's negative check.
LEAVE_ACTION_CASES = [
    {"query": q, "intent": expected, "source": "authored"}
    for category, queries, expected in _LEAVE_CATEGORIES
    if expected is not None
    for q in queries
]

# ── leave_policy — real queries from hr_query_logs, re-labeled ────────────────
LEAVE_POLICY_CASES = [
    {"query": "What is the annual leave policy?", "intent": "leave_policy", "source": "real"},
    {"query": "What is the maternity leave policy?", "intent": "leave_policy", "source": "real"},
    {"query": "what is the sick leave policy", "intent": "leave_policy", "source": "real"},
    {"query": "What is FMLA?", "intent": "leave_policy", "source": "authored"},
    {"query": "What is the casual leave policy?", "intent": "leave_policy", "source": "authored"},
    {"query": "Tell me about the compensatory off policy", "intent": "leave_policy", "source": "authored"},
    {"query": "What is the process for leave encashment?", "intent": "leave_policy", "source": "authored"},
    {"query": "How does paternity leave work?", "intent": "leave_policy", "source": "authored"},
]

# ── leave_eligibility (HEL-280) ───────────────────────────────────────────────
# "Do I personally qualify for X?" — distinct from leave_policy ("what is the
# X policy", a general rule question) and from leave_balance ("how many X do I
# have left", a quantity question). The pairs below deliberately sit close to
# both neighbours, since that boundary is where misclassification is costly:
# routing one of these to apply_leave drags an employee who only asked a
# question into an actual leave application.
LEAVE_ELIGIBILITY_CASES = [
    {"query": "Am I eligible for casual leave?", "intent": "leave_eligibility", "source": "authored"},
    {"query": "am I eligible for maternity leave", "intent": "leave_eligibility", "source": "authored"},
    {"query": "Do I qualify for earned leave?", "intent": "leave_eligibility", "source": "authored"},
    {"query": "am I entitled to sick leave", "intent": "leave_eligibility", "source": "authored"},
    {"query": "Am I allowed short leave?", "intent": "leave_eligibility", "source": "authored"},
    {"query": "check my leave eligibility for earned leave", "intent": "leave_eligibility", "source": "authored"},
    {"query": "is sick leave something I qualify for", "intent": "leave_eligibility", "source": "authored"},
    {"query": "Am I eligible for sabbatical leave?", "intent": "leave_eligibility", "source": "authored"},
]

# ── cancel_leave ────────────────────────────────────────────────────────────
# "Withdraw a request I already submitted" — the costly neighbour here is
# apply_leave, since the two share most of their vocabulary and a misroute
# would start booking leave for someone trying to cancel it. Also kept apart
# from leave_status ("is it approved") which asks about the same request
# without wanting to change it. The bare "cancel my leave" forms matter:
# they're the vague inputs the cancel story calls out for disambiguation.
CANCEL_LEAVE_CASES = [
    {"query": "Cancel my leave", "intent": "cancel_leave", "source": "authored"},
    {"query": "Cancel my leave request for Friday", "intent": "cancel_leave", "source": "authored"},
    {"query": "cancel my leave", "intent": "cancel_leave", "source": "authored"},
    {"query": "withdraw my pending leave request", "intent": "cancel_leave", "source": "authored"},
    {"query": "I want to cancel the casual leave I applied for", "intent": "cancel_leave", "source": "authored"},
    {"query": "please cancel LR-2041", "intent": "cancel_leave", "source": "authored"},
    {"query": "cancel my approved leave for 6 Aug", "intent": "cancel_leave", "source": "authored"},
    {"query": "I no longer need the leave I requested", "intent": "cancel_leave", "source": "authored"},
    {"query": "take back my leave application", "intent": "cancel_leave", "source": "authored"},
    {"query": "Cancel LR-2041", "intent": "cancel_leave", "source": "authored"},
    {"query": "I don't want my leave anymore, please cancel it", "intent": "cancel_leave", "source": "authored"},
    {"query": "Cancel my sick leave", "intent": "cancel_leave", "source": "authored"},
    {"query": "Cancel my leave, my plans changed", "intent": "cancel_leave", "source": "authored"},
    {"query": "please cancel my casual leave for next Monday", "intent": "cancel_leave", "source": "authored"},
]

# ── non_hr — real queries from hr_query_logs, re-labeled ──────────────────────
# Deliberately includes short/garbled fragments — real users type these, and
# they're exactly the kind of input that used to get silently mishandled by
# the old check_hr_relevance gate (see e.g. "What is my leave" below, logged
# as non_hr in production despite obviously being HR-relevant — the old
# separate gate rejected it before the real intent classifier ever ran).
NON_HR_CASES = [
    {"query": "what is the capital of France", "intent": "non_hr", "source": "real"},
    {"query": "Explain quantum computing simply", "intent": "non_hr", "source": "real"},
    {"query": "How do I apply for a job?", "intent": "non_hr", "source": "authored"},
    {"query": "Write python code for a login page", "intent": "non_hr", "source": "authored"},
    {"query": "How do I become a software engineer?", "intent": "non_hr", "source": "authored"},
    {"query": "Give me a recipe for pasta", "intent": "non_hr", "source": "authored"},
    {"query": "What's the weather like today?", "intent": "non_hr", "source": "authored"},
]

# ── Conversational intents — real + authored ───────────────────────────────────
GREETING_CASES = [
    {"query": "Hi", "intent": "greeting", "source": "real"},
    {"query": "hey", "intent": "greeting", "source": "real"},
    {"query": "hello", "intent": "greeting", "source": "authored"},
    {"query": "good morning", "intent": "greeting", "source": "authored"},
    {"query": "how are you?", "intent": "greeting", "source": "authored"},
]

SMALL_TALK_CASES = [
    {"query": "thank you", "intent": "small_talk", "source": "authored"},
    {"query": "thanks, that was helpful", "intent": "small_talk", "source": "authored"},
    {"query": "great, appreciate it", "intent": "small_talk", "source": "authored"},
    {"query": "bye", "intent": "small_talk", "source": "authored"},
]

CAPABILITIES_INQUIRY_CASES = [
    {"query": "who are you", "intent": "capabilities_inquiry", "source": "real"},
    {"query": "what can you do?", "intent": "capabilities_inquiry", "source": "authored"},
    {"query": "tell me about yourself", "intent": "capabilities_inquiry", "source": "authored"},
    {"query": "are you an AI?", "intent": "capabilities_inquiry", "source": "authored"},
]

CONVERSATION_META_CASES = [
    {"query": "what was my last question?", "intent": "conversation_meta", "source": "authored"},
    {"query": "can you summarize what we've talked about?", "intent": "conversation_meta", "source": "authored"},
    {"query": "show my chat history", "intent": "conversation_meta", "source": "authored"},
]

# ── HR operational intents with zero historical coverage — hand-authored ──────
# Several reuse queries already present in multi_prompt_report.py's own
# NEGATIVE_CONTROL_CASES (written there to prove a query is NOT a leave
# intent) as POSITIVE examples of their real intent here — same queries,
# complementary purpose, not duplicated data-entry effort.
PAYROLL_CASES = [
    {"query": "What is our payroll processing schedule?", "intent": "payroll", "source": "authored"},
    {"query": "How is monthly payroll calculated?", "intent": "payroll", "source": "authored"},
    {"query": "When is the pay slip generated each month?", "intent": "payroll", "source": "authored"},
    {"query": "What deductions show up on a payslip?", "intent": "payroll", "source": "authored"},
]

SALARY_CASES = [
    {"query": "How is my salary calculated?", "intent": "salary", "source": "authored"},
    {"query": "What is latest aws devops salary in Singapore", "intent": "salary", "source": "authored"},
    {"query": "Salary range for python engineer according to India", "intent": "salary", "source": "authored"},
    {"query": "What is the CTC breakdown for a senior developer?", "intent": "salary", "source": "authored"},
    {"query": "How does an annual increment usually work?", "intent": "salary", "source": "authored"},
]

RECRUITMENT_CASES = [
    {"query": "What are the job openings currently?", "intent": "recruitment", "source": "authored"},
    {"query": "How do we screen candidates for a developer role?", "intent": "recruitment", "source": "authored"},
    {"query": "What should an offer letter include?", "intent": "job_description", "source": "authored"},
    {"query": "What's a good background-check process for new hires?", "intent": "recruitment", "source": "authored"},
]

BENEFITS_CASES = [
    {"query": "What health insurance benefits do we have?", "intent": "benefits", "source": "authored"},
    {"query": "How does the provident fund contribution work?", "intent": "benefits", "source": "authored"},
    {"query": "Calculate gratuity for 5 years of service", "intent": "benefits", "source": "authored"},
    {"query": "What perks and allowances are typically offered?", "intent": "benefits", "source": "authored"},
]

PERFORMANCE_CASES = [
    {"query": "What is a performance improvement plan?", "intent": "performance", "source": "authored"},
    {"query": "How do we conduct a performance review?", "intent": "performance", "source": "authored"},
    {"query": "What should go into a 360 feedback cycle?", "intent": "performance", "source": "authored"},
    {"query": "What KPIs should a sales manager be rated on?", "intent": "performance", "source": "authored"},
]

ATTENDANCE_CASES = [
    {"query": "How many working hours per day?", "intent": "attendance", "source": "authored"},
    {"query": "What is the work from home policy?", "intent": "attendance", "source": "authored"},
    {"query": "How do I check in for attendance?", "intent": "attendance", "source": "authored"},
    {"query": "What counts as a late arrival?", "intent": "attendance", "source": "authored"},
]

PUNCH_DETAILS_CASES = [
    {"query": "What time did I check in today?", "intent": "punch_details", "source": "authored"},
    {"query": "What's my shift timing today?", "intent": "punch_details", "source": "authored"},
    {"query": "How many hours did I work yesterday?", "intent": "punch_details", "source": "authored"},
    {"query": "Show me my punch details for last Friday", "intent": "punch_details", "source": "authored"},
]

ATTENDANCE_EXPLAIN_CASES = [
    {"query": "Why was I marked late today?", "intent": "attendance_explain", "source": "authored"},
    {"query": "Explain why my attendance shows absent on Monday", "intent": "attendance_explain", "source": "authored"},
    {"query": "Why does it show missing punch for yesterday?", "intent": "attendance_explain", "source": "authored"},
    {"query": "Why was I marked half day on the 10th?", "intent": "attendance_explain", "source": "authored"},
]

REGULARISATION_CASES = [
    {"query": "I want to apply for attendance regularization", "intent": "regularisation", "source": "authored"},
    {"query": "Regularise my attendance for yesterday", "intent": "regularisation", "source": "authored"},
    {"query": "Missed punch regularisation for Monday", "intent": "regularisation", "source": "authored"},
    {"query": "Can I regularize my attendance", "intent": "regularisation", "source": "authored"},
]

EMPLOYEE_MANAGEMENT_CASES = [
    {"query": "How to handle a disciplinary case?", "intent": "employee_management", "source": "authored"},
    {"query": "What's the process for a legal layoff?", "intent": "employee_management", "source": "authored"},
    {"query": "How should a grievance complaint be escalated?", "intent": "employee_management", "source": "authored"},
    {"query": "What does a standard exit process look like?", "intent": "employee_management", "source": "authored"},
]

ONBOARDING_CASES = [
    {"query": "Tell me about the onboarding process", "intent": "onboarding", "source": "authored"},
    {"query": "What's on a new hire's first-day checklist?", "intent": "onboarding", "source": "authored"},
    {"query": "How long is the probation period usually?", "intent": "onboarding", "source": "authored"},
]

TRAINING_CASES = [
    {"query": "What training programs are available for managers?", "intent": "training", "source": "authored"},
    {"query": "How do we run a skill-gap analysis for the team?", "intent": "training", "source": "authored"},
    {"query": "What does a good L&D plan look like?", "intent": "training", "source": "authored"},
]

COMPLIANCE_CASES = [
    {"query": "What are GDPR requirements for HR data?", "intent": "compliance", "source": "authored"},
    {"query": "What should an employment contract legally include?", "intent": "compliance", "source": "authored"},
    {"query": "What's involved in a statutory HR audit?", "intent": "compliance", "source": "authored"},
]

JOB_DESCRIPTION_CASES = [
    {"query": "JD for a product manager?", "intent": "job_description", "source": "authored"},
    {"query": "Write a job description for a backend engineer", "intent": "job_description", "source": "authored"},
    {"query": "What responsibilities belong in a QA lead role profile?", "intent": "job_description", "source": "authored"},
]

INTERVIEW_QUESTIONS_CASES = [
    {"query": "Interview questions for a frontend developer?", "intent": "interview_questions", "source": "authored"},
    {"query": "What screening questions suit a QA automation role?", "intent": "interview_questions", "source": "authored"},
    {"query": "Give me an interview guide for a sales hire", "intent": "interview_questions", "source": "authored"},
]

SKILLS_CASES = [
    {"query": "Skills required for a QA automation engineer", "intent": "skills", "source": "authored"},
    {"query": "What skills should a python developer have", "intent": "skills", "source": "authored"},
    {"query": "Key skills for an AI engineer", "intent": "skills", "source": "authored"},
    {"query": "What competencies should a data analyst possess", "intent": "skills", "source": "authored"},
]

EXPERIENCE_CASES = [
    {"query": "Experience needed for an AI engineer", "intent": "experience", "source": "authored"},
    {"query": "Experience needed for senior developer?", "intent": "experience", "source": "authored"},
    {"query": "Years of experience for a senior QA", "intent": "experience", "source": "authored"},
]

GENERAL_HR_CASES = [
    {"query": "Latest HR hiring trends", "intent": "general_hr", "source": "authored"},
    {"query": "How should we structure our HR department?", "intent": "general_hr", "source": "authored"},
    {"query": "What HR metrics or KPIs should we track?", "intent": "general_hr", "source": "authored"},
    {"query": "What are the current recruitment market trends", "intent": "general_hr", "source": "authored"},
]

# ── Full dataset ────────────────────────────────────────────────────────────
INTENT_EVAL_DATASET = (
    LEAVE_ACTION_CASES
    + LEAVE_POLICY_CASES
    + LEAVE_ELIGIBILITY_CASES
    + CANCEL_LEAVE_CASES
    + NON_HR_CASES
    + GREETING_CASES
    + SMALL_TALK_CASES
    + CAPABILITIES_INQUIRY_CASES
    + CONVERSATION_META_CASES
    + PAYROLL_CASES
    + SALARY_CASES
    + RECRUITMENT_CASES
    + BENEFITS_CASES
    + PERFORMANCE_CASES
    + ATTENDANCE_CASES
    + PUNCH_DETAILS_CASES
    + ATTENDANCE_EXPLAIN_CASES
    + REGULARISATION_CASES
    + EMPLOYEE_MANAGEMENT_CASES
    + ONBOARDING_CASES
    + TRAINING_CASES
    + COMPLIANCE_CASES
    + JOB_DESCRIPTION_CASES
    + INTERVIEW_QUESTIONS_CASES
    + SKILLS_CASES
    + EXPERIENCE_CASES
    + GENERAL_HR_CASES
)
