Skip to content

Commit f2397ed

Browse files
committed
fix(watcher): normalize package names (pep503) during op verification
Previously, the watcher falsely identified our own FFI installs as 'External Culprits' due to differences in name normalization (e.g. FFI reported 'mkdocs-minify-plugin' while the disk wrote 'mkdocs_minify_plugin'). Injected a regex normalizer to ensure hyphens, underscores, and dots are uniformly matched, preventing redundant cache patches.
1 parent 9043aa5 commit f2397ed

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/omnipkg/isolation/fs_watcher.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ def end_omnipkg_op(self, installed: list, removed: list):
322322
Validates any queued FS events against the official changelog.
323323
Only processes events that happened in this handler's directory.
324324
"""
325-
official = {pkg[0].lower() for pkg in installed} | {pkg[0].lower() for pkg in removed}
325+
def _norm(n): return __import__("re").sub(r"[-_.]+", "-", n).lower()
326+
official = {_norm(pkg[0]) for pkg in installed} | {_norm(pkg[0]) for pkg in removed}
326327
culprit_count = 0
327328

328329
with self._debounce_lock:
@@ -340,7 +341,7 @@ def end_omnipkg_op(self, installed: list, removed: list):
340341
stem = p.name[:-len(".dist-info")] if p.name.endswith(".dist-info") else p.name
341342
name = stem.rsplit("-", 1)[0] if "-" in stem else stem
342343

343-
if name.lower() not in official:
344+
if _norm(name) not in official:
344345
log.info("[fs_watcher] 🚨 EXTERNAL CULPRIT during op: %s", name)
345346
culprit_count += 1
346347
parsed = self._parse_dist_info_name(p)
@@ -812,7 +813,8 @@ def end_omnipkg_op(self, installed: list, removed: list):
812813
log.debug("[fs_watcher] Omnipkg official changes: [INSTALLED: %s] [REMOVED: %s]",
813814
inst_str or "none", rem_str or "none")
814815

815-
official = {pkg[0].lower() for pkg in installed} | {pkg[0].lower() for pkg in removed}
816+
def _norm(n): return __import__("re").sub(r"[-_.]+", "-", n).lower()
817+
official = {_norm(pkg[0]) for pkg in installed} | {_norm(pkg[0]) for pkg in removed}
816818

817819
# Refresh snapshot post-op BEFORE clearing in_progress.
818820
# The poll loop checks _omnipkg_op_in_progress first — if we cleared it
@@ -849,7 +851,7 @@ def end_omnipkg_op(self, installed: list, removed: list):
849851
continue
850852
stem = p.name[:-len(".dist-info")] if p.name.endswith(".dist-info") else p.name
851853
name = stem.rsplit("-", 1)[0] if "-" in stem else stem
852-
if name.lower() not in official:
854+
if _norm(name) not in official:
853855
log.info("[fs_watcher] 🚨 EXTERNAL CULPRIT during op: %s", name)
854856
culprit_count += 1
855857
parsed = SitePackagesEventHandler._parse_dist_info_name(p)

0 commit comments

Comments
 (0)