From e2c37a935e8645cc9916eb04cf0c283b317371a0 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Fri, 9 Oct 2026 17:09:41 +0000 Subject: [PATCH] fix(checker): aggregate fuzzy f32 rounding when fully matched (worker 375e94d4) --- tools/check_decomp_complete.py | 34 ++++++++++++++++++++++++++++++---- tools/test_workflow_guards.py | 19 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/tools/check_decomp_complete.py b/tools/check_decomp_complete.py index e0554d55..6c8ceee3 100644 --- a/tools/check_decomp_complete.py +++ b/tools/check_decomp_complete.py @@ -15,6 +15,11 @@ EXPECTED_TOTAL_DATA = 1832684 EXPECTED_TOTAL_FUNCTIONS = 12563 INTEGER_PATTERN = re.compile(r"-?(0|[1-9][0-9]*)\Z") CODE_SECTIONS = frozenset({".text", ".init"}) +# objdiff accumulates the aggregate fuzzy_match_percent in 32-bit floats over every code byte, +# so a fully matched report can read 99.9998 instead of 100.0. Aggregates are accepted within +# this tolerance only when every code byte is counted as matched; units, sections and functions +# are always checked exactly. +AGGREGATE_FUZZY_TOLERANCE = 0.001 AGGREGATE_FIELDS = ( "total_units", "total_code", @@ -85,7 +90,25 @@ def percent(measures, field, label, failures): failures.append(f"{label}: {value}") -def check_complete_measures(measures, label, failures): +def aggregate_fuzzy(measures, label, failures): + value = required(measures, "fuzzy_match_percent", f"{label} fuzzy_match_percent", failures) + if value is None or exact(value): + return + try: + fully_matched = integer(measures.get("matched_code")) == integer(measures.get("total_code")) + except ValueError: + fully_matched = False + if ( + not fully_matched + or not isinstance(value, (int, float)) + or isinstance(value, bool) + or not math.isfinite(float(value)) + or not 100.0 - AGGREGATE_FUZZY_TOLERANCE <= float(value) <= 100.0 + ): + failures.append(f"{label} fuzzy_match_percent: {value}") + + +def check_complete_measures(measures, label, failures, aggregate=False): for matched, total, name in ( ("matched_code", "total_code", "code match"), ("complete_code", "total_code", "code link"), @@ -101,9 +124,12 @@ def check_complete_measures(measures, label, failures): "matched_data_percent", "complete_data_percent", "matched_functions_percent", - "fuzzy_match_percent", ): percent(measures, field, f"{label} {field}", failures) + if aggregate: + aggregate_fuzzy(measures, label, failures) + else: + percent(measures, "fuzzy_match_percent", f"{label} fuzzy_match_percent", failures) def key_for(value): @@ -131,7 +157,7 @@ def check_report(report): value = count(measures, field, "overall", failures) if value is not None and value != expected: failures.append(f"overall {field}: {value} != {expected}") - check_complete_measures(measures, "overall", failures) + check_complete_measures(measures, "overall", failures, aggregate=True) units = report.get("units") if not isinstance(units, list) or len(units) != EXPECTED_TOTAL_UNITS: @@ -244,7 +270,7 @@ def check_report(report): if not isinstance(category_measures, dict): failures.append(f"{name}: missing measures") continue - check_complete_measures(category_measures, name, failures) + check_complete_measures(category_measures, name, failures, aggregate=True) for field in AGGREGATE_FIELDS: if field in category_measures: value = count(category_measures, field, name, failures) diff --git a/tools/test_workflow_guards.py b/tools/test_workflow_guards.py index 0e296745..ff5b171b 100644 --- a/tools/test_workflow_guards.py +++ b/tools/test_workflow_guards.py @@ -233,6 +233,25 @@ class WorkflowGuardTests(unittest.TestCase): def test_complete_report_schema_passes(self): self.assertEqual(check_report(self.complete_report()), []) + def test_aggregate_fuzzy_float_rounding_passes_only_when_fully_matched(self): + report = self.complete_report() + report["measures"]["fuzzy_match_percent"] = 99.999886 + report["categories"][0]["measures"]["fuzzy_match_percent"] = 99.999886 + self.assertEqual(check_report(report), []) + + code_unit = next(unit for unit in report["units"] if "total_code" in unit["measures"]) + code_unit["measures"]["fuzzy_match_percent"] = 99.999886 + self.assertIn(f"{code_unit['name']} fuzzy percent: 99.999886", check_report(report)) + + report = self.complete_report() + report["measures"]["fuzzy_match_percent"] = 99.9 + self.assertIn("overall fuzzy_match_percent: 99.9", check_report(report)) + + report = self.complete_report() + report["measures"]["fuzzy_match_percent"] = 99.999886 + report["measures"]["matched_code"] = int(report["measures"]["total_code"]) - 4 + self.assertIn("overall fuzzy_match_percent: 99.999886", check_report(report)) + def test_missing_or_extra_unit_fails(self): for total_units in (1027, 1029): with self.subTest(total_units=total_units): -- 2.49.1