Repository navigation
fix(sync): treat a markdown path with a non-markdown type as dirty - #1542
wangzhengzhuo05 wants to merge 1 commit into
Conversation
An indexed row whose file_path is a markdown note but whose content_type is not text/markdown keeps a matching checksum, so change detection reports it unchanged forever and the row is never re-parsed. Mask such a row's checksum to unknown, alongside the existing incomplete-projection masks, so the next scan re-reads the file and repairs the type fields in place. Fixes basicmachines-co#1538 Signed-off-by: wangzhengzhuo05 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35c3a5b237
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| func.lower(Entity.file_path).like("%.md"), | ||
| func.lower(Entity.file_path).like("%.markdown"), |
There was a problem hiding this comment.
Exclude extension-only resource basenames from the mask
For indexed resources named .md or .markdown (for example _phase7_import/.md, which runtime_file_path_is_markdown_note() and the existing regular-file tests intentionally classify as non-Markdown), these SQL LIKE predicates nevertheless match the path. Every subsequent event therefore receives a NULL indexed checksum and re-reads/reindexes the unchanged resource, after which it remains non-Markdown and is masked again, so this derived state never converges. Match the canonical PurePosixPath(...).suffix semantics, including its requirement for a nonempty basename, rather than raw string endings.
AGENTS.md reference: AGENTS.md:L161-L166
Useful? React with 👍 / 👎.
|
Superseded by #1543, which preserves the contributor commit (35c3a5b) and addresses the P2 review finding. Closing to keep the queue clean — thanks @phernandez. |
What
Fixes #1538. A row whose
file_pathis a markdown note but whose indexedcontent_typeis nottext/markdowncan never be repaired, because change detection compares checksums only: the row's checksum already matches the file on disk, so every scan reports itunchangedand it is never re-parsed.Reported shape of the corrupt row (an Emacs autosave took over the real note's
file_path):Appending a single byte to the file repairs the row completely, which shows the repair machinery is healthy — it just cannot be triggered.
How
EntityRepository.get_by_file_paths()already masks an indexed checksum to SQLNULLwhen the indexed projection is known to be incomplete even though the checksum matches (publication_pending,legacy_relation_pending,legacy_markdown_identity). ANULLchecksum makes change detection re-read the canonical bytes.This adds one more predicate to that same mask: the path is a markdown note path (
.md/.markdown, case-insensitive) and the row'scontent_typeis notRUNTIME_MARKDOWN_CONTENT_TYPE. Such a row is now treated as dirty regardless of checksum, so the next scan re-reads the file and_apply_markdown_entity_fields()repairstitle,note_type,permalink,content_typeand the note-content row in place — the same repair the manual one-byte append provokes.Scope is deliberately the first acceptance clause of the issue ("a row whose
file_pathis a markdown path but whosecontent_typeis nottext/markdown"). No API, protocol, or row-shape change:get_by_file_paths()still returns(file_path, checksum).Tests
tests/repository/test_entity_repository.py::test_get_by_file_paths_masks_markdown_path_without_markdown_typenotes/note.md,content_type="text/plain", current checksum) is masked toNone;notes/note.md,content_type="text/markdown") keeps its real checksum, guarding against over-masking.Verification (local)
Mutation check: with
markdown_path_without_markdown_typeremoved from the mask'sor_(...), the new test fails (1 failed); restored, it passes. The test therefore guards this exact predicate and not incidental behaviour.Implemented with AI assistance (OpenCode + muse-spark); reviewed, re-run and mutation-checked by the author before submission.