refactor(notifier): split 1054-line notifier into per-channel modules#2
Merged
Conversation
Mirror of the QA agent refactor. Decompose the monolithic Notifier into focused modules behind a thin dispatcher, with no behaviour change. notifier.py drops from 1054 to ~100 lines: - _common.py : shared _CATEGORY_META + _score_color - email_renderer.py : EmailRenderer (subjects/bodies + SMTP send) - slack_notifier.py : SlackNotifier (Block Kit + Bot API) - console_notifier.py : ConsoleNotifier (rich terminal output) - notifier.py : thin Notifier dispatcher (send / send_digest) Notifier had no instance state, so each method became a staticmethod on its channel class. Public API (Notifier().send / .send_digest) is unchanged, so callers (core_agent, daily_digest_agent) need no changes. Verified behaviour-preserving via a render-diff harness: the email subject, the full professional email (38 KB), and the Slack blocks are byte-identical before and after the refactor. Tests: add a tests/test_notifications suite (subject/body/slack builders, console + dispatcher smoke, mocked send_email) — 58 pass, up from 52. Note: _make_email_safe and _build_fallback_html had no production caller (dead); retained on EmailRenderer for now. Co-Authored-By: Claude Opus 4.8 (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
Mirror of the QA agent's notifier refactor. Decomposes
notifier.py(1054 lines) into focused per-channel modules behind a thin dispatcher. No behaviour change — verified byte-identical output.Structure
notifier.pyNotifierdispatcher (send/send_digest)email_renderer.pyEmailRenderer— subjects/bodies + SMTP sendslack_notifier.pySlackNotifier— Block Kit + Bot APIconsole_notifier.pyConsoleNotifier— rich terminal output_common.py_CATEGORY_META+_score_colorNotifierhad no instance state, so each method became a@staticmethodon its channel class. Public API (Notifier().send/.send_digest) is unchanged — callers (core_agent,daily_digest_agent) need no changes.Verified behaviour-preserving ✅
A render-diff harness rendered, before and after, with a fixed fixture:
All byte-identical before vs after.
Tests
tests/test_notifications/suite: subject/body/slack builders, console + dispatcher smoke tests, and a mockedsend_emailtest.ruffclean onsrc/ main.py.Note (dead code)
_make_email_safeand_build_fallback_htmlhad no production caller. They're retained onEmailRendererfor now; a follow-up can remove or wire them in.🤖 Generated with Claude Code