fix(v13): FIX-06 PersistentMemoryStore 全量移除 — 665行死代码清理
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- persistent.rs 611→57行: 移除 PersistentMemoryStore struct + 全部方法 + 死 embedding global - memory_commands.rs: MemoryStoreState→Arc<Mutex<()>>, memory_init→no-op, 移除 2 @reserved 命令 - viking_commands.rs: 移除冗余 PersistentMemoryStore embedding 配置段 - lib.rs: Tauri 命令 191→189 (移除 memory_configure_embedding + memory_is_embedding_configured) - TRUTH.md + wiki/log.md 数字同步 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
//! Memory Commands - Tauri commands for persistent memory operations
|
||||
//!
|
||||
//! Unified storage: All operations delegate to VikingStorage (SqliteStorage),
|
||||
//! All operations delegate to VikingStorage (SqliteStorage),
|
||||
//! which provides FTS5 full-text search, TF-IDF scoring, and optional embedding.
|
||||
//!
|
||||
//! The previous dual-write to PersistentMemoryStore has been removed.
|
||||
//! PersistentMemory type is retained for frontend API compatibility.
|
||||
//! PersistentMemoryStore was removed in V13 audit (FIX-06): all data ops
|
||||
//! go through VikingStorage; the old embedding global was never read.
|
||||
|
||||
use crate::memory::{PersistentMemory, PersistentMemoryStore, MemoryStats, configure_embedding_client, is_embedding_configured, EmbedFn};
|
||||
use crate::memory::{PersistentMemory, MemoryStats};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::sync::Arc;
|
||||
use tauri::{AppHandle, State};
|
||||
use tauri::State;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
/// Shared memory store state
|
||||
/// NOTE: PersistentMemoryStore is kept only for embedding configuration.
|
||||
/// All actual storage goes through VikingStorage (SqliteStorage).
|
||||
pub type MemoryStoreState = Arc<Mutex<Option<PersistentMemoryStore>>>;
|
||||
/// Vestigial state — PersistentMemoryStore removed, all ops via VikingStorage.
|
||||
/// Kept as `Arc<Mutex<()>>` to preserve Tauri state injection without dead types.
|
||||
pub type MemoryStoreState = Arc<Mutex<()>>;
|
||||
|
||||
/// Memory entry for frontend API
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -43,17 +43,14 @@ pub struct MemorySearchOptions {
|
||||
|
||||
/// Initialize the memory store
|
||||
///
|
||||
/// Now a no-op for storage (VikingStorage initializes itself in viking_commands).
|
||||
/// Only initializes PersistentMemoryStore for backward-compatible embedding config.
|
||||
/// Vestigial — VikingStorage initializes itself in viking_commands.
|
||||
/// Kept for frontend API compatibility (intelligence-backend.ts calls this).
|
||||
// @connected
|
||||
#[tauri::command]
|
||||
pub async fn memory_init(
|
||||
app_handle: AppHandle,
|
||||
state: State<'_, MemoryStoreState>,
|
||||
_state: State<'_, MemoryStoreState>,
|
||||
) -> Result<(), String> {
|
||||
let store = PersistentMemoryStore::new(&app_handle).await?;
|
||||
let mut state_guard = state.lock().await;
|
||||
*state_guard = Some(store);
|
||||
// VikingStorage auto-initializes in viking_commands::init_viking_storage()
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -370,49 +367,6 @@ pub async fn memory_db_path(
|
||||
Ok(db_path.to_string_lossy().to_string())
|
||||
}
|
||||
|
||||
/// @reserved — no frontend UI yet
|
||||
/// Configure embedding for PersistentMemoryStore (chat memory search)
|
||||
/// This is called alongside viking_configure_embedding to enable vector search in chat flow
|
||||
#[tauri::command]
|
||||
pub async fn memory_configure_embedding(
|
||||
provider: String,
|
||||
api_key: String,
|
||||
model: Option<String>,
|
||||
endpoint: Option<String>,
|
||||
) -> Result<bool, String> {
|
||||
let config = crate::llm::EmbeddingConfig {
|
||||
provider,
|
||||
api_key,
|
||||
endpoint,
|
||||
model,
|
||||
};
|
||||
let client = std::sync::Arc::new(crate::llm::EmbeddingClient::new(config));
|
||||
|
||||
let embed_fn: EmbedFn = {
|
||||
let client = client.clone();
|
||||
Arc::new(move |text: &str| {
|
||||
let client = client.clone();
|
||||
let text = text.to_string();
|
||||
Box::pin(async move {
|
||||
let response = client.embed(&text).await?;
|
||||
Ok(response.embedding)
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
configure_embedding_client(embed_fn);
|
||||
|
||||
tracing::info!("[MemoryCommands] Embedding configured");
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// @reserved — no frontend UI yet
|
||||
/// Check if embedding is configured for PersistentMemoryStore
|
||||
#[tauri::command]
|
||||
pub fn memory_is_embedding_configured() -> bool {
|
||||
is_embedding_configured()
|
||||
}
|
||||
|
||||
/// Build layered memory context for chat prompt injection
|
||||
///
|
||||
/// Uses VikingStorage (SqliteStorage) with FTS5 + TF-IDF + optional Embedding.
|
||||
|
||||
Reference in New Issue
Block a user