Skip to main content

khive_runtime/
code_map_runtime.rs

1//! Dedicated code-map runtime construction.
2
3use khive_db::StorageBackend;
4
5use crate::{KhiveRuntime, RuntimeConfig, RuntimeError, RuntimeResult};
6
7impl KhiveRuntime {
8    /// Construct a dedicated code-map runtime. Every connection in its pool
9    /// selects the native handle-proving VFS before the first schema read or
10    /// migration. The caller prepares the omitted-db parent; an explicit
11    /// target receives no path transform or directory creation here, so its
12    /// parent directory must already exist. A code-map database runs in
13    /// rollback-journal mode, so a configured WAL ceiling does not apply to it.
14    pub fn new_code_map(
15        mut config: RuntimeConfig,
16        protected_main: Vec<std::path::PathBuf>,
17        protected_events: Vec<std::path::PathBuf>,
18    ) -> RuntimeResult<Self> {
19        if config.db_path.is_none() {
20            return Err(RuntimeError::InvalidInput(
21                "code-map runtime requires a guarded file-backed database".into(),
22            ));
23        }
24        let disk_guard = config
25            .resolve_disk_guard_policy(false)?
26            .expect("code-map has a file-backed disk policy");
27        let volume_lock_dir = config.volume_lock_dir.clone();
28        Self::new_with_file_backend(config, false, move |path| {
29            StorageBackend::sqlite_code_map_with_policies(
30                path,
31                &protected_main,
32                &protected_events,
33                disk_guard,
34                khive_db::require_volume_lock_dir(volume_lock_dir)?,
35            )
36        })
37    }
38}