"""
Practice: measure prompt changes on the questions you tune on AND on held-out ones (Lab 05, Exercise 9),
on the recorded runs from the video.

Fill in the TODOs, then run the tests:
    pytest test_tuning_practice.py        (locally)
or press "Run tests" on the chapter page.

A run is {question id: {check name: 1.0 or 0.0}}. Each prompt was run 3 times on each question set.
"""


def passes(checks: dict[str, float]) -> bool:
    """The gate's per-question rule: a question passes only if every one of its checks scored 1.

    TODO 1
    """
    return True


def score(run: dict[str, dict[str, float]]) -> int:
    """How many questions passed in one run.

    TODO 2
    """
    return 0


def mean_gain(before: list[dict], after: list[dict]) -> float:
    """The average score of the `after` runs minus the average score of the `before` runs,
    rounded to 2 decimals. Average over runs, because answers wobble.

    TODO 3
    """
    return 0.0


def moved(before: list[dict], after: list[dict]) -> dict[str, tuple[int, int]]:
    """The questions whose number of passing runs changed: {id: (runs passed before, runs passed after)}.
    Read these before believing a score: which questions moved, and why?

    TODO 4
    """
    return {}


def verdict(test_gain: float, new_gain: float, min_gain: float = 0.5) -> str:
    """Decide what a prompt change did, from its gain on the exam it was tuned on and on new questions:
      - "carries over"   if new_gain >= min_gain
      - "fits the test"  if only test_gain >= min_gain
      - "no effect"      otherwise (a rule that helps nothing: delete it)

    TODO 5
    """
    return "carries over"
