26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
48 lines
1.7 KiB
Rust
48 lines
1.7 KiB
Rust
use lean_ctx::core::knowledge::ProjectKnowledge;
|
|
use lean_ctx::core::memory_policy::MemoryPolicy;
|
|
|
|
#[test]
|
|
fn recall_rehydrates_from_archive_when_active_set_empty() {
|
|
let _g = lean_ctx::core::data_dir::test_env_lock();
|
|
let tmp = tempfile::tempdir().expect("tempdir");
|
|
let data_dir = tmp.path().join("data");
|
|
std::fs::create_dir_all(&data_dir).expect("mkdir");
|
|
// TODO: Audit that the environment access only happens in single-threaded code.
|
|
unsafe { std::env::set_var("LEAN_CTX_DATA_DIR", data_dir.to_string_lossy().to_string()) };
|
|
|
|
let project_root = tmp.path().join("proj");
|
|
std::fs::create_dir_all(&project_root).expect("mkdir proj");
|
|
let project_root_str = project_root.to_string_lossy().to_string();
|
|
|
|
// Create a fact that will be archived by lifecycle (low confidence).
|
|
let policy = MemoryPolicy::default();
|
|
let mut k = ProjectKnowledge::load_or_create(&project_root_str);
|
|
k.remember("architecture", "db", "PostgreSQL", "s1", 0.1, &policy);
|
|
let _ = k.run_memory_lifecycle(&policy);
|
|
k.save().expect("save");
|
|
|
|
// Now the active set should be empty (fact archived), so recall should rehydrate it.
|
|
let out = lean_ctx::tools::ctx_knowledge::handle(
|
|
&project_root_str,
|
|
"recall",
|
|
None,
|
|
None,
|
|
None,
|
|
Some("db postgres"),
|
|
"s1",
|
|
None,
|
|
None,
|
|
None,
|
|
None,
|
|
None,
|
|
);
|
|
|
|
assert!(
|
|
out.contains("architecture/db") || out.contains("PostgreSQL"),
|
|
"expected rehydrated recall result, got: {out}"
|
|
);
|
|
|
|
// TODO: Audit that the environment access only happens in single-threaded code.
|
|
unsafe { std::env::remove_var("LEAN_CTX_DATA_DIR") };
|
|
}
|