Skip to content

macOS: --update re-extracts everything when corpus path has non-ASCII chars (NFC/NFD manifest mismatch) #2221

Closed

Description

@happiesmen

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_manifest writes keys in whatever form the scan produced.
  • detect_incremental looks up manifest.get(f) and computes deleted_files by raw string comparison.

Concretely, the graph is rebuilt two ways:

  • The post-commit hook / watch._rebuild_code scans Path('.') → NFD paths → NFD manifest.
  • The /graphify --update skill 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

  1. added a commit that references this issue on Jul 27, 2026
    06e5978
  2. added 3 commits that reference this issue on Aug 13, 2026
    e13575f
    356a0b6
    dba7441
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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