Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
test(admin): cover the expired flag of read-page
Vinícius DS Andrade117ce4b90c77
diff --git a/crates/ai-memory-mcp/tests/suite/admin_read_page.rs b/crates/ai-memory-mcp/tests/suite/admin_read_page.rsindex da182a85..9fb678c2 100644--- a/crates/ai-memory-mcp/tests/suite/admin_read_page.rs+++ b/crates/ai-memory-mcp/tests/suite/admin_read_page.rs@@ -319,3 +319,89 @@ async fn read_page_missing_scope_does_not_create_workspace_or_project() {"read-page must not create a missing workspace");}++/// An expired page is still served by its exact path, but the response says+/// so: search and the listings leave such a page out, and `read-page` shows+/// the flag. A live page's response has no `expired` key.+#[tokio::test]+async fn read_page_marks_an_expired_page() {+ let tmp = TempDir::new().unwrap();+ let (state, store) = make_state(&tmp).await;+ let ws = store+ .writer+ .get_or_create_workspace("default".to_string())+ .await+ .unwrap();+ let proj = store+ .writer+ .get_or_create_project(ws, "scratch".to_string(), None)+ .await+ .unwrap();+ for (path, expires_at) in [+ ("notes/dated.md", "2000-01-01"),+ ("notes/later.md", "2999-01-01"),+ ] {+ state+ .wiki+ .write_page(WritePageRequest {+ workspace_id: ws,+ project_id: proj,+ path: PagePath::new(path).unwrap(),+ frontmatter: serde_json::json!({"title": "Dated", "expires_at": expires_at}),+ body: "dated body".to_string(),+ tier: Tier::Semantic,+ pinned: false,+ title: Some("Dated".into()),+ admission_ctx: None,+ author_id: None,+ actor: ai_memory_core::ActorContext::anonymous(),+ evidence: Vec::new(),+ })+ .await+ .unwrap();+ }+ // The DB fallback annotates too: an expired row with no file behind it.+ let a_minute_ago = jiff::Timestamp::now().as_second() - 60;+ store+ .writer+ .upsert_page(NewPage {+ workspace_id: ws,+ project_id: proj,+ path: PagePath::new("notes/db-only-dated.md").unwrap(),+ title: "DB Only Dated".to_string(),+ body: "fallback body".to_string(),+ tier: Tier::Semantic,+ frontmatter_json: serde_json::json!({"title": "DB Only Dated"}),+ pinned: false,+ links: Vec::new(),+ author_id: None,+ expires_at: Some(jiff::Timestamp::from_second(a_minute_ago).unwrap()),+ entities: Vec::new(),+ evidence: Vec::new(),+ })+ .await+ .unwrap();++ for (path, expired) in [+ ("notes%2Fdated.md", true),+ ("notes%2Flater.md", false),+ ("notes%2Fdb-only-dated.md", true),+ ] {+ let resp = get(+ state.clone(),+ &format!("/admin/read-page?workspace=default&project=scratch&path={path}"),+ )+ .await;+ assert_eq!(resp.status(), StatusCode::OK, "{path}");+ let body = body_json(resp).await;+ assert!(+ body["body"].as_str().is_some_and(|text| !text.is_empty()),+ "{body}"+ );+ assert_eq!(+ body.get("expired").and_then(serde_json::Value::as_bool),+ expired.then_some(true),+ "{path}: {body}"+ );+ }+}