d-miner5(p1): transport-agnostic miner notification engine (evaluator + core + email adapter) - #552
Merged
Merged
Conversation
Implements D-MINER.5 phase-1 per docs/design/d-miner-5-notify-engine.md: event evaluator + transport-agnostic notification core + email adapter. - reads the D-MINER.1 presence sqlite (samples table), diffs the newest per-worker sample against carried worker_state into typed events: offline>N min, back_online, hashrate_drop (vs observed peak). - notification core (no transport knowledge): per-worker subscription, throttle/dedupe window, quiet-hours (warn severity bypasses quiet). - pluggable transport adapters: email (smtplib) + logonly; V36 P2P relay (P2) and Telegram (P3) plug in at the same seam with no core change. - charter honesty: online == observed hashrate>0 (never fabricated); every Message is recorded in notifications with an explicit status (delivered/undelivered/throttled/quiet) — an undelivered alert is logged, never silently dropped. - deterministic in-memory selftest KAT (9/9): first-online silence, offline threshold + non-refire latch, back-online edge, hashrate-drop, quiet-hours warn-bypass, throttle, and unsubscribed->undelivered.
| selftest deterministic in-memory KAT of the evaluator + core (no network) | ||
| """ | ||
| import argparse | ||
| import json |
| updates worker_state. `sub_for(worker)` returns the effective subscription | ||
| (so thresholds are per worker). `at` overrides wall clock for testing. | ||
| """ | ||
| at = at if at is not None else now_ts() |
This was referenced Jun 26, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
D-MINER.5 P1 — transport-agnostic miner notification engine
Implements phase-1 of
docs/design/d-miner-5-notify-engine.md(the designmerged via #547): event evaluator + transport-agnostic notification core +
email adapter — the slice that doc marks as "shippable solo, web-owned".
What it does
scripts/miner_notify_engine.pyreads the D-MINER.1 presence sqlite, diffs thenewest per-worker sample against carried
worker_state, and emits typed events:A transport-agnostic core then applies per-worker subscription,
throttle/dedupe window, and quiet-hours (warn severity bypasses quiet),
and hands an abstract Message to a pluggable transport (
emailvia smtplib,logonlyfor dry-run). The V36 P2P relay (P2) and Telegram (P3) adapters plugin at the same seam with no core change.
Charter honesty
online == observed hashrate > 0— same source of truth as the dashboard;presence is never fabricated.
notificationswith an explicit status(
delivered/undelivered/throttled/quiet). An alert that cannot bedelivered is logged undelivered, never silently dropped.
Tests
Deterministic in-memory selftest KAT, 9/9 green (
python3 scripts/miner_notify_engine.py selftest):first-online silence, offline threshold + non-refire latch, back-online edge,
hashrate-drop, quiet-hours warn-bypass, throttle, unsubscribed→undelivered.
Script is stdlib-only; no new deps, no build/CI impact (web-owned tooling).