Files
hermes-agent/plugins
pierrenode cf6547da47 fix(gateway): offload remaining atomic_json_write calls on platform-adapter hot paths
atomic_json_write() calls os.fsync(), which blocks until the write
reaches stable storage. #83906 offloaded this in channel_directory.py,
gateway/run.py, and gateway/slash_commands.py, but the same blocking
pattern was still present on three platform-adapter message hot paths
that were never touched by that pass:

- plugins/platforms/feishu/adapter.py: _is_duplicate() persists the
  dedup cache on every new inbound message (shared by both websocket
  and webhook transports). The in-memory bookkeeping stays under
  _dedup_lock; the fsync now runs off it via asyncio.to_thread so
  concurrent callers on the ws-thread loop aren't blocked on disk I/O.

- gateway/platforms/weixin.py: ContextTokenStore.set() persists the
  context-token cache on every inbound message carrying a
  context_token, called from the async poll-loop handler
  _process_message.

- plugins/platforms/discord/adapter.py: mark_many() persists the
  non-conversational message-id tracker, called from both send() and
  send_update_prompt() when a message is tagged nonconversational.

Each fix mirrors the existing asyncio.to_thread(atomic_json_write, ...)
pattern from #83906. Regression tests assert the persist call runs on
a different thread than the event loop, mirroring
test_directory_write_runs_off_event_loop_thread in
test_channel_directory.py.
2026-09-03 02:17:01 +05:30
..