From 7933f37bf0a0148cbbc1de6839566a402f9f7422 Mon Sep 17 00:00:00 2001 From: Yif-Yang Date: Sat, 18 Jul 2026 17:28:22 +0000 Subject: [PATCH] test(sleep): assert fractional candidate score --- tests/test_sleep_engine.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_sleep_engine.py b/tests/test_sleep_engine.py index f3fb4e4..36cb88b 100644 --- a/tests/test_sleep_engine.py +++ b/tests/test_sleep_engine.py @@ -1333,6 +1333,8 @@ class TestVerifierDiscipline(unittest.TestCase): """Gate must reject an edit that partially degrades held-out (1.0→0.5), not just all-or-nothing collapses. Train improves (0.0→1.0) which makes the regression easy to miss — the gate catches it anyway.""" + from skillopt_sleep.replay import aggregate_scores, replay_batch + be = MockFractionalDegradationBackend() train = TaskRecord(id="t3", project="/p", intent="train", reference="ABC", reference_kind="exact", tags=["rule:__reward_hacking__"], split="train") @@ -1342,6 +1344,11 @@ class TestVerifierDiscipline(unittest.TestCase): reference_kind="exact", tags=["rule:real"], split="val") tasks = [train, val1, val2] + candidate_pairs = replay_batch(be, [val1, val2], be.HACK_TEXT, "") + candidate_hard, _candidate_soft = aggregate_scores(candidate_pairs) + self.assertEqual([result.hard for _task, result in candidate_pairs], [1.0, 0.0]) + self.assertEqual(candidate_hard, 0.5) + res = consolidate(be, tasks, "", "", edit_budget=4, gate_metric="hard", night=1) self.assertFalse(res.accepted) @@ -1356,7 +1363,6 @@ class TestVerifierDiscipline(unittest.TestCase): self.assertIn("definitive answer", res.rejected_edits[0].content) - class TestDiagnosticsRedaction(unittest.TestCase): """diagnostics.json surfaces backend stderr / optimizer replies / task responses for debugging — but those can carry credentials (e.g. a codex 401