Repository navigation
fix(mcp): return the checksum on reads of files that are not notes - #2179
arturbordignon wants to merge 2 commits into
Conversation
Signed-off-by: Artur Bordignon <arturbordignon6@gmail.com>
Codex Review Summary: ✅ CompletedThis 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: 272bdd3793
ℹ️ 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".
|
|
||
| # A file that is not a note has no note_content row, so its own checksum is the | ||
| # one a caller can verify. Notes carry `db_checksum` instead. | ||
| checksum: Optional[str] = Field(None, description="Checksum of a file that is not a note") |
There was a problem hiding this comment.
Keep the file checksum out of Markdown-note responses
EntityResponseV2 uses from_attributes=True, so validating an ORM Entity fills this field from Entity.checksum without checking its path. The knowledge_router.index_file response does exactly that even though the endpoint only indexes Markdown, and get_entity_by_id does it for legacy fallbacks. Those note responses now expose a physical-file hash as this non-note checksum while db_checksum is null, so clients can mistake it for the accepted note revision. Populate this field only on non-note responses or clear it on note response paths.
AGENTS.md reference: AGENTS.md:L157-L167
Useful? React with 👍 / 👎.
Signed-off-by: Artur Bordignon <arturbordignon6@gmail.com>
|
Good catch, fixed in the latest commit. Rather than clearing the field at each construction site, |
Fixes #2150.
Problem
bm_readreturned no checksum for files that are not Markdown notes. A full read of a PDF or image carried no metadata at all, and locally even a metadata-only read (include_content=false) returnedchecksum: null, because plain files go throughentity_metadata_response_payload, which excludesdb_checksum, andEntityResponseV2had no field forEntity.checksum.Change
As agreed in the issue:
EntityResponseV2gets achecksumfield. Plain files fill it fromEntity.checksumthroughmodel_validate(entity); the accepted-note payload doesn't set it, so notes keepdb_checksumanddb_checksumkeeps its single meaning (Cloud: keep content checksum and storage ETag in separate entity columns #1644).bm_read):db_checksumfor a note andchecksumfor any other file;checksum;{file_path, checksum}in the content block's_meta, so clients can still display it.A text-mode read of a text file stays plain text and makes no extra call.
docs/ai-assistant-guide-extended.mdsays a file's checksum is its SHA-256 locally and the storage ETag in Cloud.Tests
In
tests/mcp/test_tool_bm_read.py, through the real ASGI stack:test_a_file_metadata_read_returns_its_checksum(PNG, PDF, JSON): metadata-only read, non-empty checksum;test_a_binary_read_carries_its_path_and_checksum(PNG/PDF, JSON and text output): full read, non-empty checksum in_meta, equal to the metadata read's;test_a_text_file_json_read_carries_its_checksum: full JSON read of a text file.All fail on
mainand pass with this change.