Skip to content

fix: disambiguate hook block reasons to name MemPalace explicitly#666

Merged
bensig merged 1 commit intoMemPalace:mainfrom
z3tz3r0:fix/hook-reason-ambiguity-and-contributing-docs
Apr 12, 2026
Merged

fix: disambiguate hook block reasons to name MemPalace explicitly#666
bensig merged 1 commit intoMemPalace:mainfrom
z3tz3r0:fix/hook-reason-ambiguity-and-contributing-docs

Conversation

@z3tz3r0
Copy link
Copy Markdown
Contributor

@z3tz3r0 z3tz3r0 commented Apr 12, 2026

Summary

  • Root cause: Stop and precompact hook block reasons say "your memory system" — ambiguous when Claude Code's system prompt also describes a native auto-memory system (.md files). The always-loaded # auto memory instructions dominate interpretation, so Claude writes markdown files instead of calling MemPalace MCP tools. Result: hooks fire correctly but zero palace drawers are created.
  • hooks_cli.py: rewrite STOP_BLOCK_REASON and PRECOMPACT_BLOCK_REASON to name MemPalace explicitly, list the exact MCP tools (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add), and instruct not to use native auto-memory.
  • hooks/mempal_save_hook.sh, hooks/mempal_precompact_hook.sh: update matching hardcoded reason JSON strings.
  • CONTRIBUTING.md: Getting Started now shows the fork-first workflow, matching the PR Guidelines section.

Test plan

  • pytest tests/ -v — 589 passed, 0 failed
  • grep -r "your memory system" mempalace/ hooks/ — zero matches
  • Verified live: hook fired with new text and was correctly interpreted as a MemPalace save (not native auto-memory)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.
jphein added a commit to jphein/mempalace that referenced this pull request Apr 12, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
jphein added a commit to jphein/mempalace that referenced this pull request Apr 12, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Copy link
Copy Markdown
Collaborator

@bensig bensig left a comment

Choose a reason for hiding this comment

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

Code review clean, CI all green.

@bensig bensig merged commit f138d49 into MemPalace:main Apr 12, 2026
6 checks passed
jphein added a commit to jphein/mempalace that referenced this pull request Apr 12, 2026
…n conflicts

Merge upstream/develop: MemPalace#177, MemPalace#361, MemPalace#449, MemPalace#450 (benchmarks, tilde expand,
duplicate cache vars, test fixture cleanup).

Merge upstream/main: MemPalace#666 (z3tz3r0's block reason disambiguation).
Conflict resolution: keep our scoped "For THIS save" phrasing instead of
MemPalace#666's absolute "Do NOT write to auto-memory" — both memory systems are
used in tandem. Also drop "AAAK-compressed" from diary instructions since
diary_write is plain text, not AAAK dialect.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
igorls added a commit that referenced this pull request Apr 13, 2026
bensig added a commit that referenced this pull request Apr 13, 2026
* fix: disambiguate hook block reasons to name MemPalace explicitly (#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.

* fix: remove chromadb <0.7 upper bound — blocks 1.x installs

The current constraint `chromadb>=0.5.0,<0.7` forces pip to install
chromadb 0.6.x, but palaces created with chromadb 1.x (which is what
the mempalace dev environment actually uses — 1.5.7 per uv.lock) have
an incompatible SQLite schema. Specifically, chromadb 0.6.x fails with
`KeyError: '_type'` when opening a collection written by 1.x.

This means a fresh `pip install mempalace` gives users a chromadb
version that cannot read palaces created in the maintainer's own
environment. The fix removes the upper bound so pip can resolve to the
current stable chromadb release.

Reproduction:
  python3 -m venv .venv && source .venv/bin/activate
  pip install mempalace          # installs chromadb 0.6.3
  # Try opening a palace created with chromadb 1.x:
  # -> _get_collection() returns None, tool_status() returns "No palace found"
  pip install chromadb==1.5.7    # force upgrade
  # -> tool_status() returns real data (26k drawers in our case)

---------

Co-authored-by: z3tz3r0 <[email protected]>
Co-authored-by: AlyciaBHZ <[email protected]>
Co-authored-by: Ben Sigman <[email protected]>
igorls added a commit that referenced this pull request Apr 13, 2026
igorls added a commit that referenced this pull request Apr 13, 2026
Post-release back-merge bringing:
- v3.2.0 version bumps (pyproject.toml, version.py, README badge, SKILL.md)
- #690 unbounded chromadb pin
- #666 hook block reasons
- CHANGELOG: [Unreleased] → [3.2.0] — 2026-04-13
- CONTRIBUTING.md: fork-first flow + correct MemPalace upstream URL
arnoldwender pushed a commit to arnoldwender/mempalace that referenced this pull request Apr 13, 2026
…mPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.
jphein added a commit to jphein/mempalace that referenced this pull request Apr 13, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
sha2fiddy pushed a commit to sha2fiddy/mempalace that referenced this pull request Apr 13, 2026
* fix: disambiguate hook block reasons to name MemPalace explicitly (MemPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.

* fix: remove chromadb <0.7 upper bound — blocks 1.x installs

The current constraint `chromadb>=0.5.0,<0.7` forces pip to install
chromadb 0.6.x, but palaces created with chromadb 1.x (which is what
the mempalace dev environment actually uses — 1.5.7 per uv.lock) have
an incompatible SQLite schema. Specifically, chromadb 0.6.x fails with
`KeyError: '_type'` when opening a collection written by 1.x.

This means a fresh `pip install mempalace` gives users a chromadb
version that cannot read palaces created in the maintainer's own
environment. The fix removes the upper bound so pip can resolve to the
current stable chromadb release.

Reproduction:
  python3 -m venv .venv && source .venv/bin/activate
  pip install mempalace          # installs chromadb 0.6.3
  # Try opening a palace created with chromadb 1.x:
  # -> _get_collection() returns None, tool_status() returns "No palace found"
  pip install chromadb==1.5.7    # force upgrade
  # -> tool_status() returns real data (26k drawers in our case)

---------

Co-authored-by: z3tz3r0 <[email protected]>
Co-authored-by: AlyciaBHZ <[email protected]>
Co-authored-by: Ben Sigman <[email protected]>
sha2fiddy pushed a commit to sha2fiddy/mempalace that referenced this pull request Apr 14, 2026
* fix: disambiguate hook block reasons to name MemPalace explicitly (MemPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.

* fix: remove chromadb <0.7 upper bound — blocks 1.x installs

The current constraint `chromadb>=0.5.0,<0.7` forces pip to install
chromadb 0.6.x, but palaces created with chromadb 1.x (which is what
the mempalace dev environment actually uses — 1.5.7 per uv.lock) have
an incompatible SQLite schema. Specifically, chromadb 0.6.x fails with
`KeyError: '_type'` when opening a collection written by 1.x.

This means a fresh `pip install mempalace` gives users a chromadb
version that cannot read palaces created in the maintainer's own
environment. The fix removes the upper bound so pip can resolve to the
current stable chromadb release.

Reproduction:
  python3 -m venv .venv && source .venv/bin/activate
  pip install mempalace          # installs chromadb 0.6.3
  # Try opening a palace created with chromadb 1.x:
  # -> _get_collection() returns None, tool_status() returns "No palace found"
  pip install chromadb==1.5.7    # force upgrade
  # -> tool_status() returns real data (26k drawers in our case)

---------

Co-authored-by: z3tz3r0 <[email protected]>
Co-authored-by: AlyciaBHZ <[email protected]>
Co-authored-by: Ben Sigman <[email protected]>
sha2fiddy pushed a commit to sha2fiddy/mempalace that referenced this pull request Apr 14, 2026
…mPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.
igorls added a commit that referenced this pull request Apr 14, 2026
Main had 9 commits that never back-merged into develop after the v3.2.0
release cycle. Resolving conflicts as follows:

- mempalace/version.py: keep develop (3.3.0 release target)
- README.md: keep develop (Milla's #835 audit is authoritative — main
  had stale 19 tools / 170 tokens / "30x lossless" / v3.0.0 label)
- hooks/mempal_{save,precompact}_hook.sh: keep develop (#786 reversed
  the #666 "decision=block" behavior intentionally to stop hooks from
  making agents write in chat)
- pyproject.toml: auto-merged — keeps develop's 3.3.0 and picks up
  main's chromadb upper-bound removal (#690)
- CONTRIBUTING.md, mempalace/hooks_cli.py: auto-merged cleanly —
  picks up main's improvements (fork-first clone, more detailed
  block reason strings that name MemPalace and specific tools)
- integrations/openclaw/SKILL.md: bumped 3.2.0 → 3.3.0 (version
  tracks the package per #761 convention)
- CHANGELOG.md: manual merge — kept develop's preamble + Unreleased
  v3.3.0 section + footer links; folded main's richer v3.2.0 entries
  (Packaging section for #690/#761; Bug Fixes #685/#677/#716/#707/
  #755/#757; Documentation #734/#733) into the v3.2.0 section;
  deduped the split Documentation sections that auto-merge produced
igorls added a commit that referenced this pull request Apr 14, 2026
Bring back the main-only content that develop has been missing:
- pyproject.toml chromadb upper-bound removal (#690)
- CHANGELOG [3.2.0] Packaging subsection (#690, #761)
- CONTRIBUTING.md fork-first clone instructions
- mempalace/hooks_cli.py richer block-reason strings (from #666,
  still used by the Python hook invocation path)
- integrations/openclaw/SKILL.md version bump to 3.3.0

Plus the v3.3.0 release commit itself (4aa7e1e) and the legacy
main-only commits (#666, #690, v3.2.0 finalization) for history.

Resolves the main → develop drift that caused PR #838's conflicts.
Going forward, back-merging main to develop after each release
will prevent the same pattern.

Single conflict in CHANGELOG.md resolved by taking main's version
(the Packaging subsection under [3.2.0]).
sha2fiddy pushed a commit to sha2fiddy/mempalace that referenced this pull request Apr 14, 2026
…mPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.
jphein added a commit to jphein/mempalace that referenced this pull request Apr 16, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
jphein added a commit to jphein/mempalace that referenced this pull request Apr 19, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
jphein added a commit to jphein/mempalace that referenced this pull request Apr 19, 2026
…uto-memory

Block reasons now:
- Name "(MemPalace)" explicitly to avoid confusion with auto-memory
- Add mempalace_kg_add as optional step 3
- Explicitly say "Do NOT write to Claude Code's native auto-memory (.md files)"

Addresses the same root cause as MemPalace#666: Claude's auto-memory system prompt
can dominate generic "save to your memory system" instructions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
sha2fiddy pushed a commit to sha2fiddy/mempalace that referenced this pull request Apr 20, 2026
…mPalace#666)

Replace "your memory system" with explicit MemPalace references and
tool names (mempalace_diary_write, mempalace_add_drawer, mempalace_kg_add)
in stop and precompact hook block reasons. This prevents Claude Code from
misinterpreting the hook as a native auto-memory save instruction.

Updated in both Python (hooks_cli.py) and standalone shell scripts.

Also fix CONTRIBUTING.md Getting Started to show the fork-first workflow,
matching the PR Guidelines section.
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.

2 participants