0006: Profiles as defaults; lazy, shared language services
- Status: Proposed (implemented in the MVP)
- Date: 2026-12-05
Context
Users want focused setups (for example Rust work) without separate applications, and language servers are the largest consumers of memory and CPU. Restarting servers is expensive; keeping all of them running is wasteful.
Decision
- A profile is a TOML file of defaults: theme, allowed language servers, resource policy, extra explorer exclusions, extensions disabled by default. It never restricts which files open or highlight.
- Language services are keyed by (workspace root, server id). A service starts when the first permitted document needs it, is shared by all compatible documents, and stops after
idle_grace_secondswith no documents.max_running_servicesevicts the longest-idle service first and never evicts a service in use. - Crashed services restart with backoff while documents need them, at most
max_restartstimes unless they had run stably for two minutes. - Document text is owned by the core, never by the service manager, so eviction and crashes cannot lose edits.
Alternatives considered
- Start servers with the workspace: simpler, but wastes hundreds of MiB for languages not in use (rust-analyzer alone measured 577 MiB).
- Stop immediately when the last document closes: causes restart churn during tab switching.
- Per-document servers: wasteful and wrong for project-wide analysis.
- Separate builds per language: duplicates the application.
Consequences
- Grace periods trade memory for latency; profiles tune it (30 s generic, 300 s for Rust).
- The policy is time-based, not memory-based; a measured memory-pressure policy is future work.
Validation
lsp_lifecycle.rs tests lazy start, sharing, reuse within grace, eviction after grace, missing servers, crash restarts, give-up and shutdown. Session tests check profile gating.