Skip to content

fix(gateway): support dedicated lifecycle channels - #84874

Open
Malk13r wants to merge 2 commits into
NousResearch:mainfrom
Malk13r:fix/gateway-lifecycle-channel
Open

fix(gateway): support dedicated lifecycle channels#84874
Malk13r wants to merge 2 commits into
NousResearch:mainfrom
Malk13r:fix/gateway-lifecycle-channel

Conversation

@Malk13r

@Malk13r Malk13r commented Aug 12, 2026

Copy link
Copy Markdown

Summary

  • add an optional per-platform gateway_restart_channel for gateway startup and shutdown broadcasts
  • preserve the existing home-channel fallback and gateway_restart_notification suppression flag
  • route both native and Relay-fronted lifecycle targets with thread and owner provenance intact
  • warn and fall back safely when the hand-authored lifecycle target is malformed

Closes #76780.

Why

Gateway lifecycle notices currently share the platform home channel with ordinary conversation and scheduled delivery. Operators must either accept restart noise in that channel or disable lifecycle visibility entirely.

This change separates those concerns without changing normal home-channel routing:

gateway:
  platforms:
    slack:
      gateway_restart_channel:
        platform: slack
        chat_id: "C0123456789"
        name: system-messages

When omitted, behaviour remains unchanged and lifecycle notices use home_channel.

Active-session interruption messages deliberately remain in the affected conversation; only platform-level startup/shutdown broadcasts use the lifecycle destination.

Compatibility and failure behaviour

  • no new environment variable
  • supports top-level platform blocks, platforms.*, and gateway.platforms.*
  • preserves documented config precedence
  • malformed lifecycle channel mappings log a warning and fall back to the home channel without dropping the platform config or preventing gateway startup
  • Relay-fronted targets retain user_id and scope_id provenance

Verification

  • focused canonical suite: 91 passed, 2 skipped
  • full gateway suite: 5,271 passed, 4 failed, 33 skipped
  • the same 4 failures reproduce on pristine origin/main:
    • macOS abstract systemd socket test
    • shutdown-forensics subprocess test
    • 2 optional WeCom XML tests
  • ruff check: passed
  • git diff --check: passed
  • independent exact-commit review of 0b4b107a7deaef9d49f91eec1d6ae0ed322f967f: PASS, no findings

Related work

This uses a structured HomeChannel target rather than a bare chat ID, addressing the Relay provenance and malformed-config gaps previously identified on #76787.

@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles needs-decision Awaiting maintainer decision before any implementation sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Aug 12, 2026
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

fix(gateway): support dedicated lifecycle channels

  1. Shutdown notifications now iterate all configured platforms (self.config.platforms) via resolve_delivery_transport instead of only connected adapters. A platform whose native adapter failed to start is now reached through the relay path even when the platform never actually connected — it will receive a "shutdown" notice it was never operational for. Worth verifying resolve_delivery_transport cannot return a transport for a platform in a failed/never-started state (or gating on connection state for non-relay targets).

  2. In _merge_platform_map, the new and not has_restart_channel skip-condition means a platform block containing only gateway_restart_channel now materializes a platform entry where it previously was dropped. Any downstream code that assumes the presence of an entry implies enabled/other config should be checked for the new edge (the malformed-value preservation is good, this is about the newly-materialized minimal entries).

  3. _send_home_channel_startup_notifications is now misnamed — it sends to the lifecycle channel with a home fallback. Renaming (or at least a docstring update) would prevent confusion for future readers searching for "lifecycle channel".

  4. Minor: gateway_restart_channel.platform is not validated against the containing platform key in from_dict (the malformed tests cover bad enum values, but a valid HomeChannel for a different platform would be accepted silently).

@Malk13r
Malk13r force-pushed the fix/gateway-lifecycle-channel branch from 0b4b107 to f1d4a30 Compare August 16, 2026 19:19
@Malk13r

Malk13r commented Aug 16, 2026

Copy link
Copy Markdown
Author

Review observations addressed

This branch has been rebased onto current upstream and now addresses all four automated observations:

  • lifecycle shutdown/startup delivery will not use Relay to mask an enabled native platform whose adapter failed to connect;
  • deliberately disabled logical platforms can still use a connected Relay adapter that explicitly fronts them;
  • a platform block containing only gateway_restart_channel remains disabled and absent from get_connected_platforms();
  • lifecycle targets whose platform differs from the containing platform block are ignored with a privacy-safe warning and home-channel fallback;
  • _send_home_channel_startup_notifications was renamed to _send_lifecycle_channel_startup_notifications and the routing contract is documented.

The change remains scoped to gateway lifecycle notices; ordinary replies, cron output and generic delivery routing are unchanged.

Verification

  • Focused config/lifecycle/delivery suite: 112 passed, 2 skipped
  • Gateway suite: 5,734 passed, 32 skipped; the three remaining failures were reproduced identically on pristine upstream and are unrelated host/optional-dependency failures
  • Ruff and git diff --check: clean
  • Independent review of exact commit f1d4a30167d07213f063d103453d3de2eb46bc1b: PASS, with no medium-or-higher publication blockers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Dedicated alerts channel for gateway lifecycle (up/down) notifications, separate from home channel

3 participants