#2599·mempalace

Miner ignores .git/info/exclude and has no .worktrees/.claude skip, so a repo with worktrees is mined as N full copies

Author: Crpaxton4Created Sep 25, 2026Updated Sep 25, 2026

Summary

A repository that contains git worktrees gets mined as several full copies of itself, because the miner honours .gitignore files but never .git/info/exclude, and SKIP_DIRS has no entry for the two directories worktrees conventionally live in. On one repo with two worktrees this produced 33,810 duplicate drawers — 52% of the wing — a 1.0 GB chroma.sqlite3, and mines long enough to hold a shared hub's writer lease for over 40 minutes while every other session's reads queued behind it.

Versions: mempalace 3.9.0 (uv tool, Python 3.11.16), chromadb 1.5.9, plugin 3.10.0, embeddinggemma on CPU. Read from site-packages, so line references are to the installed 3.9.0.

1. The miner does not read .git/info/exclude

miner.load_gitignore_matcher loads per-directory .gitignore files only. .git/info/exclude is the per-repo, never-committed exclude list, and it is exactly where worktree paths get excluded — a worktree checked out inside its own repo is the standard reason to use it, because the path must not appear in a committed .gitignore that every clone would then inherit.

With .gitignore alone, scan_project walks into .worktrees/ and .claude/worktrees/ and mines every file there a second time, under the same wing, with different source_file values — so nothing dedupes them.

Ask: have load_gitignore_matcher (or scan_project) also load <repo>/.git/info/exclude for the repository root, with the same rule semantics. For a linked worktree the file lives in the common dir, which git rev-parse --git-common-dir names.

2. SKIP_DIRS has no .worktrees or .claude

palace.SKIP_DIRS already skips .git, node_modules, __pycache__, .venv and friends — directories that are never source. .worktrees and .claude belong in the same category:

  • .worktrees/ is the common convention for keeping git worktree checkouts inside the repo, and every one of them is a duplicate of the tree being mined.
  • .claude/ is agent state — .claude/worktrees/ is more of the same duplication, and the rest is harness scratch (settings, plugin caches, transcripts) that project-mode mining has no use for.

Ask: add both to palace.SKIP_DIRS. If .claude is contentious because some users keep hand-written notes there, .worktrees alone still removes the bulk of the duplication.

3. Read-only tool calls queue behind the write lease

When the MCP server is run as a shared hub (mempalace.mcp_server --transport http), a mempalace_mine inside the palace write path makes the server answer nothing else until it returns. Observed in that session: mempalace_status returned after 19 minutes; two mempalace_search calls were still running at 17 and 4 minutes. The hub logged it itself:

mempalace_mine has been inside the palace write path for 65s and has not returned.
chromadb writes have no timeout: this server now answers nothing else and holds
the writer lease, so peer sessions are read-only.

Nine threads at 100% CPU for 30+ minutes, RSS 6.0 GB, load average 18.5 on 18 cores. Every diary checkpoint in that window also failed with another mine is in progress: palace ... is held by PID ....

Fixes 1 and 2 shrink the mine but do not change the shape of this: any large mine still makes a shared hub unresponsive to reads.

Ask: give read-only tools (mempalace_status, mempalace_search, mempalace_list_*, mempalace_get_drawer) a path that does not wait on the chromadb writer lease.

4. The project auto-mine's hook event cannot be selected

hooks_cli._maybe_auto_ingest() is called from both hook_stop and hook_session_end. On Stop it is gated on SAVE_INTERVAL, a hardcoded module constant of 15 human messages. There is no way to say "mine the project on session end only":

  • no environment variable (the only MEMPALACE_* vars hooks_cli reads are MEMPALACE_PYTHON, MEMPALACE_MINE_PID_FILE and MEMPALACE_MINE_TIMEOUT_HOURS, plus MEMPAL_DIR itself);
  • no mempalace.yaml key and no config.json key (hooks carries auto_save, silent_save, desktop_toast, daemon — all of which affect diary saves too, so switching one off to stop the mine loses the saves);
  • no flag on mempalace hook run, whose arguments are --hook and --harness;
  • and _get_mine_targets() reads only MEMPAL_DIR from the environment, which hooks inherit as one environment — so it cannot be present for one event and absent for another.

A downstream integration therefore has no way to move the project mine to session end while keeping the per-checkpoint diary saves, which is the combination that makes sense when MEMPAL_DIR is a large monorepo.

Ask: a hooks.mine_on config key (or equivalent) taking something like stop / session-end / never, defaulting to today's behaviour. A SAVE_INTERVAL that can be configured would help independently.

Workaround, for anyone hitting this

exclude_patterns in mempalace.yaml does work and is the right escape hatch — it is honoured by mine_project and, importantly, scan_project prunes matching directories during the walk rather than filtering files afterwards, so an excluded worktree costs one stat:

yaml
wing: extra_addons
exclude_patterns:
  - ".worktrees/"
  - ".claude/"
  - ".VSCodeCounter/"

wing has to be set explicitly, because load_config raises KeyError on a yaml without it. Verified with the miner's own scan_project: 776 mineable files before, 388 after, zero worktree paths. Drawers already mined are not affected and need a mempalace_delete_by_source pass per path.

What would make this unnecessary is item 1, since .worktrees/ and **/.claude/worktrees/ were already in that repo's .git/info/exclude — git was told, and the miner did not ask.