Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80412204e8
ℹ️ 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".
| sa.text("DELETE FROM note_content WHERE entity_id = :keeper"), {"keeper": keeper} | ||
| ) | ||
| connection.execute( | ||
| sa.text("UPDATE note_content SET entity_id = :keeper WHERE entity_id = :owner"), |
There was a problem hiding this comment.
Re-key moved note content to the keeper's external ID
When _keep_unwritten_note_content selects a twin row (notably the pending-write preservation case), this update changes only entity_id; the row's external_id still names the entity deleted below, even though NoteContentRepository._align_identity_fields requires it to mirror the owning entity. /knowledge/entities/batch filters on NoteContent.external_id, so asking for the surviving keeper ID reports that canonical accepted write as missing until a later edit happens to realign it; update the mirrored external ID as part of the adoption.
AGENTS.md reference: AGENTS.md:L157-L161
Useful? React with 👍 / 👎.
8041220 to
4ed3941
Compare
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 (basicmachines-co#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 basicmachines-co#1275 Signed-off-by: Sergey Sinyugin <[email protected]>
4ed3941 to
eeaee64
Compare
|
Thank you @sergi039, this is excellent work, and it follows the #1275 design closely. Fork PRs don't get our full CI matrix, so I've moved your commit unchanged (authorship and sign-off intact) to #1766. It will be rebase-merged so it lands on main as yours. Two follow-up commits there: the Codex P1 (the migration now re-keys |
Fixes #1275.
Problem
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
-1twin;edit_noteon such a note then fails withUNIQUE constraint failed: entity.permalink. On one vault (12.7k notes, macOS + Syncthing) this left 60 twin pairs.Change
Following the layer @phernandez described in #1275 — the ingest boundary, not
get_by_file_path:utils.nfc_path()— NFC on macOS; byte-exact on Linux and Windows, whose filesystems store NFC and NFD names as distinct files.index/local_project.py), watcher (index/filesystem.py),/index-file(_canonical_file_path, which also matches entries across forms), title/directory → path inschemas/base.py(the directory is normalized beforesanitize_for_directory, which otherwise drops combining marks from NFD input), move destination (runtime/note_move.py), document import, andgenerate_permalink.0042(macOS only) for existing indexes:note_contentnotsynced) — two such writes for one file stop the upgrade with an explicit error instead of dropping one;relation.to_id,note_file_vacate.entity_id,accepted_project_note_change.entity_id; drops an edge that would duplicate one into the kept row (uix_relation_from_id_to_id);Tests
tests/index/test_unicode_path_normalization.py— each boundary; the scanner, watcher, move and title tests fail on currentmainand pass here.tests/test_nfc_file_paths_migration.py— twin merge, unwritten content kept over a fresher synced copy, refusal on two unwritten writes, edge de-duplication, vacate marker selection by on-disk checksum.test_search_with_date_filter,test_recent_activity_format_relative_time_and_truncate_helpers) also fail on unmodifiedmain— they depend on the current date.tyclean apart from the pre-existing optionalpymilvusimports. Not run: Postgres suite, integration tests, Windows.Notes