#3637·graphify

detect() hard-includes <out>/memory/ and bypasses all ignore rules

Author: igmarinCreated Sep 17, 2026Updated Sep 17, 2026

Summary

detect() unconditionally appends <out>/memory/ to scan_paths and then exempts those files from every ignore mechanism, so saved query notes re-enter the corpus on every incremental update. There is no supported way to exclude them.

Evidence (graphifyy 0.9.63, installed from PyPI)

In graphify/detect.py:

  • L1820-1824 — the dir is appended to scan_paths unconditionally:
    # Always include graphify-out/memory/ - query results filed back into the graph
    memory_dir = root / GRAPHIFY_OUT / "memory"
    ...
    if memory_dir.exists():
        scan_paths.append(memory_dir)
    
  • L1848 / L1859in_memory_tree skips the ignore-aware dir pruning.
  • L1932-1938in_memory skips both noise filtering and _ignored_for_scan(p), so .gitignore and .graphifyignore never apply:
    in_memory = memory_dir.exists() and str(p).startswith(str(memory_dir))
    if not in_memory:
        ...
    if not in_memory and _ignored_for_scan(p):
    

Meanwhile --memory-dir only redirects writes (save-result/reflect) — it does not change the scan root, so pointing memory elsewhere still leaves the hard-include watching <out>/memory/.

Impact

Running graphify save-result (or any flow that writes <out>/memory/) followed by graphify --update re-ingests the tool's own query notes. In our repo this added 62 "Query Memory" nodes and ~10 communities of self-referential noise; the only workaround is keeping <out>/memory/ absent entirely (or redirecting memory writes outside the output dir).

Suggested fix

Any of these closes the hole:

  1. Honor _ignored_for_scan inside the memory dir (drop the in_memory exemptions), so a .graphifyignore//memory entry works; or
  2. Gate the hard-include behind a flag (e.g. graphify detect --include-memory), default off; or
  3. Resolve the scan path from the same --memory-dir option used for writes, so relocating memory actually relocates the scan.

Option 1 is the least surprising: users expect ignore files to be authoritative.