Skip to content

Replace the per-event Telegram switches with one alert level #3578

Closed

Description

@pithead-developer

What's the problem

Part of #3557. Telegram alerts have 25 per-event switches plus two tamper alarms (telegram.events.*). Each is rendered as its own TELEGRAM_EVENT_* variable, read into TELEGRAM_EVENTS in the dashboard config, and listed in the control allowlists. telegram.enabled repeats what the bot token and chat id already say. A non-technical user cannot choose among 25 switches.

Owner ruling (lean roadmap and #3566 section F, 2026-10-21; Settings mockup, 2026-10-27): Alerts become Connect Telegram (bot token, chat id), then one level, All / Important / Critical / Off, with the wallet-changed and clearnet-exposed alarms always on and not switchable.

Target model:

  • Keys: telegram.bot_token, telegram.chat_id and telegram.level (off, critical, important, all). Absent means off. telegram.enabled and telegram.events.* are removed. Telegram delivery exists when the token and chat id are both set.
  • Optional alerts by level, kept in one table (a product call):
    • Critical (6): node_down, node_recovered, container_unhealthy, db_unhealthy, disk_space, hashrate_loss.
    • Important adds (13): worker_offline, worker_recovered, sync_finished, db_reset, xvb_no_share, xvb_registration, hashrate_low, high_reject_rate, hugepages, low_ram, payout_found, payout_confirmed, raffle_win.
    • All adds (6): worker_joined, worker_left, stack_online, daily_summary, block_found, new_release.
    • Off: no optional alerts.
  • Delivered at every level including Off, whenever the token and chat id are set: the tamper alarms wallet_changed and clearnet_exposed, and payout_wallet_down (it has no opt-out today).
  • dashboard.hashrate_drop_threshold and dashboard.hashrate_drop_minutes stay loadable as Advanced overrides; each level uses 50 % over 10 minutes (today's default) until measured. telegram.daily_summary_time and telegram.commands.enabled stay Advanced and unchanged.

What it impacts

How I found it

Read-only scan of develop at 9249b0b on 2026-10-21 from the lean roadmap's Config keys and Dashboard controls tables and docs/telegram.md, re-read on 2026-10-27 against the notifier, the sinks and the render step. Nothing was executed. Checked: the 25 events above are exactly today's 25 switches; notify_sinks.py documents that webhook and ntfy push every event kind. Contradiction fixed here: the earlier text called the tamper alarms not switchable yet delivered them only at levels other than Off, while the owner ruling says always on. TELEGRAM_ENABLED is also read by the bot commands and the topology and egress views, not only the alerter.

Operator note, 2026-10-27: this does not wait for the Essentials key cut (#3576). Land it one at a time with the other #3557 children, after #3632, rebased on develop-v2.1.0.

Unknown: the right level for each event beyond this proposal; per-level hashrate thresholds (the roadmap gives only Critical = 50 %/10 min); the level the setup flows preselect once credentials are entered (absent stays off here); whether develop-v2.1.0 still matches the 9249b0b reads.

How important is it

Medium-high. It removes the largest group of settings and a source of silent misconfiguration, makes the tamper alarms impossible to silence, and the Alerts card in Settings (#2530) depends on it. It is not a release emergency.

Acceptance criteria

  • Tier-1 (new pytest in dashboard/tests/service): for each of critical, important and all the delivered optional events equal the table; off and an absent level deliver no optional event; an unknown level falls back to all with a log line. At every level including off, wallet_changed, clearnet_exposed and payout_wallet_down are delivered when token and chat id are set, and nothing reaches Telegram when either is missing.
  • Tier-1: with a webhook and an ntfy sink configured, both still receive every event at every level; the level gates Telegram only.
  • Tier-1: render_env emits TELEGRAM_LEVEL and none of the 27 TELEGRAM_EVENT_* variables or TELEGRAM_ENABLED; 36-quadlet-units.sh and the support-bundle variable list (07-support-bundle.sh) follow. The alerter, bot commands, topology and egress views read the derived "token and chat id set" flag.
  • Tier-1: TELEGRAM_LEVEL is direct-commit like the toggles were. The TELEGRAM_ENABLED approval rows (APPROVAL_ENV_KEY_PATHS in config_operations.py, CONTROL_DASHBOARD_APPROVAL_KEYS in 42-control-policy-and-host-checks.sh) are removed; bot token and chat id keep the stricter unlisted route. dashboard/tests/service/test_env_key_perimeter.py and tests/stack/control/test-control-editable-allowlist.sh stay green.
  • Tier-1 migration fixtures of 2.0.0 configs (in tests/stack/config/migration.sh and the 2.0.0 fixtures if Cut the visible config keys to the Essentials and migrate 2.0.0 configs safely #3576 has added them, otherwise Telegram fixtures of their own; the step sits beside migrate_removed_telegram_control):
    • Token, chat id and enabled = true: the 25 optional toggles (absent counts as on, as in 2.0.0) map by symmetric difference to the nearest level; ties go to the more verbose; an empty set maps to off.
    • Credentials with enabled absent or false map to off.
    • One warning line lists the events whose delivery changes, including the always-on alarms starting. A config with wallet_changed = false or clearnet_exposed = false warns that the tamper alarms are now always on.
    • A second run changes nothing and a dry run writes nothing.
  • Tier-1: 39a-describe-change-notifications.sh describes a level change in words (which alert kinds start or stop), drops the tamper-alarm switch-off case and no longer names removed keys; ./pithead test-alert still reaches every configured sink.
  • docs/telegram.md replaces the event-key table with a level column and names the always-on alarms; the dropped keys are listed in docs/configuration.md (in Cut the visible config keys to the Essentials and migrate 2.0.0 configs safely #3576's 'Removed in 2.1.0' table when it exists).
  • The current dashboard UI gets deletions only: references to telegram.events.* and telegram.enabled, and the tests asserting them, are removed where they fail once the keys are gone. No FIELD_OPTIONS entry, warning text or test is added for telegram.level there; the level control is the Alerts card of Sovereign: organize mining and advanced settings without losing fields #2530. No code comments are added.

Possible solutions

  • Level table as a single Python mapping, with the bash side only passing TELEGRAM_LEVEL through; a drift test compares it to docs/telegram.md.
  • Keep telegram.events.* readable for one release as Advanced overrides for the optional events only (never the tamper alarms) instead of dropping them; costs surface, avoids silent changes.
  • Per-level hashrate thresholds once measured, instead of one fixed pair.
Earlier scope, kept as evidence only (superseded 2026-10-27; do not implement from it)

What's the problem
Part of #3557. Telegram alerts have 25 event switches plus two tamper alarms (config.reference.json, telegram.events), each rendered as its own TELEGRAM_EVENT_* variable (lib/pithead/33-render-env.sh:207-242), read in dashboard/mining_dashboard/config/config.py (TELEGRAM_EVENTS), and listed in the control allowlists (service/control_service.py, lib/pithead/42-control-policy-and-host-checks.sh). telegram.enabled is redundant with the token and chat id being set. A non-technical user cannot choose among 25 switches.

Proposed: telegram.bot_token, telegram.chat_id and one telegram.level: off, critical, important or all. Absent means off, and telegram.enabled is removed. Delivery is on when token, chat id and a level other than off are present. Proposed membership (a product call, kept in one table):

  • Critical (6, plus tamper): node_down, node_recovered, container_unhealthy, db_unhealthy, disk_space, hashrate_loss.
  • Important adds (13): worker_offline, worker_recovered, sync_finished, db_reset, xvb_no_share, xvb_registration, hashrate_low, high_reject_rate, hugepages, low_ram, payout_found, payout_confirmed, raffle_win.
  • All adds (6): worker_joined, worker_left, stack_online, daily_summary, block_found, new_release.
  • Every level, not switchable: tamper alarms wallet_changed and clearnet_exposed, and payout_wallet_down.
    Hashrate-drop thresholds stay loadable as Advanced overrides; the level supplies 50 % over 10 minutes (today's default) at all three levels until measured. telegram.daily_summary_time and telegram.commands.enabled stay Advanced.

what it impacts
Every user with Telegram configured: after migration some alerts may start or stop. The tamper alarms become non-silenceable, which reverses the 2026-09 ruling that allowed silencing them behind a typed APPLY and envelope (42-control-policy-and-host-checks.sh comments on #2367); the owner's lean roadmap asks for this. Webhook and ntfy users: the per-event toggles gate the Telegram notifier (telegram_notifier.py:72); whether they also gate the webhook and ntfy sinks was not traced and must be confirmed. The Alerts card in the lean Settings page (#2535, folded into #2530) is built on this model.

How I found it
Read-only scan of develop at 9249b0b on 2026-10-21 from the lean roadmap's Config keys and Dashboard controls tables and docs/telegram.md (event table lines 163-191). Nothing was executed. Unknown: the right level for each event beyond this proposal, and any per-level hashrate thresholds (the roadmap gives only Critical = 50 %/10 min).

how important is it
Medium-high: it removes the largest group of settings and a source of silent misconfiguration. Needs the migration scaffold from the key-diet issue.

acceptance criteria

  • Tier-1 (new pytest in dashboard/tests/service): for each level the delivered event set equals the table; the tamper alarms and payout_wallet_down are delivered at every level except off; an absent level delivers nothing; an unknown level value falls back to all with a log line.
  • Tier-1 (tests/stack/config/migration.sh fixtures): 2.0.0 configs with token, chat id and enabled = true map by symmetric difference to the nearest level (ties go to the more verbose; an empty set maps to off); a config with credentials but enabled absent or false maps to off, because 2.0.0 sent nothing for it. One warning line lists the events whose delivery changes. A config with wallet_changed = false or clearnet_exposed = false warns that tamper alarms are now always on.
  • Tier-1: render_env emits TELEGRAM_LEVEL and none of the 27 TELEGRAM_EVENT_* variables; 36-quadlet-units.sh and the support-bundle variable list (07-support-bundle.sh) follow.
  • Tier-1: TELEGRAM_LEVEL is direct-commit like the toggles were; TELEGRAM_ENABLED and its approval row (config_operations.py APPROVAL_ENV_KEY_PATHS) are removed; bot token and chat id keep the stricter unlisted route. Drift guards updated: dashboard/tests/service/test_env_key_perimeter.py and tests/stack/control/test-control-editable-allowlist.sh.
  • Tier-1: 39a-describe-change-notifications.sh describes a level change in words (which alert kinds start or stop); ./pithead test-alert still reaches every configured sink.
  • Webhook and ntfy gating is confirmed in the PR and covered by a test either way.
  • docs/telegram.md replaces the event-key table with a level column. The current panel and its warnings (telegram.level in FIELD_OPTIONS, configwarnings.mjs text for the tamper alarms) get only the minimum edits needed to follow the keys; no new current-UI behaviour (ruling 4, v2.1.0 lean UI spec: four pages, one profile control, an Advanced drawer #3566). No new explanatory code comments.

possible solutions

  • Level table as a single Python mapping, with the bash side only passing TELEGRAM_LEVEL through; a drift test compares it to docs/telegram.md.
  • Keep telegram.events.* readable for one release as Advanced overrides instead of dropping them; costs surface, avoids silent changes.
  • Per-level hashrate thresholds once measured, instead of one fixed pair.

Part of #3557.

Owner decision (operator note, 2026-10-27). The owner ruled on 2026-10-21 (lean roadmap, #3566 section F) that Alerts become one control: Connect Telegram, then one level (All / Important / Critical / Off), with the wallet-changed and clearnet-exposed alarms always on. The user-visible effect: today's per-event switches are replaced by one choice on the new Settings page, which is reviewed in the owner's mockups. On 2026-10-27 the owner directed that this work proceed now, as part of the #3557 configuration model that the Settings page depends on.

Activity

  1. added this to the v2.1.0 milestone on Oct 21, 2026
  2. added
    enhancement
    dashboard
    notifications
    on Oct 21, 2026
  3. added
    blocked
    on Oct 21, 2026
  4. pithead-developer commented on Oct 27, 2026

    @pithead-developer
    ContributorAuthor

    Operator: unblocked from #3576. One alert level instead of per-event switches does not need the Essentials key cut first. Land it one at a time with the other #3557 children, after #3632, and rebase on develop-v2.1.0 before review. The Settings mockup shows the target: Connect Telegram, then All / Important / Critical / Off, with the tamper alarms always on.

  5. removed
    blocked
    on Oct 27, 2026
  6. pithead-developer commented on Oct 27, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #3632. The trusted operator instruction requires #3578 to follow PR #3632, which remains open. Reconnaissance is complete; the working tree is clean, and no implementation or tests ran. Resume after #3632 merges into develop-v2.1.0, then implement and verify the Telegram alert-level migration.

    The runner resumes this issue when that one closes.

  7. added
    blocked
    on Oct 27, 2026
  8. 2 remaining items

  9. pithead-developer commented on Nov 13, 2026

    @pithead-developer
    ContributorAuthor

    Waiting on a transient bench_outage condition, not on another issue. tier4-e2e 868@222989dd preflight refused: live stack unhealthy, Tor clearnet egress unverified (connect-timeout via SOCKS); baseline verified no. The runner re-checks it (first at 2026-11-13T07:30Z, at most 5 times); the durable fix is tracked in #3626.

  10. pithead-developer commented on Nov 15, 2026

    @pithead-developer
    ContributorAuthor

    Waiting on a transient bench_capacity condition, not on another issue. tier4-kvm 3990@04f8e0a5 errored: required shared node inputs/reservation unavailable after 14400s (sync_wait_seconds=14400); no image build started. tier4-e2e 3989 still queued. The runner re-checks it (first at 2026-11-15T17:01Z, at most 5 times).

  11. pithead-developer commented on Nov 19, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #3971.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    dashboardenhancementnotifications

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions