Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

The Beskid LSP maintains two cooperating caches: open document buffers (State.docs) and disk-backed workspace index entries (State.workspace_index), both carrying optional DocumentAnalysisSnapshot values versioned by ANALYSIS_CACHE_VERSION. A separate CompilationContext cache keys off resolved Project.proj paths plus workspace member defaults.

flowchart LR
  subgraph open [Open buffers]
    DidOpen[didOpen / didChange]
    Doc[Document + text_hash]
    Snap[DocumentAnalysisSnapshot]
    DidOpen --> Doc --> Snap
  end
  subgraph disk [Disk index]
    Scan[workspace_scan]
    Idx[workspace_index]
    Scan --> Idx
  end
  subgraph project [Project scope]
    Ctx[compilation_context_cache]
    Inv[invalidate_compilation_cache]
  end
  Snap --> Ctx
  Inv --> Ctx
  Inv --> Snap
StoreKeyInvalidation trigger
Open DocumentLSP UriText change, version bump, cache version mismatch
Disk snapshotUri (file not open)Workspace scan, external file watcher refresh
CompilationContext(Project.proj path, member default)Manifest/lock/graph changes, explicit invalidation

build_document_analysis calls beskid_analysis::services::build_document_analysis_with_context when a CompilationContext exists. Project manifest URIs (.proj) must not produce analysis snapshots—only Beskid sources.

Hard invalidation clears compilation_context_cache and bumps per-document analysis_cache_version so every open buffer re-analyzes:

  • Project.proj, Workspace.proj, or lockfile writes affecting dependency roots
  • project.mod changes on attached Mod projects
  • Full workspace rescan after invalidate_compilation_cache (workspace_scan.rs, backend.rs)

Soft invalidation (re-run meta without full graph rebuild) is permitted only when capture keys remain valid; otherwise the server must hard-invalidate per Incremental scheduling and determinism.

Workspace scans emit BeskidStatusParams with phase: workspace_scan and throttled progress (STATUS_EMIT_INTERVAL 200ms) so the VS Code extension can mirror CLI-style progress in the status bar.

  • Document lifecycle: compiler/crates/beskid_lsp/src/session/lifecycle.rs
  • Project context cache: compiler/crates/beskid_lsp/src/session/project_context.rs
  • Workspace scan: compiler/crates/beskid_lsp/src/workspace_scan.rs
  • Server wiring: compiler/crates/beskid_lsp/src/server/backend.rs
  • Diagnostics publish debounce: 120ms coalescing in schedule_publish_diagnostics