Skip to content

fix(gateway): preserve home-channel thread targets across restart notifications (salvage #18440)#19271

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f55f24e9
May 3, 2026
Merged

fix(gateway): preserve home-channel thread targets across restart notifications (salvage #18440)#19271
teknium1 merged 2 commits into
mainfrom
hermes/hermes-f55f24e9

Conversation

@teknium1

@teknium1 teknium1 commented May 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of #18440/restart now reliably signals "gateway is back" in the configured home channel, and home-channel targeting preserves thread/topic IDs.

Changes

  • HomeChannel gains thread_id (threaded platforms only populate it)
  • _apply_env_overrides: every platform reads *_HOME_CHANNEL_THREAD_ID (and *_HOME_ROOM_THREAD_ID for Matrix)
  • /sethome updates the running GatewayConfig in-place so the pre-restart notification path sees the new home before the process reloads
  • New _send_home_channel_startup_notifications() — broadcasts once per home channel after restart, only when .restart_notify.json is present (no cold-start noise)
  • Shutdown/restart dedup key widened from (platform, chat_id) to (platform, chat_id, thread_id) so forum topics don't collide with parent chats
  • SendResult(success=False) is treated as a delivery failure instead of logged as success
  • cron/scheduler.py: bare-platform delivery (deliver: "discord") picks up DISCORD_HOME_CHANNEL_THREAD_ID so cron jobs land in the same topic /sethome picked

Salvage notes

  • Cherry-picked 892c307 from @leprincep35700's branch onto current main.
  • Resolved a conflict with fix(gateway): shutdown + restart hygiene (drain timeout, false-fatal, success log) #18761 (shutdown + restart hygiene) in _send_restart_notification — kept the PR's new return value (used for cross-function dedup) and reused main's existing "was not delivered" / "Sent restart notification" log wording so both the PR's new tests and main's existing regression tests assert correctly.
  • Added AUTHOR_MAP entry for the contributor email in scripts/release.py (required by CI).

Validation

116 targeted tests pass:

tests/gateway/test_restart_notification.py
tests/gateway/test_restart_resume_pending.py
tests/gateway/test_home_target_env_var.py
tests/cron/test_scheduler.py::TestResolveDeliveryTarget

Closes #18440.

Co-authored-by: leprincep35700 61830395+leprincep35700@users.noreply.github.com

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery comp/cron Cron scheduler and job management labels May 3, 2026
@teknium1 teknium1 merged commit 3c59566 into main May 3, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-f55f24e9 branch May 3, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants