test(scanner): reject unobserved enumeration budget evidence

Co-Authored-By: heihutu <heihutu@gmail.com>
Co-Authored-By: zhi22915 <qiuzgang@gmail.com>
This commit is contained in:
houseme
2026-09-06 01:32:21 +08:00
parent f25df09f61
commit ed026a0f1f
2 changed files with 8 additions and 0 deletions
@@ -33,6 +33,8 @@ def validate_report(report, *, round_number, pid, objects, budget):
"versions_retained", "bytes_retained", "objects_processed"):
if type(report.get(key)) is not int or not 0 <= report[key] <= 1048576:
raise ValueError(f"invalid bounded counter: {key}")
if report["raw_entries"] == 0:
raise ValueError("nonempty fixture must observe raw entries; budget hook may not have run")
if report["raw_entries"] > budget:
raise ValueError("raw-entry budget exceeded; no unbudgeted tail is permitted")
if type(report.get("snapshot_complete")) is not bool:
@@ -42,6 +42,12 @@ class ReportTests(unittest.TestCase):
with self.assertRaises(ValueError):
self.validate(report)
def test_complete_coverage_without_entry_observation_rejected(self):
report = self.report()
report["raw_entries"] = 0
with self.assertRaises(ValueError):
self.validate(report)
def test_missing_wrong_type_and_negative_counter_rejected(self):
for value in (None, True, -1, "8", 1048577):
with self.subTest(value=value):