Files
Lumotia/docs/architecture-map/05-core-storage-hotkey-build/core-paths.md
Jake 26c7307607
Some checks failed
check / cargo check (macos-latest) (push) Has been cancelled
check / cargo check (ubuntu-22.04) (push) Has been cancelled
check / cargo check (windows-latest) (push) Has been cancelled
check / svelte build + lint (push) Has been cancelled
agent: lumotia-rebrand — docs, scripts, root config, residuals
Phase 9 of the rebrand cascade. Sweep covers everything the Phase 8
frontend pass deliberately skipped: docs/, root markdown, scripts,
Cargo.toml descriptions, code comments that survived earlier
word-boundary sed, plus a handful of identifiers caught on the final
verify pass.

transcription-app changes:
- README.md, HANDOVER.md, KNOWN-ISSUES.md, run.sh — magnotia/Magnotia
  -> lumotia/Lumotia.
- docs/ — sweep across all subdirs except docs/handovers/ (preserved
  as immutable audit trail). Includes architecture-map references
  to magnotia_core::*, magnotia_storage::*, etc. now pointing at
  lumotia_*; dev-setup.md tracing output examples (lumotia_startup
  target); brief/ + superpowers/ + issues/ + whisper-ecosystem/ +
  audit/.
- Cargo.toml descriptions on 9 crates (core, audio, cloud-providers,
  hotkey, llm, mcp, plus referenced others).
- crates/core/src/{error,hardware,recommendation,paths}.rs +
  crates/audio/src/wav.rs + crates/llm/src/model_manager.rs +
  crates/cloud-providers/src/keystore.rs + crates/mcp/src/lib.rs —
  doc comments and a model-manager user-agent string.
- Caught on final pass: BroadcastChannel("magnotia_task_sync") -> ...
  ("lumotia_task_sync"); magnotia_locale i18n localStorage key
  renamed + migration shim added; CSS keyframe names
  magnotiaPulse / magnotiaBar / magnotiaFade renamed in the design-
  system kit; magnotia_viewer_item / magnotia_viewer_mode handoff
  keys renamed in HistoryPage + viewer/+page.svelte; src/assets/
  wordmark.svg text.
- src-tauri/src/lib.rs comment cleanup ("magnotia era" was sed'd
  to "lumotia era" earlier — restored).

Preserved (intentional):
- crates/core/src/paths.rs — keeps "magnotia" / "Magnotia" / ".magnotia"
  legacy detection strings in legacy_and_target_paths() so the
  migration shim can still find user data from the magnotia era.
- src/lib/stores/{page,focusTimer}.svelte.ts + src/lib/i18n/index.ts
  — migration call sites reference the legacy magnotia keys
  deliberately.
- docs/handovers/ — historical audit trail.

cargo build --workspace passes. npm run check: 0 errors / 0 warnings
(3958 files). cargo test --workspace: 339 pass / 0 fail.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 12:38:03 +01:00

4.7 KiB

name, type, slice, last_verified
name type slice last_verified
Core app paths architecture-map-page 05-core-storage-hotkey-build 2026/05/09

Core app paths

Where you are: Architecture mapCore, Storage, Hotkey, Build → Core app paths

Plain English summary. Where Lumotia stores its files on disk. One root, derived from the OS conventions (LOCALAPPDATA on Windows, ~/Library/Application Support/Lumotia on macOS, $XDG_DATA_HOME/lumotia on Linux), and named accessor methods for each subdirectory. Every other crate that needs to know "where does the database live?" reaches for lumotia_core::paths::AppPaths::current().

At a glance

  • File: crates/core/src/paths.rs (125 LOC).
  • External deps: standard library only.
  • Public surface: AppPaths (struct), app_paths, app_data_dir.
  • Consumers: lumotia-storage::file_storage (re-exports the path helpers), the Tauri startup code (slice 2), the model manager (slices 3 + 4), the diagnostic-report bundler (slice 2).

What's in here

AppPathscrates/core/src/paths.rs:6

pub struct AppPaths { app_data_dir: PathBuf }

impl AppPaths {
    pub fn current() -> Self;                         // resolves at construction
    pub fn app_data_dir(&self) -> PathBuf;
    pub fn database_path(&self) -> PathBuf;           // <root>/lumotia.db
    pub fn recordings_dir(&self) -> PathBuf;          // <root>/recordings
    pub fn crashes_dir(&self) -> PathBuf;             // <root>/crashes
    pub fn logs_dir(&self) -> PathBuf;                // <root>/logs
    pub fn diagnostic_reports_dir(&self) -> PathBuf;  // <root>/diagnostic-reports
    pub fn models_dir(&self) -> PathBuf;              // <root>/models
    pub fn speech_model_dir(&self, id: &ModelId) -> PathBuf;  // <root>/models/<id>
    pub fn llm_models_dir(&self) -> PathBuf;          // <root>/models/llm
    pub fn migration_sentinel(&self, name: &str) -> PathBuf;  // <root>/.<name>.sentinel
}

pub fn app_paths() -> AppPaths;
pub fn app_data_dir() -> PathBuf;

Root resolution — crates/core/src/paths.rs:66

The resolve_app_data_dir function picks the root by cfg(target_os = ...):

OS Root
Windows %LOCALAPPDATA%/lumotia
macOS $HOME/Library/Application Support/Lumotia
Linux $HOME/.lumotia if it already exists (legacy), else $XDG_DATA_HOME/lumotia if set, else $HOME/.local/share/lumotia
other $HOME/.lumotia

The Linux legacy-path branch keeps existing users on ~/.lumotia (early dogfooding default) without forcing a migration when the canonical XDG location is preferred.

Sentinel files — crates/core/src/paths.rs:53

migration_sentinel(name) -> <root>/.<name>.sentinel. Used for one-shot data migrations outside the SQLite schema (for example, a one-off file-system reorganisation). The pattern is: write the sentinel after the migration runs successfully; check for the sentinel on next startup; skip the migration if the sentinel exists.

Data flow / contract

  • All paths are derived from a single root. Changing resolve_app_data_dir once moves every downstream file. Tested at paths.rs:111.
  • Path resolution is pure: only reads env vars (HOME, LOCALAPPDATA, XDG_DATA_HOME) plus Path::exists for the Linux legacy probe.
  • AppPaths::current() does not create directories. Callers that need a directory to exist call std::fs::create_dir_all at write time. The storage init function does this for the database parent (crates/storage/src/database.rs:10).

Tests

crates/core/src/paths.rs:104-125:

  • derives_all_paths_from_one_base — verifies that database_path, speech_model_dir(<id>), and llm_models_dir are all rooted at the same app_data_dir.

Watch-outs

  • std::env::var(...).unwrap_or_else(|_| "/tmp".to_string()) is the fallback for missing HOME. Should never trigger in practice; defensive.
  • AppPaths::current() reads env vars at every call. Cheap, but repeated calls are wasteful. Slice 2 caches a OnceLock<AppPaths> so the value is resolved once at startup.
  • No Windows fallback for missing LOCALAPPDATA. Falls through to . (current working directory). On a misconfigured Windows host this could write the database next to the binary. Not great; the impact is limited to first-run scenarios where the env is broken.
  • Sentinel files are hidden on Unix (.<name>.sentinel) but visible on Windows. Acceptable; sentinels live alongside lumotia.db so the user sees both.

See also