Skip to content

fix(cli): honor --palace flag in cmd_init (#1313)#1321

Merged
igorls merged 2 commits intodevelopfrom
fix/1313-init-palace-flag
May 3, 2026
Merged

fix(cli): honor --palace flag in cmd_init (#1313)#1321
igorls merged 2 commits intodevelopfrom
fix/1313-init-palace-flag

Conversation

@igorls
Copy link
Copy Markdown
Member

@igorls igorls commented May 3, 2026

Closes #1313.

Root cause

cmd_init instantiated MempalaceConfig() without honoring args.palace. Every other command (cmd_status, cmd_mine, cmd_search, cmd_repair, cmd_compress, cmd_wakeup) resolves --palace first via os.path.expanduser(args.palace) if args.palace else MempalaceConfig().palace_path. cmd_init was the only outlier, so the flag was silently dropped and the palace always landed at ~/.mempalace/.

Fix

Mirror the env-var pattern already used by mcp_server.py:103 — set MEMPALACE_PALACE_PATH from args.palace at the top of cmd_init. Every downstream read of cfg.palace_path inside the command (Pass 0 corpus-origin write, cfg.init(), the post-init _maybe_run_mine_after_init) then resolves to the user-specified location automatically. Path is normalized via os.path.abspath(os.path.expanduser(...)) to match the existing env-var contract in config.py:179-184.

Test plan

  • New regression test tests/test_cli.py::test_cmd_init_honors_palace_flag — passes --palace and asserts (a) Pass 0 received the custom palace dir, not ~/.mempalace, and (b) MEMPALACE_PALACE_PATH is set in os.environ.
  • python -m pytest tests/ -v --ignore=tests/benchmarks -x -k "init or palace" — 164 passed.
  • ruff check . — clean.

cmd_init was instantiating MempalaceConfig() unconditionally, ignoring
args.palace and always writing the palace under ~/.mempalace. Mirror
the env-var pattern used by mcp_server.py (and consistent with how
cmd_mine / cmd_status / cmd_search resolve --palace) so every
downstream read of cfg.palace_path inside cmd_init — Pass 0,
cfg.init(), and the post-init mine — routes to the user-specified
location.

Adds tests/test_cli.py::test_cmd_init_honors_palace_flag covering the
regression: asserts Pass 0 receives the --palace value (not
~/.mempalace) and that MEMPALACE_PALACE_PATH is set in os.environ.

Closes #1313.
Copilot AI review requested due to automatic review settings May 3, 2026 01:56
@igorls igorls added this to the v3.3.5 milestone May 3, 2026
@igorls igorls added bug Something isn't working area/cli CLI commands labels May 3, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@igorls igorls merged commit 1888b67 into develop May 3, 2026
6 checks passed
@igorls igorls deleted the fix/1313-init-palace-flag branch May 3, 2026 06:54
monkeypatch.delenv(name, raising=False) on a missing key registers no
undo entry, so the env var cmd_init writes leaked into test_config_from_file
on Python 3.13 / Windows / macOS.

Prime the slot with setenv before delenv so teardown rolls back the write.
xcarbo added a commit to xcarbo/mempalace that referenced this pull request May 4, 2026
Catches up on a month of upstream work. Highlights pulled in:

- MemPalace#1306 searcher: hybrid candidate union (vector ∪ BM25 reranking pool)
- MemPalace#1325 mcp security: omit absolute paths from tool_get_drawer / tool_status
- MemPalace#1322 chroma: wire quarantine_stale_hnsw to prevent SIGSEGV on stale HNSW
- MemPalace#1320 mcp: forward valid_to / source params in kg_add / kg_invalidate
- MemPalace#1321 cli: honor --palace flag in cmd_init
- MemPalace#1314 kg temporal params fix
- MemPalace#1244 cli: cmd_compress writes to mempalace_closets so palace can read
- MemPalace#1243 mcp: case-insensitive agent name in diary_write/diary_read
- MemPalace#1303 mcp_server: pass embedding_function= on collection reopen
- MemPalace#1076/MemPalace#1077 hooks: quote CLAUDE_PLUGIN_ROOT / CODEX_PLUGIN_ROOT in hooks.json
- Various ruff format passes on touched files

Conflict resolution (CHANGELOG.md only — code files all auto-merged):

- 3.3.5 unreleased section header from upstream kept above 3.3.4
- 3.3.4 section: kept our 2026-04-30 release date; merged upstream's new
  MemPalace#1299 SIGSEGV-on-default-EF entry in alongside our existing topic-tunnels
  (MemPalace#1194/MemPalace#1195/MemPalace#1197), HNSW-bloat (MemPalace#1191), max_seq_id (MemPalace#1135), and
  auto-ingest (MemPalace#1230/MemPalace#1231) entries. Kept our richer topic-tunnels detail
  (upstream's version was a strict subset).

xdev patches preserved (still on this branch, untouched by merge):
- 6ef44cb fix(hooks): route CC transcripts via convo_miner with cwd-based wings
- 3fad61d fix(config): allow leading dash in wing names

Not pushed to origin — run tests locally and decide when to push.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mempalace --palace <dir> init: flag is silently ignored, init always uses default ~/.mempalace/

2 participants