venus_core/salsa_db/
inputs.rs

1//! Salsa input types for Venus.
2//!
3//! Input types are the entry points for incremental computation.
4//! Changes to inputs automatically invalidate dependent queries.
5
6use std::path::PathBuf;
7use std::sync::Arc;
8
9use super::conversions::ExecutionStatus;
10
11/// Input: Source file content.
12///
13/// This is the primary input to the incremental system.
14/// When source text changes, all dependent queries are invalidated.
15#[salsa::input]
16pub struct SourceFile {
17    /// Path to the source file
18    pub path: PathBuf,
19
20    /// Content of the source file
21    pub text: String,
22}
23
24/// Input: Compiler settings for cell compilation.
25///
26/// This input provides the configuration needed for cell compilation.
27/// Changes to settings (e.g., optimization level) will invalidate
28/// compiled cell queries.
29#[salsa::input]
30pub struct CompilerSettings {
31    /// Directory for build artifacts (.venus/build/)
32    pub build_dir: PathBuf,
33
34    /// Directory for cached outputs (.venus/cache/)
35    pub cache_dir: PathBuf,
36
37    /// Path to the compiled universe library
38    pub universe_path: Option<PathBuf>,
39
40    /// Use Cranelift backend (fast compilation)
41    pub use_cranelift: bool,
42
43    /// Optimization level (0-3)
44    pub opt_level: u8,
45}
46
47/// Input: Cell execution outputs.
48///
49/// This input stores the execution status for all cells in a notebook.
50/// It is updated after cells are executed, allowing Salsa to track
51/// when outputs change.
52///
53/// Uses `Arc` to efficiently share the potentially large status map
54/// without expensive cloning on every query.
55#[salsa::input]
56pub struct CellOutputs {
57    /// Execution status for each cell, indexed by cell ID.
58    /// Wrapped in Arc for efficient sharing.
59    pub statuses: Arc<Vec<ExecutionStatus>>,
60
61    /// Version counter that increments on any change.
62    /// Used for quick staleness checks.
63    pub version: u64,
64}