Repository navigation
Description
Summary
detect.py's directory-noise heuristic (_SKIP_DIRS / _is_noise_dir) treats any directory literally named env (or ending in _env) as a Python virtualenv and silently prunes it during the walk — with zero trace in any reportable bucket (ignored, unclassified, or any warning). This causes large, silent, undetectable data loss for any codebase that uses env/*_env as a real source directory name — a naming convention common in hardware/ASIC verification environments (UVM testbenches), and plausibly in other domains too.
Root cause
# graphify/detect.py
_SKIP_DIRS = {
"venv", ".venv", "env", ".env",
...
}
def _is_noise_dir(part: str, parent: "Path | None" = None) -> bool:
if part in _SKIP_DIRS:
return True
...
if part.endswith("_venv") or part.endswith("_env"):
return True
...This check is applied unconditionally to every subdirectory encountered during the os.walk traversal (detect(), around the kept_dirs/dirnames[:] pruning loop), before the _is_ignored() / .graphifyignore negation logic runs. Because of this ordering:
- A
.graphifyignorenegation (!env/) cannot rescue the directory — pruning happens earlier and unconditionally. - Pruned directories are never added to
ignored,unclassified, or any other bucket in thedetect()return value — there is no way to detect the loss from the tool's own output. The only symptom is a lower file/node count than expected, with nothing pointing at why. - The exact-name check (
env) applies to every subdirectory the walker descends into, not just files reached directly — so even pointingdetect()/extractdirectly at a parent directory (e.g.src_env/) does not protect a nestedenv/subdirectory from being pruned. - The suffix check (
_env) additionally prunes any directory whose own name ends in_env(e.g.src_env/) the moment it's reached as a subdirectory from a parent scan — even though it's not literally namedenv.
Reproduction
Any repo with this structure:
repo/
src_env/ # <- pruned entirely when scanned from repo root (matches *_env)
env/ # <- pruned even if src_env/ itself is the scan root (exact match)
my_class.py
other_dir/
also_real.py # <- also lost, since the whole src_env/ subtree is pruned from the root scan
from graphify.detect import detect
from pathlib import Path
detect(Path("repo")) # my_class.py and also_real.py: silently absent
detect(Path("repo/src_env")) # my_class.py: still silently absent (env/ pruned as subdir)
# also_real.py: found (not under the env/ subdir)Measured real-world impact
On a live Sandisk/WDC Gen-II UVM verification repo (ip-ctrl_mem_verif) that follows the extremely common convention of naming the top-level environment directory src_env/ and the user-owned environment-logic subdirectory env/ (e.g. verif_sv/src_env/env/ctrl_mem_env.sv):
- 93 of 109
.svsource files (705 KB) were completely absent from the graph — including the core environment class, config, scoreboard, coverage collectors, and every sequence file. - The build reported success with no errors or warnings, and produced a plausible-looking (but badly incomplete) community/report structure — nothing in the tool's own output indicated anything was wrong.
- Verification required manually diffing
find . -iname "*.ext" | wc -lagainstdetect()'s reported count per extension to even notice the gap.
This will reproduce on every repo following this convention — which is the default directory-naming convention for an entire class of hardware verification methodology (Sandisk/WDC "Gen-II" UVM environments), not a one-off.
Suggested fixes (any of these would help; happy to discuss/PR)
- Report pruned noise-dirs. Add pruned directories to a new bucket (e.g.
pruned_as_noise_dir) indetect()'s return value, the same wayignored/unclassifiedalready work — so at minimum the loss is visible and diffable. - Let
.graphifyignorenegation override_is_noise_dir, not just_is_ignored, so!env/in a.graphifyignorecan rescue a real source directory the same way it already rescues gitignored-but-wanted paths. - Narrow the heuristic with context, similar to the existing
snapshotsspecial-case (_JS_SNAPSHOT_TEST_ROOTS/ checking for*.snapfiles before pruning a baresnapshotsdir) — e.g. only treatenv/venvas a Python virtualenv if it actually contains venv markers (pyvenv.cfg,bin/activateorScripts/activate.bat,lib/pythonX.Y/site-packages), rather than pruning on bare name alone.
Happy to provide the exact repo structure / a minimal repro directory tree if useful.
Environment
- graphify version: 0.9.20
- Installed via:
pip install graphifyy(python 3.11.1) - OS: Linux (RHEL-based, dspg CAD infra)
Activity
fix(detect): stop silent data loss from env-dir pruning and absolute-…
safishamsi commentedon Jul 20, 2026
Fixed in v0.9.22: the venv heuristic for
env/.env/*_envis now gated on real markers (pyvenv.cfg, activate, lib/python*, conda-meta/), so real source dirs with those names are indexed; pruned-as-noise dirs are also recorded in a newpruned_noise_dirsbucket. https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.22fix(detect): gate coverage/ pruning on report artefacts (#2339)
fix(detect): stop silent data loss from env-dir pruning and absolute-…
fix(detect): gate coverage/ pruning on report artefacts (Graphify-Lab…