From ed5e9e65a0f1728dc4c151b36bec33080e3b7852 Mon Sep 17 00:00:00 2001 From: Divyam Talwar Date: Thu, 26 Mar 2026 13:36:42 +0530 Subject: [PATCH 1/2] fix(paths): improve exclusion matching logic and add tests for validation --- core/file_paths.py | 8 +++++--- engine/detectors/flat_dirs.py | 4 ++++ engine/detectors/passthrough.py | 4 +++- test_paths.py | 5 +++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 test_paths.py diff --git a/core/file_paths.py b/core/file_paths.py index 4c1500e..5e0a520 100644 --- a/core/file_paths.py +++ b/core/file_paths.py @@ -22,13 +22,15 @@ def matches_exclusion(rel_path: str, exclusion: str) -> bool: # Full-path glob match for patterns with directory separators # (e.g. "Wan2GP/**" should match "Wan2GP/models/rf.py"). if "/" in exclusion or os.sep in exclusion: - normalized_path = rel_path.lstrip("./") + normalized_path = rel_path[2:] if rel_path.startswith("./") or rel_path.startswith("." + os.sep) else rel_path if fnmatch.fnmatch(normalized_path, exclusion): return True if "/" in exclusion or os.sep in exclusion: normalized = exclusion.rstrip("/").rstrip(os.sep) - return rel_path.startswith(normalized + "/") or rel_path.startswith( - normalized + os.sep + return ( + rel_path == normalized + or rel_path.startswith(normalized + "/") + or rel_path.startswith(normalized + os.sep) ) return False diff --git a/engine/detectors/flat_dirs.py b/engine/detectors/flat_dirs.py index dd0c747..2c7bfc8 100644 --- a/engine/detectors/flat_dirs.py +++ b/engine/detectors/flat_dirs.py @@ -112,6 +112,10 @@ def detect_flat_dirs( dir_counts[parent] += 1 # Track direct subdirectory fan-out for every ancestor. parts = parent_rel.parts + if parts: + child_dirs.setdefault(str(scan_root), set()).add( + str((scan_root / parts[0]).resolve()) + ) for idx in range(len(parts) - 1): ancestor = (scan_root / Path(*parts[: idx + 1])).resolve() child = (scan_root / Path(*parts[: idx + 2])).resolve() diff --git a/engine/detectors/passthrough.py b/engine/detectors/passthrough.py index 8a8a54d..0c239ea 100644 --- a/engine/detectors/passthrough.py +++ b/engine/detectors/passthrough.py @@ -53,7 +53,9 @@ def classify_params( passthrough = [] direct = [] for name in params: - total = len(re.findall(rf"\b{re.escape(name)}\b", body)) + # Use (? Date: Thu, 26 Mar 2026 13:59:43 +0530 Subject: [PATCH 2/2] Revert "fix(paths): improve exclusion matching logic and add tests for validation" This reverts commit ed5e9e65a0f1728dc4c151b36bec33080e3b7852. --- core/file_paths.py | 8 +++----- engine/detectors/flat_dirs.py | 4 ---- engine/detectors/passthrough.py | 4 +--- test_paths.py | 5 ----- 4 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 test_paths.py diff --git a/core/file_paths.py b/core/file_paths.py index 5e0a520..4c1500e 100644 --- a/core/file_paths.py +++ b/core/file_paths.py @@ -22,15 +22,13 @@ def matches_exclusion(rel_path: str, exclusion: str) -> bool: # Full-path glob match for patterns with directory separators # (e.g. "Wan2GP/**" should match "Wan2GP/models/rf.py"). if "/" in exclusion or os.sep in exclusion: - normalized_path = rel_path[2:] if rel_path.startswith("./") or rel_path.startswith("." + os.sep) else rel_path + normalized_path = rel_path.lstrip("./") if fnmatch.fnmatch(normalized_path, exclusion): return True if "/" in exclusion or os.sep in exclusion: normalized = exclusion.rstrip("/").rstrip(os.sep) - return ( - rel_path == normalized - or rel_path.startswith(normalized + "/") - or rel_path.startswith(normalized + os.sep) + return rel_path.startswith(normalized + "/") or rel_path.startswith( + normalized + os.sep ) return False diff --git a/engine/detectors/flat_dirs.py b/engine/detectors/flat_dirs.py index 2c7bfc8..dd0c747 100644 --- a/engine/detectors/flat_dirs.py +++ b/engine/detectors/flat_dirs.py @@ -112,10 +112,6 @@ def detect_flat_dirs( dir_counts[parent] += 1 # Track direct subdirectory fan-out for every ancestor. parts = parent_rel.parts - if parts: - child_dirs.setdefault(str(scan_root), set()).add( - str((scan_root / parts[0]).resolve()) - ) for idx in range(len(parts) - 1): ancestor = (scan_root / Path(*parts[: idx + 1])).resolve() child = (scan_root / Path(*parts[: idx + 2])).resolve() diff --git a/engine/detectors/passthrough.py b/engine/detectors/passthrough.py index 0c239ea..8a8a54d 100644 --- a/engine/detectors/passthrough.py +++ b/engine/detectors/passthrough.py @@ -53,9 +53,7 @@ def classify_params( passthrough = [] direct = [] for name in params: - # Use (?