Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
session_id: None,
ttl_seconds: None,
expires_at: None,
valid_from: None,
})
.await?;
println!("Stored memory: {}", mem1.memory_id);
Expand Down
24 changes: 24 additions & 0 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ pub struct StoreMemoryRequest {
/// decay engine on expiry (DECAY-3).
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<u64>,
/// Bi-temporal validity start — Unix timestamp (seconds) indicating when this
/// memory becomes temporally valid. Defaults to ingest time when omitted.
/// Used by temporal recall queries (server v0.11.98+, DAK-7424).
#[serde(skip_serializing_if = "Option::is_none")]
pub valid_from: Option<i64>,
}

fn default_importance() -> f32 {
Expand All @@ -71,6 +76,7 @@ impl StoreMemoryRequest {
metadata: None,
ttl_seconds: None,
expires_at: None,
valid_from: None,
}
}

Expand Down Expand Up @@ -117,6 +123,13 @@ impl StoreMemoryRequest {
self.expires_at = Some(expires_at);
self
}

/// Set bi-temporal validity start as a Unix timestamp (seconds).
/// Defaults to ingest time when omitted (server v0.11.98+, DAK-7424).
pub fn with_valid_from(mut self, valid_from: i64) -> Self {
self.valid_from = Some(valid_from);
self
}
}

/// Stored memory response from `POST /v1/memory/store`.
Expand Down Expand Up @@ -1064,6 +1077,10 @@ pub struct BatchStoreMemoryItem {
pub ttl_seconds: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub expires_at: Option<u64>,
/// Bi-temporal validity start — Unix timestamp (seconds). Defaults to ingest time when omitted.
/// Used by temporal recall queries (server v0.11.98+, DAK-7424).
#[serde(skip_serializing_if = "Option::is_none")]
pub valid_from: Option<i64>,
/// Optional custom ID. Auto-generated if not provided.
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
Expand Down Expand Up @@ -1103,6 +1120,13 @@ impl BatchStoreMemoryItem {
self
}

/// Set bi-temporal validity start as a Unix timestamp (seconds).
/// Defaults to ingest time when omitted (server v0.11.98+, DAK-7424).
pub fn with_valid_from(mut self, valid_from: i64) -> Self {
self.valid_from = Some(valid_from);
self
}

/// Set a custom memory ID.
pub fn with_id(mut self, id: impl Into<String>) -> Self {
self.id = Some(id.into());
Expand Down
21 changes: 21 additions & 0 deletions tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ async fn test_health() {
assert!(health.healthy);
}

// ---------------------------------------------------------------------------
// StoreMemoryRequest — bi-temporal valid_from serialization (DAK-7424)
// ---------------------------------------------------------------------------

#[test]
fn test_store_memory_request_valid_from_serialized_when_set() {
let req = StoreMemoryRequest::new("agent-1", "temporal memory").with_valid_from(1_700_000_000);
let json = serde_json::to_value(&req).unwrap();
assert_eq!(json["valid_from"], 1_700_000_000i64);
}

#[test]
fn test_store_memory_request_valid_from_omitted_when_none() {
let req = StoreMemoryRequest::new("agent-1", "non-temporal memory");
let json = serde_json::to_value(&req).unwrap();
assert!(
json.get("valid_from").is_none(),
"valid_from must be absent from JSON when not set"
);
}

#[test]
fn test_health_response_build_sha_present() {
let json = r#"{"healthy":true,"version":"0.11.84","build_sha":"abc1234def5678"}"#;
Expand Down
Loading