pub struct SemanticManager {
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
embedder: Option<Arc<dyn Embedder>>,
config: SemanticConfig,
pending_plans: Arc<RwLock<HashMap<Uuid, SemanticPlan>>>,
last_similar_result: Arc<RwLock<Option<SimilarFilesResult>>>,
cleanup_cache: Arc<RwLock<Option<CleanupAnalysis>>>,
dedupe_cache: Arc<RwLock<Option<DuplicateGroups>>>,
plans_dir: PathBuf,
ops_manager: Option<Arc<OpsManager>>,
}Expand description
Semantic manager for intelligent file operations.
Fields§
§source: PathBufSource directory root
store: Option<Arc<dyn VectorStore>>Vector store for similarity search
embedder: Option<Arc<dyn Embedder>>Embedder for generating embeddings
config: SemanticConfigConfiguration
pending_plans: Arc<RwLock<HashMap<Uuid, SemanticPlan>>>Pending plans (plan_id -> plan)
last_similar_result: Arc<RwLock<Option<SimilarFilesResult>>>Last similar files result
cleanup_cache: Arc<RwLock<Option<CleanupAnalysis>>>Cached cleanup analysis
dedupe_cache: Arc<RwLock<Option<DuplicateGroups>>>Cached duplicate groups
plans_dir: PathBufDirectory for storing plans
ops_manager: Option<Arc<OpsManager>>Operations manager for executing actions
Implementations§
Source§impl SemanticManager
impl SemanticManager
Sourcepub fn new(
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
embedder: Option<Arc<dyn Embedder>>,
config: Option<SemanticConfig>,
) -> Self
pub fn new( source: PathBuf, store: Option<Arc<dyn VectorStore>>, embedder: Option<Arc<dyn Embedder>>, config: Option<SemanticConfig>, ) -> Self
Create a new semantic manager.
Sourcepub fn with_ops(
source: PathBuf,
store: Option<Arc<dyn VectorStore>>,
embedder: Option<Arc<dyn Embedder>>,
config: Option<SemanticConfig>,
ops_manager: Arc<OpsManager>,
) -> Self
pub fn with_ops( source: PathBuf, store: Option<Arc<dyn VectorStore>>, embedder: Option<Arc<dyn Embedder>>, config: Option<SemanticConfig>, ops_manager: Arc<OpsManager>, ) -> Self
Create a semantic manager with an operations manager for plan execution.
Sourcepub fn set_ops_manager(&mut self, ops_manager: Arc<OpsManager>)
pub fn set_ops_manager(&mut self, ops_manager: Arc<OpsManager>)
Set the operations manager.
Sourcefn load_plans(plans_dir: &PathBuf) -> HashMap<Uuid, SemanticPlan>
fn load_plans(plans_dir: &PathBuf) -> HashMap<Uuid, SemanticPlan>
Load all plans from disk.
Sourcefn save_plan(&self, plan: &SemanticPlan) -> Result<()>
fn save_plan(&self, plan: &SemanticPlan) -> Result<()>
Save a single plan to disk.
Sourcefn delete_plan_file(&self, plan_id: Uuid) -> Result<()>
fn delete_plan_file(&self, plan_id: Uuid) -> Result<()>
Delete a plan file from disk.
Sourcepub async fn purge_expired_plans(&self) -> usize
pub async fn purge_expired_plans(&self) -> usize
Purge expired plans from memory and disk.
Sourcepub fn is_available(&self) -> bool
pub fn is_available(&self) -> bool
Check if semantic operations are available.
Sourcepub async fn find_similar(
&self,
path: &PathBuf,
) -> Result<SimilarFilesResult, String>
pub async fn find_similar( &self, path: &PathBuf, ) -> Result<SimilarFilesResult, String>
Find files similar to a given path.
Sourcepub async fn get_last_similar_result(&self) -> Option<SimilarFilesResult>
pub async fn get_last_similar_result(&self) -> Option<SimilarFilesResult>
Get the last similar files result.
Sourcepub async fn analyze_cleanup(&self) -> Result<CleanupAnalysis, String>
pub async fn analyze_cleanup(&self) -> Result<CleanupAnalysis, String>
Analyze files for cleanup candidates.
Sourcepub async fn get_cleanup_analysis(&self) -> Option<CleanupAnalysis>
pub async fn get_cleanup_analysis(&self) -> Option<CleanupAnalysis>
Get cached cleanup analysis.
Sourcepub async fn find_duplicates(&self) -> Result<DuplicateGroups, String>
pub async fn find_duplicates(&self) -> Result<DuplicateGroups, String>
Find duplicate file groups.
Sourcepub async fn get_duplicate_groups(&self) -> Option<DuplicateGroups>
pub async fn get_duplicate_groups(&self) -> Option<DuplicateGroups>
Get cached duplicate groups.
Sourcepub async fn create_organize_plan(
&self,
request: OrganizeRequest,
) -> Result<SemanticPlan, String>
pub async fn create_organize_plan( &self, request: OrganizeRequest, ) -> Result<SemanticPlan, String>
Create an organization plan.
Sourcefn plan_by_topic(
&self,
file_embeddings: &HashMap<PathBuf, Vec<f32>>,
scope_path: &PathBuf,
max_groups: usize,
similarity_threshold: f32,
) -> (Vec<PlanAction>, String)
fn plan_by_topic( &self, file_embeddings: &HashMap<PathBuf, Vec<f32>>, scope_path: &PathBuf, max_groups: usize, similarity_threshold: f32, ) -> (Vec<PlanAction>, String)
Plan organization by semantic topic using clustering.
Sourcefn plan_by_type(
&self,
files: &[&FileRecord],
scope_path: &PathBuf,
) -> (Vec<PlanAction>, String)
fn plan_by_type( &self, files: &[&FileRecord], scope_path: &PathBuf, ) -> (Vec<PlanAction>, String)
Plan organization by file type.
Sourcefn plan_by_project(
&self,
files: &[&FileRecord],
scope_path: &PathBuf,
) -> (Vec<PlanAction>, String)
fn plan_by_project( &self, files: &[&FileRecord], scope_path: &PathBuf, ) -> (Vec<PlanAction>, String)
Plan organization by project structure (based on imports/dependencies).
Sourceasync fn plan_by_custom(
&self,
file_embeddings: &HashMap<PathBuf, Vec<f32>>,
scope_path: &PathBuf,
categories: &[String],
embedder: Option<&Arc<dyn Embedder>>,
) -> (Vec<PlanAction>, String)
async fn plan_by_custom( &self, file_embeddings: &HashMap<PathBuf, Vec<f32>>, scope_path: &PathBuf, categories: &[String], embedder: Option<&Arc<dyn Embedder>>, ) -> (Vec<PlanAction>, String)
Plan organization by custom categories.
Generates embeddings for category names and assigns files to the best matching category using cosine similarity.
Sourcepub async fn list_pending_plans(&self) -> Vec<SemanticPlan>
pub async fn list_pending_plans(&self) -> Vec<SemanticPlan>
List all pending plans.
Sourcepub async fn get_plan(&self, plan_id: Uuid) -> Option<SemanticPlan>
pub async fn get_plan(&self, plan_id: Uuid) -> Option<SemanticPlan>
Get a specific plan.
Sourceasync fn execute_action(
&self,
action: &ActionType,
) -> Result<ActionResult, String>
async fn execute_action( &self, action: &ActionType, ) -> Result<ActionResult, String>
Execute a single action via OpsManager.
Sourcepub async fn approve_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>
pub async fn approve_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>
Approve and execute a plan.
Sourcepub async fn reject_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>
pub async fn reject_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>
Reject a plan.
Sourcepub async fn get_cleanup_json(&self) -> Vec<u8> ⓘ
pub async fn get_cleanup_json(&self) -> Vec<u8> ⓘ
Get cleanup analysis as JSON bytes (for FUSE read).
Sourcepub async fn get_dedupe_json(&self) -> Vec<u8> ⓘ
pub async fn get_dedupe_json(&self) -> Vec<u8> ⓘ
Get duplicate groups as JSON bytes (for FUSE read).
Sourcepub async fn get_similar_json(&self) -> Vec<u8> ⓘ
pub async fn get_similar_json(&self) -> Vec<u8> ⓘ
Get similar files result as JSON bytes (for FUSE read).
Sourcepub async fn get_pending_plan_ids(&self) -> Vec<String>
pub async fn get_pending_plan_ids(&self) -> Vec<String>
Get pending plans directory listing.