SemanticManager

Struct SemanticManager 

Source
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: PathBuf

Source directory root

§store: Option<Arc<dyn VectorStore>>

Vector store for similarity search

§embedder: Option<Arc<dyn Embedder>>

Embedder for generating embeddings

§config: SemanticConfig

Configuration

§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: PathBuf

Directory for storing plans

§ops_manager: Option<Arc<OpsManager>>

Operations manager for executing actions

Implementations§

Source§

impl SemanticManager

Source

pub fn new( source: PathBuf, store: Option<Arc<dyn VectorStore>>, embedder: Option<Arc<dyn Embedder>>, config: Option<SemanticConfig>, ) -> Self

Create a new semantic manager.

Source

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.

Source

pub fn set_ops_manager(&mut self, ops_manager: Arc<OpsManager>)

Set the operations manager.

Source

fn load_plans(plans_dir: &PathBuf) -> HashMap<Uuid, SemanticPlan>

Load all plans from disk.

Source

fn save_plan(&self, plan: &SemanticPlan) -> Result<()>

Save a single plan to disk.

Source

fn delete_plan_file(&self, plan_id: Uuid) -> Result<()>

Delete a plan file from disk.

Source

pub async fn purge_expired_plans(&self) -> usize

Purge expired plans from memory and disk.

Source

pub fn is_available(&self) -> bool

Check if semantic operations are available.

Source

pub async fn find_similar( &self, path: &PathBuf, ) -> Result<SimilarFilesResult, String>

Find files similar to a given path.

Source

pub async fn get_last_similar_result(&self) -> Option<SimilarFilesResult>

Get the last similar files result.

Source

pub async fn analyze_cleanup(&self) -> Result<CleanupAnalysis, String>

Analyze files for cleanup candidates.

Source

pub async fn get_cleanup_analysis(&self) -> Option<CleanupAnalysis>

Get cached cleanup analysis.

Source

pub async fn find_duplicates(&self) -> Result<DuplicateGroups, String>

Find duplicate file groups.

Source

pub async fn get_duplicate_groups(&self) -> Option<DuplicateGroups>

Get cached duplicate groups.

Source

pub async fn create_organize_plan( &self, request: OrganizeRequest, ) -> Result<SemanticPlan, String>

Create an organization plan.

Source

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.

Source

fn plan_by_type( &self, files: &[&FileRecord], scope_path: &PathBuf, ) -> (Vec<PlanAction>, String)

Plan organization by file type.

Source

fn plan_by_project( &self, files: &[&FileRecord], scope_path: &PathBuf, ) -> (Vec<PlanAction>, String)

Plan organization by project structure (based on imports/dependencies).

Source

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.

Source

pub async fn list_pending_plans(&self) -> Vec<SemanticPlan>

List all pending plans.

Source

pub async fn get_plan(&self, plan_id: Uuid) -> Option<SemanticPlan>

Get a specific plan.

Source

async fn execute_action( &self, action: &ActionType, ) -> Result<ActionResult, String>

Execute a single action via OpsManager.

Source

pub async fn approve_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>

Approve and execute a plan.

Source

pub async fn reject_plan(&self, plan_id: Uuid) -> Result<SemanticPlan, String>

Reject a plan.

Source

pub async fn get_cleanup_json(&self) -> Vec<u8>

Get cleanup analysis as JSON bytes (for FUSE read).

Source

pub async fn get_dedupe_json(&self) -> Vec<u8>

Get duplicate groups as JSON bytes (for FUSE read).

Source

pub async fn get_similar_json(&self) -> Vec<u8>

Get similar files result as JSON bytes (for FUSE read).

Source

pub async fn get_pending_plan_ids(&self) -> Vec<String>

Get pending plans directory listing.

Source

pub async fn get_plan_json(&self, plan_id: &str) -> Vec<u8>

Get a plan as JSON bytes (for FUSE read).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more