Expand description
cyrs-db — incremental analysis database (spec 0001 §11).
This crate builds on the Salsa skeleton from cy-zx6 and adds the
complete input-query surface from spec §11.2 (cy-nk7), plus the
FileId model, snapshot API, and workspace-scoped SchemaProvider
wiring from spec §11.4–§11.5 (cy-amr).
§Primary API (spec §11.4–§11.5)
See workspace for the high-level Database + FileId + snapshot API
intended for consumers (cyrs-lsp, cyrs-agent, cyrs-cli,
cyrs-tck).
workspace::Database— workspace-scoped database. Owns aCypherDatabaseplus aFileId → SourceFileregistry.workspace::FileId— stable u32 handle, the unit of caching (§11.4).workspace::DatabaseSnapshot—Sendread-only snapshot for cross-thread queries (§11.5).workspace::UnknownFileId— error returned for stale handles.
§Salsa internals (low-level, for crate authors)
SourceFile— Salsa#[input]for per-filesource+dialect.inputs::FileOptions— Salsa#[input]for per-fileinputs::AnalysisOptions.inputs::WorkspaceInputs— Salsa#[input]for workspace-scoped schema (§11.4).inputs::options_digest—#[salsa::tracked]derived query: stable u64 hash ofAnalysisOptions, used to gate all analysis-dependent derived queries.CypherDatabase— the concretesalsa::Databaseimpl.CypherDb— the database trait that all concrete DBs implement.ParseOutput— memoised result of parsing aSourceFile.parse_cst— first derived query: lossless CST, re-evaluated only whensourcechanges.
§Input query surface (spec §11.2)
| Query | Salsa kind | Scope |
|---|---|---|
source_text(file) -> &str | #[input] field | per-file |
dialect(file) -> DialectMode | #[input] field | per-file |
options(file) -> AnalysisOptions | #[input] field | per-file |
options_digest(file) -> u64 | #[tracked] | per-file |
schema() -> Option<Arc<dyn …>> | #[input] field | workspace |
§Legacy facade API (preserved for backward compat)
The legacy LegacyDatabase / legacy FileId (u32 newtype) remain
exported under their old names for backward compatibility while binary
crates migrate to the new workspace::Database API.
§Send + Sync / snapshot semantics (spec §11.5)
CypherDatabase is Clone. Cloning shares the Arc<Zalsa> backing
store and creates a fresh ZalsaLocal, producing a snapshot. The clone
can be sent to another thread for concurrent read queries (Send).
Writes require &mut self and block until all clones are dropped.
Re-exports§
pub use inputs::AnalysisOptions;pub use inputs::FileOptions;pub use inputs::WorkspaceInputs;pub use inputs::options_digest;pub use options::DatabaseOptions;pub use queries::Analysis;pub use queries::AstOutput;pub use queries::DiagnosticsOutput;pub use queries::PlanOutput;pub use queries::ResolvedNamesOutput;pub use queries::all_diagnostics;pub use queries::analyse_file;pub use queries::parse_ast;pub use queries::plan_of;pub use queries::resolved_names;pub use queries::sema_diagnostics;pub use workspace::Database;pub use workspace::DatabaseSnapshot;pub use workspace::FileId;pub use workspace::UnknownFileId;
Modules§
- inputs
- Input queries for the incremental analysis database (spec §11.2).
- options
- Per-query LRU capacity options for the incremental database (spec §11.X).
- queries
- Derived Salsa query chain (spec 0001 §11.3).
- workspace
- Workspace-level
DatabaseAPI —FileIdmodel, snapshot semantics, and theSchemaProviderwiring (spec 0001 §11.4, §11.5).
Structs§
- Cypher
Database - The concrete incremental database (Salsa 2022-style, spec §11.1).
- Legacy
Database - Legacy analysis database (non-incremental). Preserved for backward
compatibility while binary crates migrate to
workspace::Database. - Legacy
File Id - File identity within the legacy
LegacyDatabase. - Parse
Output - Memoised result of parsing a
SourceFile. - Source
File - A single source file tracked by the incremental database.
Enums§
- Dialect
Mode - Dialect mode selected at parse time. Spec §9.
Traits§
- Cypher
Db - Trait that all concrete databases in this workspace implement.
Functions§
- parse_
cst - Parse a
SourceFileinto a lossless CST. - set_
parse_ cst_ lru - Adjust the LRU capacity of
parse_cstat runtime.