Skip to content

feat(mine): add --sync flag to prune drawers for files removed from git tracking #1252

@sokol-matija

Description

@sokol-matija

Problem

When a file is added to .gitignore (or otherwise untracked from git), its drawers remain in the palace indefinitely. There is no way to detect and remove these orphaned drawers without manually running mempalace purge --wing <x> --room <y> or writing a custom ChromaDB script.

Concrete example: A project folder with ~10k files was mined into a room. The folder was later added to .gitignore. The room still holds 10,547 drawers with no supported way to bulk-remove them short of a custom Python script querying ChromaDB directly.

Proposed solution

Add a --sync flag to mempalace mine (or a standalone mempalace sync command) that:

  1. Reads source_path metadata from all drawers in the target wing/room
  2. Checks each path against the current git-tracked file list (git ls-files) and the .gitignore rules
  3. Deletes drawers whose source file is no longer tracked (gitignored, deleted, or moved)
mempalace mine --sync                     # prune orphans in current repo's wing
mempalace mine --sync --wing iis          # scope to one wing
mempalace sync --wing iis --room old-dir  # explicit sync command

Why this should be default (or at least easy)

The mine workflow already tracks filed_away state per file to avoid re-mining. The inverse — removing stale entries — is the natural complement. Without it, palaces grow unboundedly and searches return results for files that no longer exist in the project.

A reasonable default would be: when mempalace mine is run in a git repo, automatically prune drawers whose source_path is now gitignored. This mirrors how tools like ripgrep and git ls-files naturally respect .gitignore.

Related

Neither addresses retrospective cleanup of gitignored files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions