Skip to content

Commit 7e798ba

Browse files
authored
d-miner5(kat): pin throttle re-fire after window elapses (#567)
* d-miner5(fix): gate back_online on a reported outage evaluate() emitted a back_online event whenever the prior sample was offline, regardless of whether an OFFLINE alert had actually fired. A sub-threshold blip (dark < offline_min) never fires OFFLINE, so the recovery edge would tell the miner they are back from an outage they were never told about and that never met the alert threshold -- a false-positive notification. Gate the back_online edge on offline_fired so a recovery is only reported when the outage itself was reported. Add KAT scenario 6b (blip-then-recover stays silent); selftest 10/10. * d-miner5(kat): pin hashrate_drop honesty (no fabricated drop without observed peak) Extends the D-MINER.5 notify-engine selftest to regression-lock the HASHRATE_DROP edge cases, completing the per-kind honesty sweep (offline/back_online/daily-summary already pinned): 6c first-online (peak==0 guard) must NEVER fire a drop -- a drop with no observed prior peak is a fabricated alert. 6d a real halving vs the observed peak fires exactly one drop. 6e a dark (hashrate==0) sample is an OFFLINE concern, never a -100% drop -- drop is evaluated in the online branch only. Test-only / SAFE-ADDITIVE: pins existing honest behavior, no engine logic change. Selftest 13/13. * d-miner5(kat): pin undelivered-no-throttle (a failed alert must retry, never masquerade as handled) * d-miner5(kat): pin throttle re-fire after window elapses (stale alert must never masquerade as permanent coverage) Completes the throttle-honesty triad with #8 (within-window suppress) and #8b/#563 (undelivered retries): once the throttle window has ELAPSED, a still-true condition (e.g. an ongoing outage) must re-fire. Guards the `< window` bound in recently_sent() against a >=/off-by-one regression that would swallow every later real alert and warn the miner only once though the rig is still down. selftest 15/15. --------- Co-authored-by: frstrtr <frstrtr@users.noreply.github.com>
1 parent d290f75 commit 7e798ba

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

scripts/miner_notify_engine.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,22 @@ def put(ts, worker, hr):
455455
check(rt and rt["status"] == "deliver",
456456
f"undelivered must not throttle retry, got {rt}")
457457

458+
# 8c) throttle honesty (the partner of #8/#8b): once the window has
459+
# ELAPSED, a still-true condition must re-fire. A throttle that never
460+
# releases would let a single stale alert masquerade as permanent
461+
# coverage of an ongoing outage -- the miner is warned once and never
462+
# again though the rig is still down. Guards the `< window` bound in
463+
# recently_sent() against a >=/off-by-one regression that swallows
464+
# every later real alert.
465+
con.execute("INSERT INTO notifications(ts,worker,kind,severity,route,status)"
466+
" VALUES(?,?,?,?,?,?)",
467+
(t0, "w6", OFFLINE, "warn", "x", "delivered"))
468+
con.commit()
469+
refire = route_event(con, {"worker": "w6", "kind": OFFLINE,
470+
"ts": t0 + sub["throttle_s"] + 1, "detail": "d"}, sub)
471+
check(refire and refire["status"] == "deliver",
472+
f"condition must re-fire after throttle window elapses, got {refire}")
473+
458474
# 9) no subscription -> route_event returns None (logged undelivered, not dropped)
459475
nosub = dict(sub, enabled=0, channels=[])
460476
check(route_event(con, info_ev, nosub) is None, "unsub should route to None")
@@ -465,7 +481,7 @@ def put(ts, worker, hr):
465481
for f in fails:
466482
print(" -", f)
467483
return 1
468-
print("SELFTEST OK (14/14)")
484+
print("SELFTEST OK (15/15)")
469485
return 0
470486

471487

0 commit comments

Comments
 (0)