Skip to content

fix(diary): same-size edits silently skipped — content-hash needed #925

@arnoldwender

Description

@arnoldwender

Bug

diary_ingest.py decides whether a diary file changed by comparing byte length only:

https://github.com/MemPalace/mempalace/blob/develop/mempalace/diary_ingest.py#L123-L128

prev_size = state.get(state_key, {}).get("size", 0)
curr_size = len(text)
if curr_size == prev_size and not force:
    continue

Any in-place edit that preserves total length is silently skipped — no re-ingest, no closet update.

Reproduction

  1. Create ~/diary/2026-04-15.md with content teh quick brown fox (19 chars). Run mempalace diary-ingest.
  2. Edit the file: tehthe (still 19 chars). Save.
  3. Run mempalace diary-ingest again.

Expected: drawer + closets reflect the corrected text.
Actual: file is skipped; the drawer still contains teh. The user's correction never reaches the palace until --force.

Triggering scenarios in real use:

  • Typo fixes (most common — same-length swaps)
  • Replacing one word with another of equal length (bugfix, devqa)
  • Reordering characters (anagram-style edits)
  • Any patch that only changes characters without adding/removing them

Why it matters

This violates the Verbatim always and 100% recall principles in CLAUDE.md — the palace silently holds an outdated version of the user's exact words.

Suggested fix

Replace the size comparison with a sha256 of the file content. Hash collisions on legitimate edits are not a realistic concern for diary text; fixed-cost (~µs) per file. Migration is automatic — when the state file lacks a hash, the first run treats the file as changed (correct fallback).

Happy to send a PR (already drafted at fix/diary-content-hash on my fork).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/hooksClaude Code hook scripts (Stop, PreCompact, SessionStart)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions