From e921ba80cd7be62f7ecbd84b1c39e89e88ff5225 Mon Sep 17 00:00:00 2001 From: Joe Esquibel Date: Thu, 20 Aug 2026 21:05:07 -0400 Subject: [PATCH] Fix file_data.class_count to use the real named class list class_count was sourced from the raw class_start SIGNAL vector (hv[class_idx], the same value as struct_class_start), not len(classes) -- the actual named list that also backs the class_data table. function_count already correctly used len(functions); this brings class_count in line with the same pattern. Found while manually verifying dockerfile's tri-comparison numbers: class_count reported 69 for a Dockerfile with 69 real FROM stages, but class_data had 0 rows (dockerfile has no named class extraction wired yet, tracked separately as #1974). class_count should honestly report len(classes) regardless of which language it's counting for. Adds a regression assertion to test_record_keeper_data_insertion -- the existing mock_pipeline_state fixture already had 1 real class with no 'class_start' key in its mock SIGNAL_SCHEMA, so the bug was silently producing class_count=0 there even though nothing asserted it. Fixes #1972. Co-Authored-By: Claude Sonnet 5 Co-Authored-By: Gemini 3.1 Pro --- gitgalaxy/recorders/record_keeper.py | 3 +-- tests/tools_recorders/test_record_keeper.py | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gitgalaxy/recorders/record_keeper.py b/gitgalaxy/recorders/record_keeper.py index 7ad45769c..a04689b5e 100644 --- a/gitgalaxy/recorders/record_keeper.py +++ b/gitgalaxy/recorders/record_keeper.py @@ -554,8 +554,7 @@ def record_mission( producer_ratio = net_mets.get("producer_ratio", 0.0) ecosystem_role = net_mets.get("ecosystem_role", "Unknown") - class_idx = self.SIGNAL_SCHEMA.index("class_start") if "class_start" in self.SIGNAL_SCHEMA else -1 - class_count = hv[class_idx] if class_idx >= 0 and class_idx < len(hv) else 0 + class_count = len(file_data.get("classes", [])) repo_macro = tel.get("repo_macro_species", "Unknown") repo_z = tel.get("repo_z_score", 0.0) diff --git a/tests/tools_recorders/test_record_keeper.py b/tests/tools_recorders/test_record_keeper.py index eacb39d30..951ac108e 100644 --- a/tests/tools_recorders/test_record_keeper.py +++ b/tests/tools_recorders/test_record_keeper.py @@ -195,6 +195,9 @@ def test_record_keeper_data_insertion(keeper, mock_pipeline_state, tmp_path): assert file_row["ecosystem_role"] == "Core Hub" assert file_row["state_danger"] == 2 # The hit_vector value for danger + assert file_row["class_count"] == 1 + assert file_row["function_count"] == 1 + file_id = file_row["id"] # 3. Verify Class & Function Relationships (Foreign Keys)