Skip to content

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

fix(profiles): register the lease fence before unclean-takeover recovery; ignore stale-epoch fence registration

Steven Enamakelf691e107f6b0
diff --git a/crates/openhuman-core/src/channels/bus/subscriber.rs b/crates/openhuman-core/src/channels/bus/subscriber.rs
index 1fafdf6f0d..307e15bf19 100644
--- a/crates/openhuman-core/src/channels/bus/subscriber.rs
+++ b/crates/openhuman-core/src/channels/bus/subscriber.rs
@@ -67,7 +67,9 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {
// If that contract is broken, the legacy channel-only key would let
// different users share one chat session and its prepared wallet quote.
if channel.split(':').next() == Some("discord")
- && sender.as_deref().is_none_or(|value| value.trim().is_empty())
+ && sender
+ .as_deref()
+ .is_none_or(|value| value.trim().is_empty())
{
tracing::warn!("[channel-inbound] dropping Discord message without sender id");
return;
diff --git a/crates/openhuman-core/src/storage/fence_tests.rs b/crates/openhuman-core/src/storage/fence_tests.rs
index 094730a71b..a154f3c57d 100644
--- a/crates/openhuman-core/src/storage/fence_tests.rs
+++ b/crates/openhuman-core/src/storage/fence_tests.rs
@@ -196,6 +196,10 @@ fn the_registry_replaces_retires_and_prunes_dead_tombstones() {
registry.register(Arc::clone(&second));
assert_eq!(registry.lookup("profile:alice").unwrap().epoch(), 2);
+ // An older grant's fence never displaces a newer one.
+ registry.register(Arc::clone(&first));
+ assert_eq!(registry.lookup("profile:alice").unwrap().epoch(), 2);
+
// Retiring a stale epoch leaves the current fence.
registry.retire("alice", 1);
assert_eq!(registry.lookup("profile:alice").unwrap().epoch(), 2);