Skip to content

fix(mcp): return full checksums from legacy note tools - #1877

Closed
remote-controlled-man wants to merge 2 commits into
basicmachines-co:mainfrom
remote-controlled-man:codex/prflow-5933a5971d6d
Closed

remote-controlled-man wants to merge 2 commits into
basicmachines-co:mainfrom
remote-controlled-man:codex/prflow-5933a5971d6d

Conversation

@remote-controlled-man

@remote-controlled-man remote-controlled-man commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1874.

The legacy write_note and edit_note text results shortened the accepted checksum to eight characters. Reusing the displayed value as expected_checksum rejected an unchanged note. Return the full checksum for create, overwrite, edit and auto-create results, and synchronize the two existing generated manual pages. The exact revision comparison and stale-write protection are unchanged.

Validation on macOS / Python 3.12, at 478c957:

Canonical justfile suite Passed Skipped Deselected
SQLite unit 8,927 82 0
SQLite integration 759 14 40
PostgreSQL unit 8,920 89 0
PostgreSQL integration 762 11 40

Executed through the upstream scripts/run_tests.py file shards (4/2/6/4), with separate PostgreSQL databases. All 16 shards completed with exit 0 and exhaustive, disjoint file selection. The integration marker not semantic and not benchmark, assertions and per-test timeouts were preserved.

The new regression uses a real MCP client/server, ASGI API and database: each text checksum permits the next conditional overwrite, then rejects a stale overwrite without changing content. All eight initially failing test files plus the new regression passed in a focused run (333 passed). Full-repository Ruff, formatting, ty check src tests test-int, sandboxed doctor --local and git diff --check passed.

The initial SQLite unit run exposed local timezone/temp-directory/CLI PATH/just setup problems and the stale manual blocks. These were corrected before the focused run and complete four-suite rerun. The test services and their data volume were removed afterward.

Prepared with AI assistance (Codex). No external model API was used.

Summary by CodeRabbit

  • Bug Fixes
    • Text responses for created, updated, and edited notes now display the full checksum, making it available for conditional updates.
    • Reusing a stale checksum still results in a revision conflict, and the replacement content remains unchanged.
  • Documentation
    • Clarified that checksums from read results or previous write and edit results can be used for conditional updates.

Signed-off-by: Steven Huang <134844631+remote-controlled-man@users.noreply.github.com>
Signed-off-by: Steven Huang <134844631+remote-controlled-man@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 03:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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 ⚠️ Failed 2026-10-27T04:00:46.693453Z
We couldn’t complete this review. Comment @codex review to try again.
478c957 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.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b8fe8d7-eeb7-4918-a851-0ed31f3b625e
Commits

Reviewing files that changed from the base of the PR and between 438d497 and 478c957.

Files selected for processing: 5
  • src/basic_memory/man/man3/edit-note(3).md
  • src/basic_memory/man/man3/write-note(3).md
  • src/basic_memory/mcp/tools/edit_note.py
  • src/basic_memory/mcp/tools/write_note.py
  • test-int/mcp/test_text_checksum_preconditions.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Text output from write_note and edit_note now includes the full checksum. Their expected_checksum documentation describes JSON read results and prior write/edit results as checksum sources. Integration coverage checks use of a receipt checksum for an overwrite and rejection after the note revision changes.

Changes: Checksum receipts

Layer / File(s) Summary
Full checksums in text receipts
src/basic_memory/mcp/tools/write_note.py, src/basic_memory/mcp/tools/edit_note.py, src/basic_memory/man/man3/write-note(3).md, src/basic_memory/man/man3/edit-note(3).md, test-int/mcp/test_text_checksum_preconditions.py
The tools display full checksums in text output. Their documentation describes checksum sources from JSON reads or prior write/edit results. The integration test checks that a receipt checksum permits an overwrite and that reusing the stale checksum causes a revision conflict.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: phernandez

Merge Risk: Minimal · up to 478c9

Text receipts now provide full checksums for conditional writes. No material merge risk is identified.

Architecture risk: Low · up to 478c9

The change affects 2 systems.

Changed systems: src, test-int

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 4 changed files map to changed impact.
  • observed — test-int (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/basic_memory/man/man3/edit-note(3).md: The expected_checksum description no longer limits write/edit checksums to JSON mode or notes that text output shows only the first eight characters; it retains the revision-conflict and no-write behavior.
  • observed — Modified behavior in src/basic_memory/man/man3/write-note(3).md: The expected_checksum description replaces the named bm_read, bm_write, and bm_edit JSON results with a generic JSON read result or previous write/edit result as checksum sources; its documented revision precondition and conflict outcome remain unchanged.
  • observed — Modified behavior in src/basic_memory/mcp/tools/edit_note.py: The expected_checksum documentation now accepts the full checksum from a JSON read result or previous write/edit result; it no longer specifies JSON mode or notes that text output shows only the first eight characters.
  • observed — Modified behavior in src/basic_memory/mcp/tools/edit_note.py: The example now describes the checksum as coming from a previous result, replacing the narrower reference to a read or JSON result.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: legacy MCP note tools (write_note and edit_note) now return full checksums in text output instead of shortened eight-character checksums. The raw summary confirms this…
Linked Issues check Passed [#1874] requires text output from write_note and edit_note to show the full checksum, with the expected_checksum comparison kept as an exact match. The diff at head meets this. In write_note.py, the t…
Out of Scope Changes check Passed All changed hunks relate to #1874. The write_note.py and edit_note.py changes replace the eight-character truncation in text output. The docstring edits in these files and in the two generated manual …
Full details: Title check

Explanation

The title names the main change: legacy MCP note tools (write_note and edit_note) now return full checksums in text output instead of shortened eight-character checksums. The raw summary confirms this change in the edit_note.py and write_note.py tools, and the linked issue #1874 asks for the same behavior. The title is specific, concise, and uses a conventional commit prefix, so it passes.

Full details: Linked Issues check

Explanation

[#1874] requires text output from write_note and edit_note to show the full checksum, with the expected_checksum comparison kept as an exact match. The diff at head meets this. In write_note.py, the text checksum line changes from checksum[:8] to the full checksum. In edit_note.py, both the created-note and edited-note text branches (formerly lines 1000 and 1011) change the same way. No comparison logic changed, so the exact-match precondition and stale-write protection are unchanged. The new integration test test-int/mcp/test_text_checksum_preconditions.py covers created, updated, edited, and auto-created receipts. For each, it reads the text checksum, confirms it is 64 characters, uses it as expected_checksum for a conditional overwrite that succeeds, and confirms that a reuse of the stale checksum fails with a revision conflict and leaves the replacement content intact. The issue asks for a coding fix only, so no non-coding requirements apply. The author reports the test suite results. Those results were not re-run in this review.

Full details: Out of Scope Changes check

Explanation

All changed hunks relate to #1874. The write_note.py and edit_note.py changes replace the eight-character truncation in text output. The docstring edits in these files and in the two generated manual pages (edit-note(3).md and write-note(3).md) describe the expected_checksum source as a JSON read result or a previous write/edit result. Because the text output now carries the full checksum, these edits keep the documented guidance accurate. They do not alter the tool contract or the comparison logic. The new integration test supports the objective directly. No unrelated behavior change appears in the reviewed hunks. The CLA status comment in the PR objectives is not a repository change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@CLAassistant

CLAassistant commented Oct 27, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@phernandez

Copy link
Copy Markdown
Member

Thank you, Steven, for identifying this checksum issue, preparing the fix, and doing such thorough regression testing. The bug and your fix are valid. We have decided to remove the legacy write_note and edit_note MCP tools entirely for 1.0, without compatibility aliases; that removal is covered by #1881 as part of #1833. Because this PR specifically fixes the retiring MCP text responses, we are closing it as superseded by that removal. We appreciate the care and time you put into this contribution.

@phernandez phernandez closed this Oct 27, 2026
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.

[BUG] Text output of write_note and edit_note shows an 8-character checksum that expected_checksum rejects

4 participants