use atheneum::graph::AtheneumGraph;
use serde_json::json;
#[test]
fn test_seed_memory_primitive() {
let graph = AtheneumGraph::open_in_memory().expect("open");
graph
.upsert_concept(
"Compiler Optimization",
&json!({
"summary": "Transforms source code to execute more efficiently",
"scope": "project",
"project_id": "envoy"
}),
)
.unwrap();
graph
.upsert_concept(
"Memory Allocator",
&json!({
"summary": "Manages physical heap memory segments",
"scope": "global"
}),
)
.unwrap();
graph
.store_memory("key1", "Vim preference details", "user", 1.0, None, None)
.unwrap();
std::thread::sleep(std::time::Duration::from_millis(50));
graph
.store_memory(
"key2",
"Emacs preference details",
"project",
0.9,
Some("envoy"),
None,
)
.unwrap();
graph.with_raw_connection(|conn| {
conn.execute(
"INSERT INTO graph_entities (kind, name, file_path, data) VALUES ('ToolCall', 'grep_search', NULL, '{}')",
[],
)?;
Ok(())
}).unwrap();
let seed = graph.seed_memory(None, 1000).unwrap();
println!("High budget instructions:\n{}", seed.instructions);
assert!(seed.instructions.contains("Compiler Optimization"));
assert!(seed.instructions.contains("Memory Allocator"));
assert!(seed.instructions.contains("key1"));
assert!(seed.instructions.contains("key2"));
assert!(!seed.instructions.contains("grep_search"));
let seed_proj = graph.seed_memory(Some("envoy"), 1000).unwrap();
println!("Envoy project instructions:\n{}", seed_proj.instructions);
assert!(seed_proj.instructions.contains("Compiler Optimization"));
assert!(seed_proj.instructions.contains("key2"));
assert!(!seed_proj.instructions.contains("Memory Allocator"));
assert!(!seed_proj.instructions.contains("key1"));
let seed_low = graph.seed_memory(None, 20).unwrap();
println!("Low budget instructions:\n{}", seed_low.instructions);
assert!(seed_low.instructions.contains("truncated") || seed_low.token_estimate <= 20);
}