Answer prose round 1: 0 🔴, 16 🟡 (0 misread); name the offline deciders and runs, and fix the help, the decision and the docstrings

This commit is contained in:
2026-11-17 10:22:54 +01:00
parent 155a65117c
commit 5f098aa315
6 changed files with 82 additions and 56 deletions
+22 -14
View File
@@ -7,7 +7,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from transcript_archive.outcomes import ANSWERED, FINISHED, INTERRUPTED, UNFINISHED
from claude_code.entries import AssistantTurn, HumanTurn, Text, ToolCall
from judge_replay.offline import classifier, decision_table, evaluate, final_message, folds_of, METHODS, offline_report, question_mark, Sample
from judge_replay.offline import classifier, decision_table, evaluate, final_message, folds_of, LEARNERS, offline_report, question_mark, RULES, Sample
def turn(*parts):
@@ -56,12 +56,12 @@ class Classifier(unittest.TestCase):
done = [sample(FINISHED, f"merged pull request {n} and removed the worktree, no findings left") for n in range(12)]
return classifier([*asking, *done, *extra])
def test_decides_a_message_like_each_kind_it_learned_and_nothing_else(self):
def test_decides_a_message_like_each_kind_it_learned(self):
decide = self.trained()
self.assertEqual(decide("I recommend option 3; tell me which you want"), INTERRUPTED)
self.assertEqual(decide("merged pull request 99 and removed the worktree, no findings left"), FINISHED)
def test_abstains_on_every_message_where_it_learned_no_interrupt_or_no_other_kind(self):
def test_abstains_where_it_learned_no_interrupt_or_no_other_kind(self):
self.assertIsNone(classifier([sample(FINISHED, "merged")])("merged"))
self.assertIsNone(classifier([sample(INTERRUPTED, "which?")])("which?"))
self.assertIsNone(classifier([])("anything"))
@@ -91,25 +91,33 @@ class Report(unittest.TestCase):
def samples(self):
return [sample(FINISHED, "Merged."), sample(FINISHED, "Merged. Release 1.0.0 is ready to cut."), sample(INTERRUPTED, "I recommend merging."), sample(INTERRUPTED, "Merged.")]
def test_names_each_method_and_counts_what_it_decided_and_missed_by_kind(self):
text = offline_report("claude-opus-5-5", self.samples(), {"decision table": decision_table})
self.assertIn("Replayed 4 archived verdicts of claude-opus-5-5 projects offline, nothing sent to an outside service: 2 finished, 2 interrupt.", text)
self.assertIn("decision table, on held-out folds: decided 3 of 4: finished 2 (archived interrupt 1), interrupt 1. Missed interrupts: 1.", text)
self.assertIn("does not decide finished with no missed interrupt", text)
def test_counts_what_a_rule_decided_on_the_whole_archive_and_missed_by_kind(self):
text = offline_report("claude-opus-5-5", self.samples(), {"decision table": decision_table}, {})
self.assertIn("Replayed 4 archived verdicts of claude-opus-5-5 projects offline, without sending anything to an outside service. The archive gives them as 2 finished, 2 interrupt.", text)
self.assertIn("decision table, on the whole archive: decided 3 of 4: finished 2 (of these, archived interrupt 1), interrupt 1. Missed interrupts: 1.", text)
self.assertIn("decision table, on the whole archive, does not decide finished with no missed interrupt: it decided 1 archived interrupt(s) as finished.", text)
def test_says_a_method_that_decided_a_kind_and_missed_no_interrupt_decides_that_kind(self):
text = offline_report("claude-opus-5-5", [sample(FINISHED, "Merged."), sample(INTERRUPTED, "I recommend merging.")], {"decision table": decision_table})
text = offline_report("claude-opus-5-5", [sample(FINISHED, "Merged."), sample(INTERRUPTED, "I recommend merging.")], {"decision table": decision_table}, {})
self.assertIn("Missed interrupts: 0.", text)
self.assertIn("decides finished with no missed interrupt: 1 of 1 finished", text)
self.assertIn("decision table, on the whole archive, decides finished with no missed interrupt: 1 of 1 finished.", text)
def test_runs_a_method_that_learns_once_for_each_fold_and_once_on_the_latest_fifth(self):
def test_runs_a_learner_once_for_each_fold_and_once_on_the_latest_fifth_and_a_rule_only_on_the_whole_archive(self):
samples = [sample(INTERRUPTED if n % 2 else FINISHED, "I recommend it" if n % 2 else "merged it") for n in range(20)]
text = offline_report("m", samples, {"classifier": classifier}, folds=4)
text = offline_report("m", samples, {"rule": question_mark}, {"classifier": classifier}, folds=4)
self.assertIn("classifier, on held-out folds: decided", text)
self.assertIn("classifier, on the latest fifth after learning from the rest: decided", text)
self.assertIn("rule, on the whole archive: decided 20 of 20", text)
self.assertNotIn("rule, on held-out", text)
self.assertNotIn("rule, on the latest fifth", text)
def test_the_shipped_methods_are_the_one_rule_the_table_and_the_classifier(self):
self.assertEqual(list(METHODS), ["a question mark", "decision table", "classifier"])
def test_counts_the_verdicts_it_skipped_only_where_it_skipped_some(self):
self.assertNotIn("Skipped", offline_report("m", self.samples(), {}, {}))
self.assertIn("Skipped 2 verdicts whose transcript could not be read.", offline_report("m", self.samples(), {}, {}, skipped=2))
def test_the_shipped_methods_are_the_question_mark_rule_the_table_and_the_classifier(self):
self.assertEqual(list(RULES), ['"?" rule', "decision table"])
self.assertEqual(list(LEARNERS), ["classifier"])
if __name__ == "__main__":