Skip to content

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

fix(memory): key the free-period cache with the full credential digest

M3gA-Mind73e416f53444
diff --git a/crates/openhuman-core/src/memory/billing.rs b/crates/openhuman-core/src/memory/billing.rs
index 8b9a182c55..4f2cee7b34 100644
--- a/crates/openhuman-core/src/memory/billing.rs
+++ b/crates/openhuman-core/src/memory/billing.rs
@@ -68,11 +68,11 @@ pub async fn free_period_active(config: &Config) -> bool {
.await
}
-/// A short, one-way digest of a credential, for a cache key.
+/// A one-way digest of a credential for a cache key: the full SHA-256, so
+/// two accounts never share a key.
fn digest(secret: &str) -> String {
sha2::Sha256::digest(secret.as_bytes())
.iter()
- .take(8)
.map(|byte| format!("{byte:02x}"))
.collect()
}
diff --git a/crates/openhuman-core/src/memory/billing_tests.rs b/crates/openhuman-core/src/memory/billing_tests.rs
index 2f451179be..40037a4696 100644
--- a/crates/openhuman-core/src/memory/billing_tests.rs
+++ b/crates/openhuman-core/src/memory/billing_tests.rs
@@ -258,3 +258,10 @@ async fn each_account_keeps_its_own_answer() {
"the second account asked for its own answer"
);
}
+
+#[test]
+fn the_cache_key_digest_is_the_full_sha256() {
+ let key = digest("th_account_a");
+ assert_eq!(key.len(), 64, "{key}");
+ assert_ne!(key, digest("th_account_b"));
+}