fix(gateway): notify home channels after cold start and crash recovery - #69676
fix(gateway): notify home channels after cold start and crash recovery#69676plcunha wants to merge 3 commits into
Conversation
|
Found and fixed a lifecycle-notification race in |
|
Thanks for investigating the startup-notification failures. Two parts of this PR have since been addressed on current main at more appropriate boundaries. Problems
Suggested changes
Automated hermes-sweeper review. |
|
Reconciled with current main and re-scoped on head |
…+ cold-start notify + PID liveness check Three fixes for the gateway startup notification cascade: 1. Wait for Telegram _send_path_degraded to clear before sending home-channel startup notifications (up to 15s). The old fixed 1.0s sleep raced the first getUpdates cycle on networks where Telegram needs IPv6 fallback -> DoH -> sticky IPv4 (>1s). Fixes the race documented in NousResearch#66589. 2. Send home-channel startup notification on ALL starts (cold start, crash recovery, post-update restart), not only planned restarts. Chat-originated /restart still suppresses the duplicate (its reply target already covers that lifecycle). Fixes the design gap in NousResearch#62512. 3. Add PID liveness check to read_runtime_status() so dashboards and /api/status report 'stopped' instead of 'running' when the gateway PID is dead but the state file is stale. Fixes the false-positive health check that masked NousResearch#56524.
The _pid_exists helper already existed at gateway/status.py:733 with proper cross-platform handling (Windows-safe via ctypes, not os.kill). Reuse it instead of adding a redundant function that duplicates the same logic and breaks existing test mocks that patch _pid_exists.
fbf193c to
de2cf15
Compare
1|## Summary
2|
3|Notify configured home channels when the gateway becomes available after a true cold start or crash recovery, while preserving mode-specific behavior for chat-originated
/restart.4|
5|This PR has been re-scoped against current
mainin response to review. It no longer duplicates Telegram adapter readiness or dashboard PID-liveness logic already implemented upstream.6|
7|## Current behavior
8|
9|Current
mainsends the home-channel lifecycle notification only for a non-chat planned restart. A cold service start or crash recovery completes silently even when a home channel is configured.10|
11|## Change
12|
13|- Send the existing lightweight home-channel startup notification when no chat-originated restart marker was present.
14|- Keep chat
/restartscoped to its originating chat/topic and suppress a duplicate home-channel broadcast.15|- Preserve planned-restart marker cleanup.
16|- Treat home-channel notification delivery as best effort so it cannot abort gateway startup.
17|
18|## Explicitly not included
19|
20|- No runner-level Telegram
_send_path_degradedpolling; adapter readiness remains owned by the Telegram adapter.21|- No runtime-status PID override; dashboard liveness remains owned by
resolve_gateway_liveness()andget_runtime_status_running_pid().22|
23|## Tests
24|
25|Added mode-specific regressions for:
26|
27|1. cold/crash-recovery startup broadcasts exactly through the home-channel path;
28|2. chat-originated
/restartdoes not also broadcast to home.29|
30|Validation on current
origin/main:31|
32|-
21 passedacross startup and restart-notification suites33|- Ruff passed
34|-
py_compilepassed35|-
git diff --checkpassed36|
37|## Policy note
38|
39|This intentionally isolates the remaining maintainer decision identified by the sweeper: whether configured home channels should receive an online notification after cold start/crash recovery. The implementation and tests are now limited to that policy choice.
40|