From 9eaf29ae622b0e31c88bfead278f3492bddd953c Mon Sep 17 00:00:00 2001 From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 03:20:53 +0000 Subject: [PATCH 1/4] fix(CODEWIKI-009): 4 review findings across 4 files --- test_clustering_proof.py | 58 +++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/test_clustering_proof.py b/test_clustering_proof.py index 9dfbecc2..bc8d0373 100644 --- a/test_clustering_proof.py +++ b/test_clustering_proof.py @@ -10,6 +10,32 @@ from codewiki.src.be.dependency_analyzer.models.core import Node from codewiki.src.config import Config + +class TestResults: + def __init__(self): + self.tests = [] + + def add_test(self, name, passed, message=""): + self.tests.append((name, passed, message)) + + def print_summary(self): + print("\n" + "=" * 80) + print("šŸ“Š TEST SUMMARY") + print("=" * 80) + for name, passed, message in self.tests: + status = "āœ… PASS" if passed else "āŒ FAIL" + print(f"{status}: {name}") + if message: + print(f" {message}") + total = len(self.tests) + passed_count = sum(1 for _, passed, _ in self.tests if passed) + print(f"\n{passed_count}/{total} tests passed") + print("=" * 80) + return all(passed for _, passed, _ in self.tests) + + +results = TestResults() + test_repo = os.getenv("TEST_REPO_PATH", os.path.dirname(os.path.abspath(__file__))) config = Config( @@ -78,22 +104,30 @@ print("\nšŸ“Š RESULTS:\n") if len(module_tree) == 0: - print("āŒ FAILED: Empty module tree") - print(" LLM did NOT follow format") - sys.exit(1) + results.add_test( + "clustering_produces_modules", + False, + "Empty module tree - LLM did NOT follow format" + ) elif len(module_tree) == 1: - print("āš ļø LLM returned 1 module (rejected as too small)") - print(" But LLM DID follow the tag format correctly!") - print(f" Module: {list(module_tree.keys())[0]}") - sys.exit(0) + results.add_test( + "clustering_produces_modules", + True, + f"LLM returned 1 module (rejected as too small) but followed tag format correctly. " + f"Module: {list(module_tree.keys())[0]}" + ) else: - print(f"āœ…āœ…āœ… SUCCESS! {len(module_tree)} modules created āœ…āœ…āœ…") - print("\nšŸŽ‰ THE FIX IS PROVEN TO WORK! šŸŽ‰\n") - print("Modules generated:") + modules_desc = [] for name, info in module_tree.items(): comp_count = len(info.get('components', [])) comp_list = info.get('components', [])[:5] more = len(info.get('components', [])) - 5 - print(f" - {name}: {comp_count} components {comp_list}{'...' if more > 0 else ''}") - sys.exit(0) + modules_desc.append(f"{name}: {comp_count} components {comp_list}{'...' if more > 0 else ''}") + results.add_test( + "clustering_produces_modules", + True, + f"{len(module_tree)} modules created. Modules generated:\n - " + "\n - ".join(modules_desc) + ) +all_passed = results.print_summary() +sys.exit(0 if all_passed else 1) From b287376751fc487b52ea2022d5594f3975356ad8 Mon Sep 17 00:00:00 2001 From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 03:20:54 +0000 Subject: [PATCH 2/4] fix(CODEWIKI-009): 4 review findings across 4 files --- test_clustering_simple.py | 47 ++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/test_clustering_simple.py b/test_clustering_simple.py index 951c6d26..2a291f9e 100644 --- a/test_clustering_simple.py +++ b/test_clustering_simple.py @@ -17,6 +17,33 @@ from codewiki.src.be.dependency_analyzer.models.core import Node from codewiki.src.config import Config + +class TestResults: + def __init__(self): + self.tests = [] + + def add_test(self, name, passed, message=""): + self.tests.append((name, passed, message)) + + def print_summary(self): + print("\n" + "=" * 80) + print("TEST SUMMARY") + print("=" * 80) + failed = 0 + for name, passed, message in self.tests: + status = "āœ… PASS" if passed else "āŒ FAIL" + print(f"{status}: {name}") + if message: + print(f" {message}") + if not passed: + failed += 1 + print("=" * 80) + print(f"Total: {len(self.tests)}, Passed: {len(self.tests) - failed}, Failed: {failed}") + return failed == 0 + + +results = TestResults() + # Test repo test_repo = os.getenv("TEST_REPO_PATH", os.path.join(os.path.dirname(os.path.abspath(__file__)), "openframe-oss-tenant")) @@ -97,13 +124,21 @@ print("=" * 80) if len(module_tree) == 0: - print("\nāŒ FAILED: Empty module tree") - print(" LLM did not follow the tag format") - sys.exit(1) + results.add_test( + "clustering produces module tree", + False, + "Empty module tree - LLM did not follow the tag format" + ) else: - print(f"\nāœ… SUCCESS: {len(module_tree)} modules created") + detail_lines = [f"{len(module_tree)} modules created"] for module_name, module_info in module_tree.items(): comp_count = len(module_info.get("components", [])) - print(f" - {module_name}: {comp_count} components") - sys.exit(0) + detail_lines.append(f" - {module_name}: {comp_count} components") + results.add_test( + "clustering produces module tree", + True, + "\n".join(detail_lines) + ) +success = results.print_summary() +sys.exit(0 if success else 1) From 9833c4bc1c9bd16fb77d6b3b6b6e3a51a0378d67 Mon Sep 17 00:00:00 2001 From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 03:20:56 +0000 Subject: [PATCH 3/4] fix(CODEWIKI-009): 4 review findings across 4 files --- test_fqdn_normalization.py | 215 +++++++++++++++++++++++++++++-------- 1 file changed, 171 insertions(+), 44 deletions(-) diff --git a/test_fqdn_normalization.py b/test_fqdn_normalization.py index ec90ff81..e8091755 100644 --- a/test_fqdn_normalization.py +++ b/test_fqdn_normalization.py @@ -1,17 +1,41 @@ """ Test Cases for FQDN Normalization Fix -Run with: python -m pytest test_fqdn_normalization.py -v +Run with: python test_fqdn_normalization.py """ -import pytest from collections import namedtuple # Mock Node class for testing Node = namedtuple('Node', ['short_id']) -def test_strip_deps_prefix(): +class TestResults: + def __init__(self): + self.passed = 0 + self.failed = 0 + self.failures = [] + + def add_test(self, name, condition, message=""): + if condition: + self.passed += 1 + else: + self.failed += 1 + self.failures.append(f"{name}: {message}") + + def print_summary(self): + total = self.passed + self.failed + print(f"\n{'=' * 60}") + print(f"Test Summary: {self.passed}/{total} passed") + if self.failures: + print("Failures:") + for failure in self.failures: + print(f" - {failure}") + print(f"{'=' * 60}") + return self.failed == 0 + + +def test_strip_deps_prefix(results): """Test that 'deps.' prefix is correctly stripped.""" # Simulated components dictionary components = { @@ -34,11 +58,19 @@ def test_strip_deps_prefix(): # Test normalization for llm_id, expected_fqdn in zip(llm_output, expected): stripped = llm_id[5:] if llm_id.startswith("deps.") else llm_id - assert stripped in components, f"Failed to find {stripped} after stripping" - assert stripped == expected_fqdn - - -def test_fuzzy_component_name_match(): + results.add_test( + "test_strip_deps_prefix: stripped in components", + stripped in components, + f"Failed to find {stripped} after stripping", + ) + results.add_test( + "test_strip_deps_prefix: stripped == expected_fqdn", + stripped == expected_fqdn, + f"{stripped} != {expected_fqdn}", + ) + + +def test_fuzzy_component_name_match(results): """Test fuzzy matching by component name (last segment).""" components = { "openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer": Node(short_id="PinotConfigInitializer"), @@ -50,16 +82,29 @@ def test_fuzzy_component_name_match(): # Extract component name component_name = llm_id.split('.')[-1] - assert component_name == "PinotConfigInitializer" + results.add_test( + "test_fuzzy_component_name_match: component_name extraction", + component_name == "PinotConfigInitializer", + f"component_name was {component_name}", + ) # Find matches matches = [fqdn for fqdn in components.keys() if fqdn.split('.')[-1] == component_name] - assert len(matches) == 1, f"Expected 1 match, found {len(matches)}" - assert matches[0] == "openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer" + results.add_test( + "test_fuzzy_component_name_match: match count", + len(matches) == 1, + f"Expected 1 match, found {len(matches)}", + ) + if matches: + results.add_test( + "test_fuzzy_component_name_match: match value", + matches[0] == "openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer", + f"matches[0] was {matches[0]}", + ) -def test_path_suffix_matching(): +def test_path_suffix_matching(results): """Test matching by path suffix (last N segments).""" components = { "openframe-oss-lib.different.path.java.config.pinot.PinotConfigInitializer": Node(short_id="PinotConfigInitializer"), @@ -73,11 +118,20 @@ def test_path_suffix_matching(): matches = [fqdn for fqdn in components.keys() if fqdn.endswith(suffix_3)] - assert len(matches) == 1 - assert matches[0] == "openframe-oss-lib.different.path.java.config.pinot.PinotConfigInitializer" + results.add_test( + "test_path_suffix_matching: match count", + len(matches) == 1, + f"Expected 1 match, found {len(matches)}", + ) + if matches: + results.add_test( + "test_path_suffix_matching: match value", + matches[0] == "openframe-oss-lib.different.path.java.config.pinot.PinotConfigInitializer", + f"matches[0] was {matches[0]}", + ) -def test_exact_fqdn_match(): +def test_exact_fqdn_match(results): """Test that exact FQDN matches work without modification.""" components = { "main-repo.src.services.user_service.UserService": Node(short_id="UserService"), @@ -85,10 +139,14 @@ def test_exact_fqdn_match(): llm_id = "main-repo.src.services.user_service.UserService" - assert llm_id in components + results.add_test( + "test_exact_fqdn_match: llm_id in components", + llm_id in components, + f"{llm_id} not found in components", + ) -def test_short_id_mapping(): +def test_short_id_mapping(results): """Test that short ID → FQDN mapping works.""" components = { "main-repo.src.services.user_service.UserService": Node(short_id="UserService"), @@ -102,11 +160,19 @@ def test_short_id_mapping(): mapping[short_id] = fqdn # Test mapping - assert mapping["UserService"] == "main-repo.src.services.user_service.UserService" - assert mapping["Logger"] == "main-repo.src.utils.logger.Logger" - - -def test_partial_path_mapping(): + results.add_test( + "test_short_id_mapping: UserService", + mapping.get("UserService") == "main-repo.src.services.user_service.UserService", + f"mapping['UserService'] was {mapping.get('UserService')}", + ) + results.add_test( + "test_short_id_mapping: Logger", + mapping.get("Logger") == "main-repo.src.utils.logger.Logger", + f"mapping['Logger'] was {mapping.get('Logger')}", + ) + + +def test_partial_path_mapping(results): """Test that partial paths are mapped correctly.""" components = { "main-repo.src.services.auth.UserService": Node(short_id="UserService"), @@ -128,13 +194,29 @@ def test_partial_path_mapping(): mapping[partial] = fqdn # Test mappings - assert "UserService" in mapping - assert "auth.UserService" in mapping - assert "services.auth.UserService" in mapping - assert "src.services.auth.UserService" in mapping - - -def test_collision_detection(): + results.add_test( + "test_partial_path_mapping: UserService in mapping", + "UserService" in mapping, + "UserService not found in mapping", + ) + results.add_test( + "test_partial_path_mapping: auth.UserService in mapping", + "auth.UserService" in mapping, + "auth.UserService not found in mapping", + ) + results.add_test( + "test_partial_path_mapping: services.auth.UserService in mapping", + "services.auth.UserService" in mapping, + "services.auth.UserService not found in mapping", + ) + results.add_test( + "test_partial_path_mapping: src.services.auth.UserService in mapping", + "src.services.auth.UserService" in mapping, + "src.services.auth.UserService not found in mapping", + ) + + +def test_collision_detection(results): """Test that collisions are detected when same short ID maps to multiple FQDNs.""" from collections import defaultdict @@ -154,11 +236,19 @@ def test_collision_detection(): else: mapping[short_id] = fqdn - assert "UserService" in collisions - assert len(collisions["UserService"]) >= 1 # At least one collision + results.add_test( + "test_collision_detection: UserService in collisions", + "UserService" in collisions, + "UserService not found in collisions", + ) + results.add_test( + "test_collision_detection: at least one collision", + len(collisions["UserService"]) >= 1, + f"collisions['UserService'] had length {len(collisions['UserService'])}", + ) -def test_best_path_match_scoring(): +def test_best_path_match_scoring(results): """Test the path similarity scoring algorithm.""" llm_id = "deps.openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer" candidates = [ @@ -180,11 +270,19 @@ def test_best_path_match_scoring(): scores.sort(key=lambda x: x[1], reverse=True) # Best match should have highest score - assert scores[0][0] == "openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer" - assert scores[0][1] > scores[2][1] # Better than different namespace - - -def test_non_existent_component(): + results.add_test( + "test_best_path_match_scoring: best match", + scores[0][0] == "openframe-oss-lib.src.main.java.config.pinot.PinotConfigInitializer", + f"scores[0][0] was {scores[0][0]}", + ) + results.add_test( + "test_best_path_match_scoring: better than different namespace", + scores[0][1] > scores[2][1], + f"scores[0][1]={scores[0][1]} not > scores[2][1]={scores[2][1]}", + ) + + +def test_non_existent_component(results): """Test that non-existent components fail normalization.""" components = { "main-repo.src.services.UserService": Node(short_id="UserService"), @@ -194,14 +292,22 @@ def test_non_existent_component(): # Should not match anything stripped = llm_id[5:] if llm_id.startswith("deps.") else llm_id - assert stripped not in components + results.add_test( + "test_non_existent_component: stripped not in components", + stripped not in components, + f"{stripped} unexpectedly found in components", + ) component_name = llm_id.split('.')[-1] matches = [fqdn for fqdn in components.keys() if component_name in fqdn] - assert len(matches) == 0 + results.add_test( + "test_non_existent_component: no matches", + len(matches) == 0, + f"Expected 0 matches, found {len(matches)}", + ) -def test_double_class_name(): +def test_double_class_name(results): """Test handling of paths with duplicate component names.""" # This tests the scenario: PintoConfigInitializer.PinotConfigInitializer components = { @@ -218,10 +324,14 @@ def test_double_class_name(): # Should match by component name matches = [fqdn for fqdn in components.keys() if fqdn.split('.')[-1] == component_name] - assert len(matches) == 1 + results.add_test( + "test_double_class_name: match count", + len(matches) == 1, + f"Expected 1 match, found {len(matches)}", + ) -def test_java_package_path(): +def test_java_package_path(results): """Test handling of Java package paths with com.openframe prefix.""" components = { "openframe-oss-lib.src.main.java.com.openframe.management.config.PinotConfig": Node( @@ -235,8 +345,25 @@ def test_java_package_path(): # Strip deps prefix stripped = llm_id[5:] if llm_id.startswith("deps.") else llm_id - assert stripped in components + results.add_test( + "test_java_package_path: stripped in components", + stripped in components, + f"{stripped} not found in components", + ) if __name__ == "__main__": - pytest.main([__file__, "-v"]) + results = TestResults() + test_strip_deps_prefix(results) + test_fuzzy_component_name_match(results) + test_path_suffix_matching(results) + test_exact_fqdn_match(results) + test_short_id_mapping(results) + test_partial_path_mapping(results) + test_collision_detection(results) + test_best_path_match_scoring(results) + test_non_existent_component(results) + test_double_class_name(results) + test_java_package_path(results) + success = results.print_summary() + raise SystemExit(0 if success else 1) From 7f1b41a905afe7719c19524499201ff34ca242ed Mon Sep 17 00:00:00 2001 From: "flamingo[bot]" <277372822+flamingo[bot]@users.noreply.github.com> Date: Wed, 23 Sep 2026 03:20:57 +0000 Subject: [PATCH 4/4] fix(CODEWIKI-009): 4 review findings across 4 files --- test_clustering_local.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test_clustering_local.py b/test_clustering_local.py index c59e8e31..33c1177e 100644 --- a/test_clustering_local.py +++ b/test_clustering_local.py @@ -163,13 +163,18 @@ def test_clustering(results): return False if __name__ == "__main__": + test_results = TestResults() + # Check for API keys if not (os.getenv("OPENAI_API_KEY") or os.getenv("MAIN_API_KEY")): print("āŒ ERROR: OPENAI_API_KEY or MAIN_API_KEY environment variable not set") print(" Set it with: export OPENAI_API_KEY='your-key-here'") + test_results.add_test("api_key_configured", False, "OPENAI_API_KEY or MAIN_API_KEY environment variable not set") + test_results.print_summary() sys.exit(1) - test_results = TestResults() + test_results.add_test("api_key_configured", True) + success = test_clustering(test_results) test_results.print_summary() sys.exit(0 if success else 1)