Repository navigation
Description
Problem
A full bm_read of a non-Markdown binary file (a PDF or an image) returns the file content without a checksum field. Markdown notes and text files include it. A customer's backup job checks each file against Basic Memory's stored checksum. Because of this, it reads the PDF's checksum as empty (length 0), and the check fails on every run, even though the file is intact.
The checksum does exist. bm_read(..., include_content=false) returns it for any file type, and the entity row has it.
Where
src/basic_memory/mcp/tools/read.py, in the # --- Files that are not Markdown notes --- branch:
_present_file(...)returns image content ordocument.to_resource_content(...)for binaries, with no metadata attached.- The text-file path returns a dict through
target.paths.note(...), and the metadata-only path includes"checksum": entity.db_checksum.
The JSON output of bm tool read --json for a binary therefore has no checksum to report.
Second issue: what the checksum means
In Cloud, db_checksum is the storage ETag: 32 hex characters, which for single-part uploads is the MD5 of the bytes. Locally it is SHA-256 (64 hex characters). Projects can even mix both (one production workspace has 32- and 64-character values side by side). Callers have no way to tell which algorithm a value uses, so comparing it with a local SHA-256 fails even when the file is intact.
Proposed
- Include
checksum(andcontent_type,file_path) in the JSON result of a full binary read, matching text files and notes. - Document what the checksum is, or return it with its algorithm (for example
checksum_algorithm: "md5-etag" | "sha256"), so backup and verification tools can compare correctly.
Done when
bm tool read --cloud --jsonon a PDF returns a non-emptychecksum.- The docs (or the response itself) say which hash the checksum is.
- There is a test for a full binary read in JSON output that asserts the checksum is present.
Activity
claude commentedon Nov 25, 2026
Claude finished @phernandez's task in 13s —— View job
Triage
bug,cloud)read.py, non-Markdown branch) and CLI JSON output. The checksum semantics concern Cloud, since the storage ETag is MD5 there and SHA-256 locally.include_content=falsereturns the checksum.checksum,content_typeandfile_pathto the binary read result. This is a small change plus a test.checksum_algorithmfield. This needs a design decision, because Cloud can mix 32-character MD5 ETags and 64-character SHA-256 values in the same project. Inferring the algorithm from the checksum length is fragile, so it would be better to record the algorithm at write time.Duplicates: I searched for existing issues on checksums in binary reads and found none.
Notes: The issue is clear and includes a location, a proposal and acceptance criteria. I did not investigate further or implement anything, because this was triage only.
arturbordignon commentedon Nov 29, 2026
Hi! I'd like to take this one.
Plan: in the non-Markdown branch of
bm_read, addchecksum(fromentity.db_checksum),content_typeandfile_pathto the JSON result for images and documents, matching what a metadata-only read returns. I'll add a test for a full binary read in JSON that asserts a non-empty checksum.For the second part, would you prefer a docs note (SHA-256 locally, the storage ETag in Cloud) or a
checksum_algorithmfield in the response? A docs note keeps this PR small. The field would need the API to report which hash it stored, unless inferring it from the length (32 vs 64 hex characters) is acceptable.arturbordignon commentedon Nov 29, 2026
Quick finding while reproducing: locally,
include_content=falsealso returnschecksum: nullfor a PDF, PNG or JSON file. Plain files go throughentity_metadata_response_payload, which dropsdb_checksumon purpose (ENTITY_METADATA_PAYLOAD_EXCLUDE), andEntityResponseV2has no field forEntity.checksum(the file's SHA-256). My guess is that Cloud fillsdb_checksumwith the storage ETag, which is why it shows up there.The MCP side is ready on my branch: a top-level
checksumin JSON for text files, and{file_path, checksum}in the content block's_metafor images and documents, so clients can still display them.For the API side, which would you prefer?
Entity.checksumfor non-note files through a new field (e.g.checksum), leaving the note-content fields excluded.db_checksumfromEntity.checksumfor non-note files, matching what Cloud returns.phernandez commentedon Nov 29, 2026
Thanks for taking this, @arturbordignon, and for the extra finding about
include_content=false.checksumfield filled fromEntity.checksumfor non-note files, and leavedb_checksumalone. Option 2 would givedb_checksumtwo meanings, which is what Cloud: keep content checksum and storage ETag in separate entity columns #1644 is meant to undo.Your MCP side sounds right: top-level
checksumin JSON for text files, andfile_path/checksumin the content block's_metafor images and documents. Please include a test for a full binary read and one for a metadata-only read, both asserting a non-empty checksum.