Skip to content

fix(core): preserve non-Markdown files during moves - #1485

Merged
phernandez merged 1 commit into
mainfrom
fix-non-markdown-moves
Sep 6, 2026
Merged

fix(core): preserve non-Markdown files during moves#1485
phernandez merged 1 commit into
mainfrom
fix-non-markdown-moves

Conversation

@phernandez

@phernandez phernandez commented Sep 6, 2026

Copy link
Copy Markdown
Member

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_entity to 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

  • All eight new cases fail against the original implementation with rewritten text or binary decoding errors.
  • 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.

Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 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-09-06T01:32:19.718250Z b00b278 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.

@phernandez
phernandez merged commit 495356c into main Sep 6, 2026
35 checks passed
@phernandez
phernandez deleted the fix-non-markdown-moves branch September 6, 2026 02:05
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.

1 participant