fix(core): preserve non-Markdown files during moves - #1485
Merged
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Moving a PDF or other non-Markdown entity must preserve its bytes and leave its permalink absent. The explicit move service treated a null permalink as a Markdown identity needing repair, injecting YAML into text files and failing to decode binary files. Directory moves use this same path.
Related: basicmachines-co/basic-memory-cloud#1974.
What Changed
Restrict permalink generation and frontmatter updates in
EntityService.move_entityto Markdown entities. Existing Markdown move and legacy-identity behavior remains intact.Implementation Details
The guard uses the entity's content type. Non-Markdown files retain their external ID, null permalink, and exact bytes while the path and checksum update normally. Regression coverage exercises direct service moves and directory moves for a Dockerfile and binary PDF, with permalink updates enabled and disabled.
Testing
uv run pytest tests/services/test_non_markdown_moves.py tests/services/test_entity_service.py -k 'move' --no-cov -q: 21 passed, including existing Markdown move tests.just fast-check: passed.BASIC_MEMORY_TEST_POSTGRES=1 uv run pytest tests/services/test_non_markdown_moves.py --no-cov -q: 8 passed.just doctor: passed.Risks / Follow-ups
Cloud overrides this move method and requires its own equivalent guard plus a binary-safe S3 checksum fix, tracked by the linked Cloud issue. This PR changes no schema or storage format.