07.4.3.18.2 — Runtime Notification Migration

This commit is contained in:
2026-05-09 21:46:58 +03:00
parent 7e5ecc2ed9
commit c3cf446143
9 changed files with 665 additions and 370 deletions

View File

@@ -0,0 +1,210 @@
# 07.4.3.18.2 — Runtime Notification Migration
## Stage Goal
Перевести runtime Telegram-уведомления
со старого inline-alert подхода
на отдельную Runtime Notification Architecture.
---
# Что было реализовано
## 1. Runtime Notification Pipeline
В проект введён полноценный runtime notification layer:
~~~text
RuntimeEvent
RuntimeEventPublisher
NotificationService
TelegramNotificationChannel
~~~
---
## 2. Strong Signal Alerts Migration
Сильные сигналы автоторговли были вынесены
из прямого Telegram send flow
в RuntimeEvent pipeline.
Ранее:
~~~text
AutoTradeRunner
-> bot.send_message()
~~~
Теперь:
~~~text
AutoTradeRunner
-> RuntimeEventPublisher.publish()
-> NotificationService
-> TelegramNotificationChannel
~~~
---
## 3. Execution Alerts Migration
Paper execution alerts также переведены
в RuntimeEvent pipeline:
- POSITION_OPENED
- POSITION_CLOSED
- POSITION_FLIPPED
---
## 4. Notification Dedupe Layer
Добавлен NotificationDedupe:
~~~python
NotificationDedupe.should_send(...)
~~~
Поддерживает:
- anti-spam
- cooldown suppression
- duplicate protection
---
## 5. Notification Templates
Добавлены отдельные шаблоны:
~~~text
notifications/templates/signal.py
notifications/templates/execution.py
~~~
Теперь presentation layer отделён от business logic.
---
## 6. Telegram Channel Abstraction
Добавлен:
~~~text
TelegramNotificationChannel
~~~
Теперь NotificationService не зависит напрямую от aiogram Bot API.
---
## 7. Notification Target Registry
Добавлен:
~~~text
NotificationTargetRegistry
~~~
Registry хранит:
- active bot
- target chat_id
Позволяет:
- отправлять уведомления без открытого auto screen
- поддерживать detached runtime notifications
---
## 8. Circular Import Protection
Устранён circular import:
~~~text
runtime_events
↔ notifications
~~~
Через lazy import внутри RuntimeEventPublisher.
---
# Runtime Validation
Система была протестирована
на реальном paper execution.
Подтверждено:
- runtime events публикуются
- Telegram delivery работает
- execution alerts приходят
- journal logging работает
- dedupe layer работает
- detached delivery работает
---
# Ограничения текущего этапа
Signal escalation layer ещё не реализован.
Сейчас RuntimeEvent публикуется только при:
~~~text
decision_status transition
~~~
Из-за этого:
- repeated READY signals
- stronger confirmations
- confidence escalation
пока не создают новые RuntimeEvent.
Это переносится в:
~~~text
07.4.3.19 — Strategy Audit & Signal Quality Layer
~~~
---
# Modified Components
## Runtime Events
~~~text
runtime_events/event_types.py
runtime_events/models.py
runtime_events/publisher.py
~~~
## Notifications
~~~text
notifications/service.py
notifications/models.py
notifications/dedupe.py
notifications/targets.py
notifications/channels/telegram.py
notifications/templates/signal.py
notifications/templates/execution.py
~~~
## Auto Trading
~~~text
trading/auto/runner.py
~~~
---
# Result
Система перешла
от inline Telegram alerts
к полноценной event-driven runtime notification architecture.