Repository navigation
fix(detect): NFC-normalize manifest keys for macOS --update - #2224
SyedFahad7 wants to merge 2 commits into
Conversation
…ath forms macOS yields NFD paths from os.walk/getcwd while skill path literals are often NFC. Raw string compare treated every file as deleted+new and forced a full re-extract. Canonicalize at the manifest boundary (same idea as Graphify-Labs#1226). Fixes Graphify-Labs#2221
There was a problem hiding this comment.
Pull request overview
This PR fixes macOS incremental update behavior by NFC-normalizing manifest keys at the manifest boundary, so scans that yield NFD paths (e.g., via os.walk() / getcwd()) still match prior manifests written with NFC path literals (Issue #2221).
Changes:
- Added
_nfc()helper and applied NFC normalization when loading and saving manifest keys. - Updated incremental comparison (
detect_incremental) to normalize scanned file paths before manifest lookups and deletion checks. - Hardened
save_manifest()pruning/clear-semantic membership checks to tolerate NFC/NFD mismatches in the provided path sets.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # NFC after relativize so on-disk keys match what load_manifest | ||
| # re-anchors and compares against (#2221). | ||
| manifest = {_nfc(_to_relative_for_storage(k, root)): v for k, v in manifest.items()} | ||
| else: | ||
| manifest = {_nfc(k): v for k, v in manifest.items()} |
There was a problem hiding this comment.
good catch — pushed a follow-up. _to_relative_for_storage now NFC's both the key and Path(root).resolve() before relpath, and the absolute re-anchor join NFC's the result too. should keep the #777 relative keys intact on macOS non-ASCII roots.
| def _nfc(s: str) -> str: | ||
| """NFC-normalize a path string used as a manifest key. | ||
|
|
||
| On macOS, ``os.walk`` / ``getcwd`` yield NFD paths while path literals | ||
| and many skill-substituted roots are NFC. Raw string compare then treats |
There was a problem hiding this comment.
fair point. kept this PR to the detect.py fix only for now — happy to add a regression test in a follow-up if maintainers want it in-tree.
Stamped keys can already be NFC while Path(root).resolve() is NFD, so os.path.relpath treated in-root files as ../ and kept them absolute. Normalize both operands inside _to_relative_for_storage (and the join in _to_absolute_from_storage).
Adds the regression test PR #2224 shipped without: an NFD-keyed manifest (portable and legacy-absolute) must match an NFC scan so --update is a no-op instead of re-extracting everything. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Thanks @SyedFahad7. Shipped in v0.9.28 (cherry-picked to v8), with the NFC regression test added as a follow-up. Closed-unmerged here, but it's in the release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.28 |
…phify-Labs#2221) Adds the regression test PR Graphify-Labs#2224 shipped without: an NFD-keyed manifest (portable and legacy-absolute) must match an NFC scan so --update is a no-op instead of re-extracting everything. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes #2221.
On macOS,
os.walk/getcwdhand back NFD paths, but a lot of callers pass NFC path literals (skill--update, etc). Manifest lookup was a raw string compare, so every file looked deleted + new and--updaterebuilt the whole corpus.Same idea as the office sidecar hash fix in #1226 — just NFC the keys at the manifest boundary (load / save / incremental compare).
Test plan
--updatewith no real changes — should report 0 new / 0 deleteduv run pytest tests/test_detect.py -q(or full suite if you prefer)