#!/usr/bin/env python3
"""Beginner lab: map AI production symptoms to LLMOps responsibilities.
No external packages, model or API key required.
"""
from __future__ import annotations
import argparse

SCENARIOS = [
    ("Users receive HTTP 503 when traffic spikes and the inference queue is full.", "reliability", "Protect the service with admission control, capacity planning and graceful overload behavior."),
    ("The service is healthy but answers became worse after a prompt/model release.", "evaluation", "Infrastructure health cannot prove semantic quality; run representative quality/regression evaluations."),
    ("Nobody can tell which provider handled a costly request.", "observability", "Request-level telemetry and cost attribution should identify routing decisions and usage."),
    ("A team can call a restricted model even though policy says it should not.", "security/governance", "Authorization and policy must be enforced outside model instructions."),
    ("A simple summarization workload is always sent to the most expensive model.", "routing", "Routing policy can select an adequate backend based on task, risk, cost and availability."),
    ("The model server is running but the intended model is not ready to accept requests.", "serving", "Readiness must represent actual serving capability, not only process existence."),
    ("GPU memory is near its limit as concurrency grows.", "cost/capacity", "Capacity planning connects model size, concurrency and memory headroom to safe workload limits."),
]

CHOICES = ["serving", "routing", "reliability", "observability", "evaluation", "security/governance", "cost/capacity"]


def self_test() -> int:
    assert len(SCENARIOS) == 7
    assert {expected for _, expected, _ in SCENARIOS} == set(CHOICES)
    print("PASS scenario_count=7")
    print("PASS responsibilities=" + ",".join(CHOICES))
    print("PASS beginner_lab_no_external_dependencies")
    return 0


def interactive() -> int:
    print("LLMOps responsibility mapper")
    print("Choose one of:", ", ".join(CHOICES))
    score = 0
    for index, (scenario, expected, reason) in enumerate(SCENARIOS, 1):
        print(f"\n{index}. {scenario}")
        answer = input("Your classification: ").strip().lower()
        if answer == expected:
            score += 1
            print("✓ Correct.")
        else:
            print(f"△ Expected: {expected}")
        print("Why:", reason)
    print(f"\nScore: {score}/{len(SCENARIOS)}")
    print("Production lesson: classify the missing capability before choosing a product or changing production.")
    return 0


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--self-test", action="store_true")
    args = parser.parse_args()
    raise SystemExit(self_test() if args.self_test else interactive())
