MCPcopy Create free account
hub / github.com/1jehuang/jcode / remember_project

Method remember_project

crates/jcode-base/src/memory.rs:396–429  ·  view source on GitHub ↗
(&self, entry: MemoryEntry)

Source from the content-addressed store, hash-verified

394 const STORAGE_DEDUP_THRESHOLD: f32 = 0.85;
395
396 pub fn remember_project(&self, entry: MemoryEntry) -> Result<String> {
397 let mut entry = entry;
398 if self.should_generate_embedding_for_entry(&entry) {
399 entry.ensure_embedding();
400 }
401
402 let mut graph = self.load_project_graph()?;
403
404 if let Some(ref emb) = entry.embedding {
405 if let Some(existing_id) =
406 Self::find_duplicate_in_graph(&graph, emb, Self::STORAGE_DEDUP_THRESHOLD)
407 && let Some(existing) = graph.get_memory_mut(&existing_id)
408 {
409 existing.reinforce(entry.source.as_deref().unwrap_or("dedup"), 0);
410 self.save_project_graph(&graph)?;
411 return Ok(existing_id);
412 }
413
414 // Cross-store dedup: also check global graph
415 if let Ok(mut global_graph) = self.load_global_graph()
416 && let Some(existing_id) =
417 Self::find_duplicate_in_graph(&global_graph, emb, Self::STORAGE_DEDUP_THRESHOLD)
418 && let Some(existing) = global_graph.get_memory_mut(&existing_id)
419 {
420 existing.reinforce(entry.source.as_deref().unwrap_or("cross-dedup"), 0);
421 self.save_global_graph(&global_graph)?;
422 return Ok(existing_id);
423 }
424 }
425
426 let id = graph.add_memory(entry);
427 self.save_project_graph(&graph)?;
428 Ok(id)
429 }
430
431 pub fn remember_global(&self, entry: MemoryEntry) -> Result<String> {
432 let mut entry = entry;

Calls 9

ensure_embeddingMethod · 0.80
load_project_graphMethod · 0.80
get_memory_mutMethod · 0.80
reinforceMethod · 0.80
save_project_graphMethod · 0.80
load_global_graphMethod · 0.80
save_global_graphMethod · 0.80
add_memoryMethod · 0.80