Files
mempalace/mempalace
jp 247744296d fix(blob-seq-marker): tests + style nit per @igorls #1177 review
Three new tests cover the marker contract:

- test_fix_blob_seq_ids_writes_marker_after_blob_path — marker is
  written after a successful BLOB → INTEGER conversion.
- test_fix_blob_seq_ids_writes_marker_when_already_integer — marker
  is written even on a no-op (already-INTEGER) path. The point of
  the marker is to skip sqlite3.connect() on subsequent calls, not
  to record that a conversion happened.
- test_fix_blob_seq_ids_skips_sqlite_when_marker_present — verifies
  the load-bearing property via monkeypatched sqlite3.connect: when
  the marker exists, the function never opens sqlite. This is the
  bug #1090 fix — opening Python's sqlite3 against a live ChromaDB
  1.5.x WAL DB corrupts the next PersistentClient call, and we
  must never do it again post-migration.

Also folded in @igorls's style nit:

- Path(marker).touch() instead of open(marker, "a").close().
  Same effect, reads cleaner. Moved Path import to the top of the
  module since it didn't yet exist there.

35/35 backend tests pass. The "Production: fresh MCP server + stop
hook + mempalace mine subprocess" checkbox in the PR body is checked
in the PR reply — the canonical 151K palace has been running this
fix since #1177 was filed (via Syncthing-replicated source on the
disks daemon at v1.7.0); zero PersistentClient corruption since.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-26 13:21:50 -07:00
..
2026-04-13 18:25:01 -07:00
2026-04-13 18:25:01 -07:00
2026-04-13 18:25:01 -07:00
2026-04-23 16:44:22 -07:00

mempalace/ — Core Package

The Python package that powers MemPalace. All modules, all logic.

Modules

Module What it does
cli.py CLI entry point — routes to mine, search, init, compress, wake-up
config.py Configuration loading — ~/.mempalace/config.json, env vars, defaults
normalize.py Converts 5 chat formats (Claude Code JSONL, Claude.ai JSON, ChatGPT JSON, Slack JSON, plain text) to standard transcript format
miner.py Project file ingest — scans directories, chunks by paragraph, stores to ChromaDB
convo_miner.py Conversation ingest — chunks by exchange pair (Q+A), detects rooms from content
searcher.py Semantic search via ChromaDB vectors — filters by wing/room, returns verbatim + scores
layers.py 4-layer memory stack: L0 (identity), L1 (critical facts), L2 (room recall), L3 (deep search)
dialect.py AAAK compression — entity codes, emotion markers, 30x lossless ratio
knowledge_graph.py Temporal entity-relationship graph — SQLite, time-filtered queries, fact invalidation
palace_graph.py Room-based navigation graph — BFS traversal, tunnel detection across wings
mcp_server.py MCP server — 19 tools, AAAK auto-teach, Palace Protocol, agent diary
onboarding.py Guided first-run setup — asks about people/projects, generates AAAK bootstrap + wing config
entity_registry.py Entity code registry — maps names to AAAK codes, handles ambiguous names
entity_detector.py Auto-detect people and projects from file content
general_extractor.py Classifies text into 5 memory types (decision, preference, milestone, problem, emotional)
room_detector_local.py Maps folders to room names using 70+ patterns — no API
spellcheck.py Name-aware spellcheck — won't "correct" proper nouns in your entity registry
split_mega_files.py Splits concatenated transcript files into per-session files

Architecture

User → CLI → miner/convo_miner → ChromaDB (palace)
                                     ↕
                              knowledge_graph (SQLite)
                                     ↕
User → MCP Server → searcher → results
                  → kg_query → entity facts
                  → diary    → agent journal

The palace (ChromaDB) stores verbatim content. The knowledge graph (SQLite) stores structured relationships. The MCP server exposes both to any AI tool.