"""
Practice: the checks behind Lab 18's script 01, where an assistant grows its own test suite from
what learners ask. You'll draw the "is it new?" line, count how much review each kind of memory
costs, score a reviewer beyond luck, and find the tests a document change may have broken.

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


def threshold_rates(covered: list[float], new: list[float], tau: float) -> dict:
    """covered: for each message a starting test already covers, its similarity to the closest test.
    new: the same for messages no test covers. A message counts as new when its similarity is below tau.
    Return:
      repeats  covered messages called repeats (similarity >= tau)
      fresh    new messages called new (similarity < tau)
      sent_on  all messages called new, which go on to the test writer"""
    # TODO
    raise NotImplementedError


def reviewed(messages: list[tuple[int, str]], starting: set[str], remember: str) -> int:
    """How many tests go to review over the replay.

    messages: (day, question) in order. Two messages with the same question text mean the same thing
    (a stand-in for similarity above the line). starting: questions the starting tests cover.
    Review happens at the end of each week (days 0-6 are week 1, 7-13 week 2, ...), and the reviewer
    approves every test it's sent.

    remember decides what a message is compared with:
      "nothing"   nothing: every message becomes a test for review
      "approved"  the starting tests and the tests approved at earlier weekly reviews
      "seen"      also every earlier message already judged new (a candidate), approved or still waiting"""
    # TODO
    raise NotImplementedError


def kappa(a: list[bool], b: list[bool]) -> float:
    """Cohen's kappa for two yes/no raters: (agreement - chance agreement) / (1 - chance agreement).
    Chance agreement = P(a yes) * P(b yes) + P(a no) * P(b no). If chance agreement is 1, return 0.0."""
    # TODO
    raise NotImplementedError


def to_recheck(tests: list[dict], revised: set[str], day: int) -> list[str]:
    """tests: {"id", "intent", "added_day"}. revised: the questions (intents) whose answer a document
    revision changed on `day`. Return the ids of tests written before that day for one of those
    questions, in the order given: each is a claim about the old document."""
    # TODO
    raise NotImplementedError
