Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(memory): assert invalid policy updates leave config unchanged

Steven Enamakel28028edfe727
diff --git a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
index 5563d2b2c3..ee12170014 100644
--- a/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/views_tests.rs
@@ -49,10 +49,18 @@ fn the_policy_round_trips_and_refuses_out_of_range_values() {
..PolicySetParams::default()
},
] {
- assert!(matches!(
- apply_policy_set(&mut config, &bad),
- Err(MemoryError::InvalidRequest(_))
- ));
+ let before = serde_json::to_value(&config).unwrap();
+ let result = apply_policy_set(&mut config, &PolicySetParams {
+ log_conversations: Some(!config.memory.conversations.enabled),
+ recall_enabled: Some(!config.memory.recall.enabled),
+ ..bad
+ });
+ assert!(matches!(result, Err(MemoryError::InvalidRequest(_))));
+ assert_eq!(
+ serde_json::to_value(&config).unwrap(),
+ before,
+ "invalid policy update must be atomic"
+ );
}
config.memory.agent_id = Some("employee-7".into());
assert!(policy_view(&config).host_bound);