Skip to main content

hyprstream_core/storage/
mod.rs

1//! Storage for model weights and adapters
2//!
3//! This module provides storage for:
4//! - Neural network weights
5//! - LoRA adapters
6//! - Model checkpoints
7//! - Memory-mapped disk persistence
8//! - XET-based content-addressable storage (via git2db, requires `xet` feature)
9//! - Git LFS to XET translation for Hugging Face models (via git2db::lfs, requires `xet` feature)
10//! - Git-native model registry
11pub mod adapter_manager;
12pub mod cas;
13pub mod errors;
14pub mod model_ref;
15pub mod paths;
16pub mod pinned_model;
17pub mod release_store;
18
19// Re-export types for backward compatibility
20pub use adapter_manager::{AdapterConfig, AdapterInfo, AdapterManager};
21pub use cas::{BlobManifest, CasError, CasSubstrate, DedupDomain, TrustBoundary};
22pub use errors::{ModelRefError, ModelRefResult};
23pub use model_ref::{validate_model_name, GitRef, ModelRef};
24pub use paths::StoragePaths;
25
26// ============================================================================
27// Compatibility types (formerly in model_storage.rs)
28// ============================================================================
29
30use serde::{Deserialize, Serialize};
31use uuid::Uuid;
32
33/// Unique identifier for a model
34#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
35pub struct ModelId(Uuid);
36
37impl ModelId {
38    /// Create a new random model ID
39    pub fn new() -> Self {
40        Self(Uuid::new_v4())
41    }
42}
43
44impl Default for ModelId {
45    fn default() -> Self {
46        Self::new()
47    }
48}
49
50impl std::fmt::Display for ModelId {
51    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52        write!(f, "{}", self.0)
53    }
54}
55
56/// Metadata for a cloned/tracked model
57#[derive(Debug, Clone, Serialize, Deserialize)]
58pub struct ModelMetadata {
59    /// Model name
60    pub name: String,
61    /// Display name (may include version/branch info)
62    pub display_name: Option<String>,
63    /// Model type (e.g., "language_model", "embedding")
64    pub model_type: String,
65    /// When the model was first tracked
66    pub created_at: i64,
67    /// When the model was last updated
68    pub updated_at: i64,
69    /// Size in bytes (if known)
70    pub size_bytes: Option<u64>,
71    /// Tags for metadata enrichment
72    pub tags: Vec<String>,
73    /// Whether the model has uncommitted changes
74    pub is_dirty: bool,
75}
76
77/// Result of a clone operation
78#[derive(Debug, Clone)]
79pub struct ClonedModel {
80    /// Unique identifier for this model
81    pub id: ModelId,
82    /// Model name
83    pub name: String,
84    /// Path to the cloned model
85    pub path: std::path::PathBuf,
86}
87
88// Compatibility types (moved from model_registry)
89/// Options for checkout operations
90#[derive(Debug, Default)]
91pub struct CheckoutOptions {
92    pub create_branch: bool,
93    pub force: bool,
94}
95
96/// Result of a checkout operation
97#[derive(Debug, Clone)]
98pub struct CheckoutResult {
99    pub previous_oid: git2db::Oid,
100    pub new_oid: git2db::Oid,
101    pub previous_ref_name: Option<String>,
102    pub new_ref_name: Option<String>,
103    pub was_forced: bool,
104    pub files_changed: usize,
105    pub has_submodule: bool,
106}