The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
docs(gateway): point the rich_sent_store restatements at _LOCK
kshitijk4poor6351d60a6f3a
diff --git a/gateway/rich_sent_store.py b/gateway/rich_sent_store.pyindex 00ae6e471a1..4cb54129bf9 100644--- a/gateway/rich_sent_store.py+++ b/gateway/rich_sent_store.py@@ -57,7 +57,7 @@ def _update(chat_id, message_id, fields: dict) -> None:if len(data) > _MAX_ENTRIES: # trim oldest by timestampfor k, _ in sorted(data.items(), key=lambda kv: kv[1].get("ts", 0))[: len(data) - _MAX_ENTRIES]:data.pop(k, None)- atomic_json_write(path, data, indent=None) # atomic write; the lock makes the triple atomic+ atomic_json_write(path, data, indent=None) # see _LOCKexcept Exception:returndiff --git a/tests/gateway/test_rich_sent_store_off_loop.py b/tests/gateway/test_rich_sent_store_off_loop.pyindex 16b5a0a5ad1..f713a1befd3 100644--- a/tests/gateway/test_rich_sent_store_off_loop.py+++ b/tests/gateway/test_rich_sent_store_off_loop.py@@ -36,9 +36,8 @@ def test_record_async_runs_off_the_loop_thread(isolated_store, monkeypatch):def test_concurrent_record_async_calls_lose_no_entry(isolated_store, monkeypatch):"""Two off-loop RMWs for different keys must both land in the durable file.- ``atomic_json_write`` makes each write atomic, not load/merge/save. Slowing the- write forces the second caller to load the same pre-state unless ``_update`` is- serialized, in which case the later ``os.replace`` drops the other key.+ Slowing the write forces the lost-update race described on+ ``rich_sent_store._LOCK`` unless ``_update`` is serialized."""real_write = rich_sent_store.atomic_json_write