Skip to content

fix(core): give the move-orphan gate a content-checksum source - #1160

Merged
jope-bm merged 1 commit into
mainfrom
fix-move-orphan-gate-checksum-1601
Jul 27, 2026
Merged

fix(core): give the move-orphan gate a content-checksum source#1160
jope-bm merged 1 commit into
mainfrom
fix-move-orphan-gate-checksum-1601

Conversation

@jope-bm

@jope-bm jope-bm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

The move-vacate gate added in #1152 (basic-memory-cloud#1601) compares a path's vacate marker against the current object's checksum using the checker's single current_checksum_source. That same source drives the freshness decision, so it is effectively locked to whatever checksum domain the store indexes by.

  • Local: one SHA-256 content checksum is used everywhere (freshness, index, note content, marker), so the gate works.
  • Basic Memory Cloud: the S3 index pipeline keys on the object ETag, but note content (and therefore the vacate marker, recorded from the note's source checksum) is SHA-256. These are different domains, and a single marker value cannot satisfy both the gate (compared against the ETag freshness checksum) and the delete-guard/clear lifecycle (SHA-256). The result is that the gate never matches a real orphan and instead retires the marker and re-imports the ghost — i.e. the fix is inert in cloud.

Change

Add an optional move_orphan_checksum_source: CurrentFileChecksumSource | None = None to FileIndexChecker, used only for the marker comparison in _apply_move_orphan_gate (the retire and tombstone paths). When it is None the gate falls back to current_checksum, so behavior is unchanged for local and any single-domain store. The gap-(a) moved-entity comparison keeps using current_checksum because both sides are the entity/freshness domain.

Cloud will pass a SHA-256 (bm-file-checksum object metadata) source here.

Risk

Backward-compatible and opt-in: the new field defaults to None. No existing caller passes it, so local indexing is byte-for-byte unchanged (verified: the 22 existing checker tests pass untouched).

Testing

ty + ruff clean. Added test_checker_gate_uses_content_checksum_source_when_domains_differ: with a freshness checksum (ETag) deliberately different from the marker's content checksum, the gate consults the content source, suppresses the leftover, and does not retire the marker. 23 checker tests pass.

Companion: basic-memory-cloud#1613.

🤖 Generated with Claude Code

The move-vacate gate (#1601) compares a path's vacate marker against the current
object's checksum via the checker's single current_checksum_source. That source
also drives the freshness decision, so it is locked to whatever domain the store
indexes by. On local that is the SHA-256 content checksum everywhere, so the gate
works. A store whose freshness domain differs from note content — Basic Memory
Cloud indexes by S3 ETag while note content (and therefore the marker) is SHA-256
— cannot satisfy both: the marker is content-domain, the freshness checksum is
ETag-domain, so the gate would never match a real orphan and would instead retire
the marker and re-import the ghost.

Add an optional move_orphan_checksum_source used only for the marker comparison
(retire + tombstone paths). It defaults to None, in which case the gate falls
back to current_checksum and behavior is unchanged for local and any single-domain
store. The gap-(a) moved-entity comparison stays on current_checksum because both
sides are the entity/freshness domain.

Cloud will pass a SHA-256 (bm-file-checksum) source here; see
basic-memory-cloud#1601 / PR #1613.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Joe P <joe@basicmemory.com>
@jope-bm
jope-bm merged commit 4c3b278 into main Jul 27, 2026
25 checks passed
@jope-bm
jope-bm deleted the fix-move-orphan-gate-checksum-1601 branch July 27, 2026 14:56
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