Repository navigation
Description
Summary
On macOS, --update (incremental re-extraction) reports every file as both deleted and new when the corpus path contains non-ASCII characters (e.g. Cyrillic, accented Latin). This forces a full re-extraction — including re-transcribing every video and re-running the LLM on every doc/image — instead of a true incremental update.
Root cause
macOS returns filesystem paths in Unicode NFD form (os.getcwd(), Path('.').resolve() decompose combining characters), while an explicit path string literal is typically NFC. detect.py compares manifest keys as raw strings with no normalization, so the two forms never match:
save_manifestwrites keys in whatever form the scan produced.detect_incrementallooks upmanifest.get(f)and computesdeleted_filesby raw string comparison.
Concretely, the graph is rebuilt two ways:
- The post-commit hook /
watch._rebuild_codescansPath('.')→ NFD paths → NFD manifest. - The
/graphify --updateskill substitutes an explicit path literal → NFC paths.
So the manifest written by one path never matches the scan done by the other. Result: new_total == total_files and deleted == total_files on every run.
Reproduce
import json, tempfile, unicodedata
from pathlib import Path
from graphify.detect import detect, save_manifest, detect_incremental
tmp = Path(tempfile.mkdtemp()) / unicodedata.normalize("NFC", "Пузатый Тренер")
tmp.mkdir(parents=True)
(tmp / "note.md").write_text("body", encoding="utf-8")
mpath = str(tmp / "manifest.json")
save_manifest(detect(tmp)["files"], manifest_path=mpath)
# simulate the other code path writing NFD keys (what macOS getcwd yields):
raw = json.loads(Path(mpath).read_text())
Path(mpath).write_text(json.dumps({unicodedata.normalize("NFD", k): v for k, v in raw.items()}))
inc = detect_incremental(tmp, manifest_path=mpath)
print(inc["new_total"], len(inc["deleted_files"])) # -> 1 1 (expected: 0 0)Fix
Canonicalize paths to NFC wherever a path becomes a manifest key or is compared. Minimal patch to detect.py:
import unicodedata
def _nfc(s: str) -> str:
return unicodedata.normalize("NFC", s)# load_manifest
raw = json.loads(Path(manifest_path).read_text(encoding="utf-8"))
return {_nfc(k): v for k, v in raw.items()}
# save_manifest
manifest[_nfc(f)] = {"mtime": p.stat().st_mtime, "hash": _md5_file(p)}
# detect_incremental
stored = manifest.get(_nfc(f))
...
current_files = {_nfc(f) for flist in full["files"].values() for f in flist}With this, the repro above prints 0 0, and incremental updates work regardless of whether the manifest was written from an NFD (cwd) or NFC (literal) scan.
Environment: graphifyy 0.7.13, macOS (Darwin), Python 3.10.
Activity
test(detect): regression for NFC manifest keys on macOS --update (#2221)
chore: bump to 0.9.28; changelog for #2211/#2213/#2210/#2212/#2215/#2221
fix(detect): NFC-normalize manifest keys so --update survives macOS p…
fix(detect): NFC-normalize manifest keys so --update survives macOS p…
test(detect): regression for NFC manifest keys on macOS --update (Gra…
chore: bump to 0.9.28; changelog for Graphify-Labs#2211/Graphify-Labs…