Skip to main content

Crate turbovault_vault

Crate turbovault_vault 

Source
Expand description

§Vault Manager

Vault operations: reading, writing and editing notes, keeping the derived state (note cache and link graph) fresh, and dispatching writes to the configured backend.

This crate provides:

  • File reading and writing with error handling
  • The freshness gate, which notices changes made outside TurboVault
  • Write dispatch to a Direct or Git backend (substrate::WriteSubstrate)
  • Edit engine for SEARCH/REPLACE edits with fuzzy matching

§Quick Start

use turbovault_vault::VaultManager;
use turbovault_core::ServerConfig;
use std::path::PathBuf;

// Create a vault manager
let config = ServerConfig::default();
let manager = VaultManager::new(config)?;

// Read a file
let path = PathBuf::from("notes/example.md");
let _vault_path = manager.vault_path();

§Core Modules

§Manager

manager::VaultManager is the primary interface for vault operations:

  • Read/write files
  • Query metadata
  • List files
  • Traverse directory structure

§Write substrate

substrate::WriteSubstrate applies every change plan, either directly (temp file and atomic rename) or as one Git commit.

§Edit Engine

edit::EditEngine provides advanced editing capabilities:

  • Search and replace with context
  • Block-based edits
  • Diff-based fuzzy matching
  • Hash verification

Example:

use turbovault_vault::EditEngine;

let _edit_engine = EditEngine::new();
// Use edit_engine for advanced file modifications

§Thread Safety

All components are thread-safe:

  • VaultManager uses Arc<RwLock<...>> internally
  • Safe to share across async tasks
  • Concurrent read access with exclusive write access

§Error Handling

All operations return turbovault_core::Result<T>:

  • File not found errors
  • Permission errors
  • Invalid paths
  • Encoding errors

Re-exports§

pub use edit::EditEngine;
pub use edit::EditResult;
pub use edit::SearchReplaceBlock;
pub use manager::ChangeListener;
pub use manager::ScannedNote;
pub use manager::VaultManager;
pub use reindex::CommitOrigin;
pub use reindex::PendingCommit;
pub use reindex::ReindexQueue;
pub use reindex::apply_commit_diff;
pub use reindex::watch_ref_changes;
pub use substrate::ApplyOutcome;
pub use substrate::DirectSubstrate;
pub use substrate::GitSubstrate;
pub use substrate::WriteSubstrate;

Modules§

edit
LLM-optimized file editing with SEARCH/REPLACE blocks
manager
The vault manager: file operations, the note cache and link graph, and the freshness gate that keeps them in step with the vault on disk.
prelude
The vault types and core’s prelude, for a glob import.
reindex
Lazy GSU (Graph + Search Update) queue + apply (GWS.14).
substrate
WriteSubstrate — the dispatch point behind VaultManager (write- substrate-layering M3a, turbovault-qae.4.1).

Functions§

compute_hash
Compute SHA-256 hash of content (with Unicode NFC normalization). Lives in turbovault-core so the audit trail and the parser hash the same way. The content hash TurboVault hands out for a note: lowercase hex SHA-256 of its Unicode NFC form. It is the expected_hash a Direct-backed write checks, the hash read_note reports, the before/after hash on an audit entry, and FileMetadata::checksum, so any two of them can be compared.