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

Function dedup_learnings

atomic-agent/src/learnings.rs:313–338  ·  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

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

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