Commit Graph
2 Commits
Author SHA1 Message Date
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
Arun Babu Neelicattu 379ef10d1d feat(server,cli): add discovery and broadcast controls with config decoupling (#3135)
* feat(server,cli): add discovery and broadcast controls with config decoupling

Add configuration and CLI controls to enable or disable server UDP beacon broadcasting (lemond --broadcast / --no-broadcast) and client auto-discovery (lemonade --discovery / --no-discovery). Broadcast state is configured via a new broadcast boolean key (defaulting to true) with backward-compatible normalization for no_broadcast. Transient CLI startup overrides are isolated in process memory to prevent leaking into persistent config.json on dynamic configuration updates.

* fix(server): add seamless legacy no_broadcast config migration and ctor normalization

* docs: sync generated backend configuration boilerplate

* fix(server): track effective broadcast state changes and expand migration tests

* fix(server): normalize legacy keys per source before defaults merge
2026-08-16 01:26:43 +00:00