Repository navigation
Description
detect() carve-out for graphify-out/memory/ is half-implemented — gitignore still filters memory files
Summary
detect.py L26-29 includes special-case logic to always walk graphify-out/memory/ so that save-result Q&A artifacts can be folded back into the graph on the next --update:
# Always include graphify-out/memory/ - query results filed back into the graph
memory_dir = root / "graphify-out" / "memory"
scan_paths = [root]
if memory_dir.exists():
scan_paths.append(memory_dir)But the downstream _is_ignored(p, root, ignore_patterns) filter on L73 still applies the normal gitignore rules to every file found. If the user's .gitignore contains graphify-out/ (a very common pattern — graphify itself suggests it in the post-commit-hook installer), all memory files get filtered out even though the scan deliberately walked the directory.
Net effect: the save-result → --update → graph loop silently breaks for any user who gitignores graphify-out/. Memory artifacts pile up on disk and never become graph nodes.
Reproducer
# In a project where graphify-out/ is gitignored (the common case):
cd /path/to/your/project
echo 'graphify-out/' >> .gitignore
# Run a query and save the result
graphify query "How does X work?"
graphify save-result --question "How does X work?" --answer "..." --type query --nodes "..."
ls graphify-out/memory/ # ← file is on disk
# Try to fold it into the graph
graphify --update # ← memory file is silently filtered
python3 -c "
from graphify.detect import detect
from pathlib import Path
r = detect(Path('.'))
mem = [f for files in r['files'].values() for f in files if '/memory/' in f]
print(f'Memory files detected: {len(mem)}') # 0
"In our project (safishamsi/graphify users testing, also confirmed in a CDP protocol repo, 9 memory files):
>>> from graphify.detect import _is_ignored, _load_graphifyignore
>>> from pathlib import Path
>>> root = Path('.').resolve()
>>> test = root / 'graphify-out' / 'memory' / 'query_2026...md'
>>> _is_ignored(test, root, _load_graphifyignore(root))
True # ← filtered, even though detect() walks the dirWhy the carve-out leaks
The L73 _is_ignored call is unconditional. It runs on every walked file, regardless of which scan_root it came from. The scan correctly includes memory_dir, but the filter doesn't know it's supposed to exempt files inside that path.
A .graphifyinclude workaround doesn't help either — _load_graphifyinclude's docstring states include patterns are for "opt[ing] hidden files/dirs into traversal", and the include_patterns variable isn't passed to _is_ignored.
Workarounds (what users have to do today)
-
Fenced gitignore rule — replace
graphify-out/withgraphify-out/*\n!graphify-out/memory/\n!graphify-out/memory/**. Works but ugly; users have to figure this out themselves and edit project-level gitignore. -
Don't gitignore
graphify-out/— keeps the loop alive but bloats the repo with regeneratedgraph.json,GRAPH_REPORT.md, and per-rebuild backup dirs (6+ MB each). -
Move memory dir elsewhere via symlink —
mv graphify-out/memory docs/graphify-qa && ln -s ../docs/graphify-qa graphify-out/memory. Works but fragile and not discoverable.
Proposed fix
Either:
(a) Apply the carve-out in _is_ignored. Inside detect.py L73, mirror the existing in_memory short-circuit from L67-68 by skipping the gitignore check for paths inside memory_dir:
in_memory = memory_dir.exists() and str(p).startswith(str(memory_dir))
if in_memory:
pass # carve-out: memory files are always included
elif _is_ignored(p, root, ignore_patterns):
continueThis matches the intent stated in the L25 comment. The user's gitignore is opt-in tracking for the rest of graphify-out/; memory files should be exempt because they're explicitly meant to round-trip.
(b) Make the memory dir configurable via env var (GRAPHIFY_MEMORY_DIR) or a .graphifyrc. Users who want memory artifacts elsewhere (e.g. under docs/graphify-qa/) can point graphify at the new path, and the same exemption applies to whatever path is configured.
(a) is the minimum fix. (b) is the larger improvement that solves "I want memory artifacts under docs/ not graphify-out/" cleanly.
Environment
- graphify version: 0.8.17
- Python: 3.13
- Install:
uv tool install graphifyy - Project gitignore:
graphify-out/(single line, common pattern)
Related
save-result --memory-dirflag exists for writing memory to a custom path, but the read-side (detect carve-out) is hardcoded tographify-out/memory/. Asymmetric.
Activity
fix: memory-dir gitignore leak, Pass 2 dedup cross-file identical mer…
safishamsi commentedon May 27, 2026
Fixed in v8 (commit 9f73400). The
_is_ignoredcall at line 938 was unconditional — files ingraphify-out/memory/were correctly walked but then silently filtered by gitignore patterns anyway. One-line fix:if not in_memory and _is_ignored(p, root, ignore_patterns):— the memory carve-out now also exempts from gitignore filtering, so thesave-result → --updateround-trip works correctly even whengraphify-out/is gitignored.feat: BYOND DreamMaker support, --mode deep flag, changelog fixes (#884…
fix: memory-dir gitignore leak, Pass 2 dedup cross-file identical mer…
feat: BYOND DreamMaker support, --mode deep flag, changelog fixes (Gr…