MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / dedup_learnings

Function dedup_learnings

atomic-agent/src/learnings.rs:315–340  ·  view source on GitHub ↗

Remove learnings that already exist in the context file. Returns a new `Learnings` with only the Repo and Workflow entries that are not already present. Code learnings are always empty in the result because they're not written to context files. Comparison is by finding text (exact match on the list item content).

(existing_content: &str, new_learnings: &Learnings)

Source from the content-addressed store, hash-verified

313///
314/// Comparison is by finding text (exact match on the list item content).
315pub fn dedup_learnings(existing_content: &str, new_learnings: &Learnings) -> Learnings {
316 let existing = read_existing_learnings(existing_content);
317
318 let repo: Vec<String> = new_learnings
319 .repo
320 .iter()
321 .filter(|item| !is_duplicate(&existing, &format!("- {}", item)))
322 .cloned()
323 .collect();
324
325 // Code learnings are not written to context files — skip them
326 let code: Vec<CodeLearning> = Vec::new();
327
328 let workflow: Vec<String> = new_learnings
329 .workflow
330 .iter()
331 .filter(|item| !is_duplicate(&existing, &format!("- {}", item)))
332 .cloned()
333 .collect();
334
335 Learnings {
336 repo,
337 code,
338 workflow,
339 }
340}
341
342// Save to Context File
343

Callers 5

test_dedup_no_existingFunction · 0.85

Calls 3

read_existing_learningsFunction · 0.85
is_duplicateFunction · 0.85
iterMethod · 0.45

Tested by 4

test_dedup_no_existingFunction · 0.68