"""
Practice: the scoring behind Lab 07, where an AI reviewer read 81 wrong plans (each one states a
planted bug as a design decision) and 77 right ones, and the same 81 bugs in the finished PRs' diffs.
You'll score a plan review, pair the plan stage with the diff stage, turn two catch counts into a
difference in points, and count how the approved plan changed which clean PRs got flagged.

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


def score_plan(kind: str, comments: list[dict]) -> bool:
    """Score one plan review.

    kind: "wrong" (the plan states a planted bug) or "right" (the agent's own plan, no planted bug).
    comments: the reviewer's comments, each {"severity": "bug" or "nit", "same": bool}, where
    "same" is the judge model's verdict: does this comment object to the planted decision?

    A wrong plan is caught when at least one comment, of any severity, is judged the same.
    A right plan is sent back when at least one comment has severity "bug" (the judge isn't asked:
    there's no planted bug to match). Return True for caught / sent back, False otherwise."""
    # TODO
    raise NotImplementedError


def paired_split(ids: set[str], in_plan: set[str], in_diff: set[str]) -> dict[str, int]:
    """Pair the two stages on the same bugs.

    ids: every bug compared. in_plan / in_diff: the ones caught at each stage.
    Return {"both": .., "only_plan": .., "only_diff": .., "neither": ..}; the four add up to len(ids)."""
    # TODO
    raise NotImplementedError


def points(ids: set[str], in_plan: set[str], in_diff: set[str]) -> int:
    """Plan minus diff, in percentage points: (caught in plan − caught in diff) / len(ids) × 100,
    rounded to a whole number (round half away from zero is fine; the lab's numbers never land on .5)."""
    # TODO
    raise NotImplementedError


def flag_changes(before: set[str], after: set[str]) -> dict[str, int]:
    """How a change to the reviewer's input moved its false alarms on clean PRs.

    before / after: the clean PRs flagged as buggy without and with the approved plan.
    Return {"before": .., "after": .., "new": .. (flagged only after), "no_longer": .. (only before)}."""
    # TODO
    raise NotImplementedError
