feat: pre-cutover cleanup — smoke-test refresh, remediation→TelegramNotifier, coverage config (rc3)#23
Merged
Merged
Conversation
Three coordinated cleanups before crossing into the morning-signal consumer cutover: 1. examples/smoke_test.py rewritten to lead with FlowDoctor.builder() + TelegramNotifierConfig instead of the now-@deprecated flow_doctor.init() yaml flow. Adds smoke checks for flow_doctor.context() propagation, report_async() from an asyncio context, and flow_doctor.otel.report_to_otel_span_event. All offline (FLOW_DOCTOR_SKIP_PREFLIGHT=1 + fake creds + sqlite at temp path). 2. RemediationExecutor's orphan _notify_telegram path migrated to consume a first-class TelegramNotifier instance. Adds TelegramNotifier.send_raw(text) for adjacent subsystems firing ad-hoc messages without conforming to the Report shape; the sentinel pattern on parse_mode / disable_notification lets callers distinguish "use instance default" from "explicit override". RemediationConfig gains telegram_bot_token + telegram_chat_id + telegram_message_thread_id; _init_remediation builds a real TelegramNotifier from those (with FLOW_DOCTOR_TELEGRAM_* env-var fallback chain) and hands it to RemediationExecutor. The legacy telegram_webhook_url path stays — soft-deprecated for 0.4.x yaml back-compat, removed in 0.6.0. When both are configured, the notifier wins. Remediation pings going through the new path pick up Markdown rendering, threading, target-id audit (actions.target row), and the same validate() preflight as the rest of the notifier surface. 3. [tool.coverage.run] section added to pyproject.toml. pytest-cov was misreporting coverage on Pydantic-derived modules under editable installs because it instruments AFTER the import has already happened; the direct ``python -m coverage run -m pytest && python -m coverage report`` path measures correctly. Real project-wide coverage is 84%, not the 67% pytest-cov reported. 17 new tests cover: send_raw POST shape + chat/thread/parse_mode override (sentinel-based), never-raise behavior on network failure and API ok=false, 4096-char truncation, HTTP non-200 returning None, RemediationExecutor invoking send_raw with the formatted message, emoji + dry-run tag + error-truncation in the formatted body, RemediationExecutor preferring the notifier when both paths are configured, legacy webhook URL still working unchanged for 0.4.x back-compat, and _init_remediation building the notifier from RemediationConfig fields + env-var fallbacks. Version bump 0.5.0rc2 → 0.5.0rc3. Suite: 393/393 pass (376 prior + 17 new). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Three coordinated cleanups before the morning-signal consumer cutover. Bumps to 0.5.0rc3.
1.
examples/smoke_test.pyrewritten for the rc-era surfaceLeads with
FlowDoctor.builder()+TelegramNotifierConfiginstead of the now-@deprecatedflow_doctor.init()yaml flow. Adds smoke checks forflow_doctor.context()propagation,report_async()from anasynciocontext, andflow_doctor.otel.report_to_otel_span_event. All offline (FLOW_DOCTOR_SKIP_PREFLIGHT=1+ fake creds + sqlite at temp path).2. RemediationExecutor's orphan Telegram path migrated to
TelegramNotifierPreviously
RemediationExecutorhad a bespoke_notify_telegramPOST to an arbitrary webhook URL — a misnomer (Telegram doesn't have user-installable webhooks the way Slack does) and a duplicate code path that didn't compose with the rest of the notifier surface.Added:
TelegramNotifier.send_raw(text, *, parse_mode=, disable_notification=)for adjacent subsystems firing ad-hoc messages without conforming to theReportshape. Sentinel-basedparse_mode/disable_notificationlets callers distinguish "use instance default" from "explicit override".Added to
RemediationConfig:telegram_bot_token+telegram_chat_id+telegram_message_thread_id._init_remediationincore/client.pybuilds a realTelegramNotifierfrom these (with theFLOW_DOCTOR_TELEGRAM_*env-var fallback chain) and hands it toRemediationExecutorvia a newtelegram_notifier=kwarg.Deprecated:
RemediationConfig.telegram_webhook_url— kept for 0.4.x yaml back-compat through the 0.5.x series, removed in 0.6.0. When both paths are configured, the notifier wins.Remediation pings going through the new path pick up Markdown rendering, threading, target-id audit (
actions.targetrow populated with the non-secrettelegram:<chat_id>[:<thread>]identifier), and the samevalidate()preflight as the rest of the notifier surface.3. Canonical coverage entry in
pyproject.tomlpytest-covwas misreporting coverage on Pydantic-derived modules under editable installs because it instruments after the import has already happened —flow_doctor/notify/configs.pyregistered as 17% when it's actually 98%. The directpython -m coverage run -m pytest && python -m coverage reportpath measures correctly. Real project-wide coverage is 84%, not the 67%pytest-covreported (still over the v0.5.0 plan's 80% target).Also:
.coverageartifact +htmlcov/added to.gitignore.Test plan
pytest tests/→ 393/393 pass (376 prior + 17 new for the remediation-Telegram migration).python examples/smoke_test.py→ all 10 smoke checks pass offline.python -m coverage run -m pytest && python -m coverage report→ 84% suite-wide,telegram.py83%,executor.py68% (was 56% — the migration tests lifted it).0.5.0rc3after merge.🤖 Generated with Claude Code