Commit Graph
3 Commits
Author SHA1 Message Date
fl0rianr 496bb24982 revert internal mcp client code (#3498) 2026-09-09 14:04:09 +00:00
Mario LimoncielloandClaude 93c888224d fix: recover cache and models lost by 11.8.0 FHS split (#3387) (#3393)
* fix: recover cache and models relocated by FHS split (#3387)

The 11.8.0 FHS split (#3028) moved the systemd service's config, models,
and binaries out of $HOME/.cache into StateDirectory/CacheDirectory/HF_HOME,
but the startup migration only moved JSON and read it from the new (empty)
cache dir, so upgrades appeared to lose all config and downloaded models.

Add migrate_legacy_paths(), which recovers the pre-3028 home-based cache
payload and HuggingFace models into the relocated directories via rename
(with a cross-filesystem copy fallback), never overwriting existing files.
It is a no-op for plain-user, user-service, macOS, and Windows installs.

Co-Authored-By: Claude <[email protected]>

* fix: keep HuggingFace models in place across upgrade

Relocating models to HF_HOME=/var/cache/huggingface risked a
cross-filesystem copy of tens of GB when /var/cache and /var/lib are
separate mounts, which can fail on a full disk. Drop HF_HOME from the
unit so models resolve via HOME (~/.cache/huggingface) and stay put; the
startup migration no longer touches model blobs. Downloaded backends
still relocate to the (small, regenerable) CacheDirectory.

Co-Authored-By: Claude <[email protected]>

* fix: point systemd migration example at the in-home model cache

Models now resolve via HOME rather than HF_HOME=/var/cache/huggingface,
so the user->service migration helper must land them under the lemonade
user's ~/.cache/huggingface, not the now-unused /var/cache/huggingface.

Co-Authored-By: Claude <[email protected]>

* ci: drop EOL Ubuntu 25.10 (questing) from packaging

Ubuntu 25.10 has reached end of life. Remove it from the Launchpad PPA
build matrix and stop building its build-environment container image;
tidy the now-stale examples in prepare-debian-build. Leaves noble (24.04)
and resolute (26.04).

Co-Authored-By: Claude <[email protected]>

* fix: gate legacy cache recovery on systemd relocation

Address review feedback (#3393): the recovery leg ran whenever the active
cache dir differed from the pre-3028 home-based one, which is also true when
a user simply passes an explicit cache dir (e.g. `lemond /tmp/scratch`, or CI's
`lemond ./`). That would drain their real ~/.cache/lemonade into the scratch
dir — the same class of surprise as 11.8.0. Only recover when systemd actually
relocated our directories, signalled by CACHE_DIRECTORY / STATE_DIRECTORY.

Also check the error_code from fs::directory_iterator in move_tree_into so a
permission error surfaces a warning instead of silently no-op'ing recovery.

Co-Authored-By: Claude <[email protected]>

* fix(deb): don't recursively chown the HF model cache on every upgrade

With models now resolving under /var/lib/lemonade/.cache/huggingface (this
branch drops the /var/cache/huggingface redirect), the postinst's
`chown -R /var/lib/lemonade` would walk tens of GB of model blobs on every
dpkg configure. Prune the HuggingFace cache from the chown — those files are
already owned by the service that downloaded them.

Co-Authored-By: Claude <[email protected]>

* Bump to 11.8.1

---------

Co-authored-by: Claude <[email protected]>
2026-08-27 20:20:20 +00:00
edf2aa5291 Move persistent Lemonade JSON state from .cache to .config (#3028)
* feat: migrate persistent JSON state from .cache to .config

Lemonade was persisting configuration (config.json, user_models.json,
recipe_options.json, mcp_servers.json, jobs.json) under ~/.cache/lemonade,
mixing it with runtime artifacts. This change moves persistent state to
platform config directories and adds automatic migration on startup.

**Directory layout changes:**
- Linux user: ~/.cache/lemonade → ~/.config/lemonade (XDG_CONFIG_HOME)
- Linux systemd: /var/lib/lemonade (StateDirectory, replaces cache dir for config)
- macOS: ~/Library/Application Support/lemonade/.cache → .config
- Windows: unchanged (AppData/Local/lemonade)
- Desktop app: ~/.cache/lemonade/app_settings.json → ~/.config/lemonade/

**Systemd integration (Linux):**
- StateDirectory=lemonade for persistent config (/var/lib/lemonade)
- CacheDirectory=lemonade for downloads/models (/var/cache/lemonade)
- RuntimeDirectory=lemonade for ephemeral state (/run/lemonade)
- EnvironmentFile changed from wildcard /etc/lemonade/conf.d/*.conf to single
  /etc/default/lemond with GROUP_WRITE for multi-admin setups
- postinst migrates split conf.d files to merged /etc/default/lemond

**Migration behavior:**
- Automatic on first startup after upgrade
- Legacy JSON files moved from cache_dir to config_dir
- Logged errors/warnings for migration failures (permissions, disk full)
- Idempotent (safe to run multiple times)
- Custom cache/config dirs keep files together (portable installs)

**Runtime changes:**
- CLI accepts second positional arg: lemond [cache_dir] [config_dir]
- ConfigFile, ModelManager, McpClientManager, JobManager read/write via config_dir
- Migration runs once at startup in main.cpp (removed redundant calls)
- CLI overrides (--port, --host) saved before logging setup
- --broadcast flag preserved (process-only override, not persisted)

**Backward compatibility:**
- Migration preserves all user data
- Explicit custom directories bypass migration
- User service: EnvironmentFile=-%E/lemonade/lemond.conf (XDG config)

Fixes #3027

* fix: update test_mcp_client_config and test_config_discovery for new ConfigFile::load signature

- test_mcp_client_config: link against lemonade-server-core instead of compiling mcp_client.cpp directly
- test_config_discovery: update ConfigFile::load() calls to pass both cache_dir and config_dir parameters

Co-Authored-By: Claude <[email protected]>

* fix: remove GROUP_WRITE from /etc/default/lemond for secure-by-default permissions

Reduces permissions from 0664 to 0640 (owner rw, group r, no world access).

Co-Authored-By: Claude <[email protected]>

* Add test coverage

---------

Co-authored-by: Mario Limonciello <[email protected]>
Co-authored-by: Claude <[email protected]>
2026-08-20 21:24:35 +00:00