Skip to content

fix(core): normalize file paths to NFC at the ingest boundary on macOS - #1766

Merged
phernandez merged 3 commits into
mainfrom
fix/1275-nfc-paths
Oct 14, 2026
Merged

phernandez merged 3 commits into
mainfrom
fix/1275-nfc-paths

Conversation

@phernandez

Copy link
Copy Markdown
Member

Supersedes #1765 by @sergi039. Fixes #1275.

The first commit is @sergi039's change, cherry-picked unchanged with authorship and sign-off intact. It moves to an in-repo branch so the full CI matrix runs (fork PRs skip it). Please rebase-merge so their commit lands on main as their own.

See #1765 for the full design: NFC normalization at the ingest boundary (scanner, watcher, /index-file, title → path, move destination, generate_permalink), byte-exact paths on Linux and Windows, and migration 0042, which merges existing NFC/NFD twin entities on macOS.

Maintainer follow-ups

  • Re-key adopted note content (Codex P1 on fix(core): normalize file paths to NFC at the ingest boundary on macOS #1765). When the migration moves a twin's unwritten note_content row to the kept entity, it now updates external_id along with entity_id. Reads look note content up by external_id (note_content_reads.py), so the accepted write would otherwise look missing until the next edit. The regression test fails without the fix.
  • Cover the macOS path in CI. The NFC and migration tests skipped off macOS, but CI runs the full suite only on Linux and Windows, so none of that code ran in CI. The tests now pin sys.platform to darwin. Both filesystems can hold an NFD name, and nfc_path and the migration decide by sys.platform alone.
  • Nits: the test docstring no longer says Windows resolves both spellings to one file, and the utils imports are sorted.

Verification

  • just fast-test on the new suites plus tests/test_migration_graph.py: 36 passed (macOS)
  • just typecheck: clean
  • Linux and Windows coverage of the pinned tests comes from this PR's CI

🤖 Generated with Claude Code

https://claude.ai/code/session_01QjnYzcPoFtqTK5yNphjLS4

sergi039 and others added 3 commits October 14, 2026 11:19
macOS filesystems resolve the NFC and NFD spellings of a name to one file
but report whichever form is on disk, and Syncthing keeps NFD names on
macOS. Paths are identity keys, so a name flipped to NFD rewrote an
entity's key or minted a -1 twin, after which edit_note failed on the
permalink constraint (#1275).

Normalize where relative paths enter the index: scanner, watcher,
/index-file, title and directory to path (before sanitizing, which drops
combining marks), move destination, document import, and
generate_permalink. Linux and Windows keep byte-exact paths, since their
filesystems store NFC and NFD names as distinct files.

Migration 0042 (macOS only) merges existing twins into the oldest row,
keeps an accepted write that has not reached disk, redirects references,
drops edges that would duplicate one into the kept row, keeps the vacate
marker whose checksum matches the file on disk, and stores every path in
NFC. Two unwritten writes for one file stop the upgrade instead of
dropping one.

Fixes #1275

Signed-off-by: Sergey Sinyugin <13364190+sergi039@users.noreply.github.com>
The 0042 migration moved a twin's unwritten note_content row to the kept
entity by entity_id only, leaving external_id naming the deleted twin.
Reads look note content up by external_id, so the accepted write looked
missing until a later edit realigned it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjnYzcPoFtqTK5yNphjLS4
Signed-off-by: phernandez <paul@basicmachines.co>
The NFC tests and the 0042 migration tests skipped off macOS, and CI runs
the full suite only on Linux and Windows, so none of that code ran in CI.
Pin sys.platform to darwin instead: both filesystems can hold an NFD name,
and nfc_path and the migration decide by sys.platform alone. Also fix the
test docstring that said Windows resolves both spellings to one file, and
sort the utils imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QjnYzcPoFtqTK5yNphjLS4
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T16:25:55.804901Z 1e99e1a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e99e1ada8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@phernandez
phernandez merged commit 0b51c22 into main Oct 14, 2026
36 checks passed
@phernandez
phernandez deleted the fix/1275-nfc-paths branch October 14, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file_path lookups are byte-wise, so NFC/NFD filename variants create duplicate entities (macOS + Syncthing)

2 participants