Skip to content

GRAPHIFY_OUT nested path excludes every directory matching its basename from the scan (detect.py GRAPHIFY_OUT_NAME) #2273

Description

@vanjos

GRAPHIFY_OUT with a nested path excludes every directory whose basename matches, not just the output dir.

Root cause

paths.py reduces GRAPHIFY_OUT to a bare basename:

GRAPHIFY_OUT_NAME = os.path.basename(os.path.normpath(GRAPHIFY_OUT))

and detect.py (~line 696) puts that bare name into the set of directory names excluded from the scan, to avoid re-ingesting the output as source (#524, #1423):

"graphify-out", GRAPHIFY_OUT_NAME,  # never treat own output as source input

Because the exclude is matched by directory name anywhere in the tree rather than by the resolved output path, any source directory whose name equals the output dir's basename is silently dropped from the graph.

Impact

A canonical multi-scope layout that writes each scope to graphify-out/<scope>/ gives GRAPHIFY_OUT the basename <scope>. If the scanned tree contains a directory named <scope> (very common for a Python src-layout package, e.g. src/<ns>/<scope>/), that entire directory is excluded. The graph is missing the module's source with no error or warning.

Repro

A Python src-layout package where the source lives under src/.../<name>/, scanned with the output dir basename set to <name>:

graphify update path/to/pkg --no-cluster        # GRAPHIFY_OUT=graphify-out/<name>

Result, holding everything constant except the GRAPHIFY_OUT basename:

  • basename <name> (matches the module dir): 0 files under src/.../<name>/
  • basename xyz (no match): full coverage

Measured on a real package: GRAPHIFY_OUT basename nlp produced 0 files under src/revil/nexus/nlp/ (18,188 nodes); basename xyz produced 4,770 files under it (23,258 nodes). Deterministic across runs, same source, same command.

Suggested fix

Exclude the output directory by resolved path (e.g. skip paths under the actual GRAPHIFY_OUT directory) rather than by bare basename. The literal graphify-out name exclude is fine as a convenience, but deriving a global directory-name exclude from GRAPHIFY_OUT's basename over-matches real source directories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions