diff --git a/scripts/history_engine.py b/scripts/history_engine.py index e9bd71d7..01204dfb 100644 --- a/scripts/history_engine.py +++ b/scripts/history_engine.py @@ -151,7 +151,12 @@ def collect_metrics(workspace: str, scan_result: Dict[str, Any]) -> Dict[str, An try: from circular_engine import detect_circular circ = detect_circular(workspace) - metrics["circular_deps_count"] = circ.get("cycle_count", 0) + # Bug: detect_circular() returns "total_cycles", never "cycle_count" — + # this always silently fell back to the 0 default regardless of how + # many cycles were actually found (found via real-codebase validation: + # circular_deps_count read 0 while the circular_deps list right below + # had 5 entries populated from the same detect_circular() call). + metrics["circular_deps_count"] = circ.get("total_cycles", 0) metrics["circular_deps"] = [] cycles = circ.get("cycles", circ.get("chains", {})) if isinstance(cycles, dict): diff --git a/scripts/impact_engine.py b/scripts/impact_engine.py index 5538cb87..cafa7647 100755 --- a/scripts/impact_engine.py +++ b/scripts/impact_engine.py @@ -296,8 +296,19 @@ def analyze_impact( test_patterns = [ f"{base}.test.ts", f"{base}.test.js", f"{base}.spec.ts", f"{base}.spec.js", f"{base}.test.tsx", f"{base}.spec.tsx", - f.replace(".rs", "_test.rs").replace(".py", "_test.py"), ] + # Rust/Python "_test" suffix convention — only applicable to files of + # that extension. Bug: str.replace() is a no-op when the extension + # doesn't match (e.g. a .ts file has no ".rs"/".py" substring), so the + # "pattern" silently degenerated into the original filename `f` itself + # — which trivially exists on disk, causing EVERY affected file to be + # misclassified as its own test file (found via real-codebase + # validation: impact --name signInWithGoogle listed calculator_widget.ts, + # errors.ts, sidepanel.ts as "tests", none of which are test files). + if f.endswith(".rs"): + test_patterns.append(f[:-3] + "_test.rs") + elif f.endswith(".py"): + test_patterns.append(f[:-3] + "_test.py") for tf in test_patterns: full_path = os.path.join(workspace, tf) if os.path.exists(full_path):