Skip to content

refactor(notifier): split 1054-line notifier into per-channel modules#2

Merged
royavrahami merged 1 commit into
mainfrom
refactor/decompose-notifier
Jun 1, 2026
Merged

refactor(notifier): split 1054-line notifier into per-channel modules#2
royavrahami merged 1 commit into
mainfrom
refactor/decompose-notifier

Conversation

@royavrahami

Copy link
Copy Markdown
Owner

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

Module Responsibility Lines
notifier.py thin Notifier dispatcher (send / send_digest) ~100 (was 1054)
email_renderer.py EmailRenderer — subjects/bodies + SMTP send 824
slack_notifier.py SlackNotifier — Block Kit + Bot API 90
console_notifier.py ConsoleNotifier — rich terminal output 86
_common.py shared _CATEGORY_META + _score_color 23

Notifier had no instance state, so each method became a @staticmethod on 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:

  • the email subject
  • the full professional email (38 KB HTML)
  • the Slack blocks (timestamp normalised)

All byte-identical before vs after.

Tests

  • New tests/test_notifications/ suite: subject/body/slack builders, console + dispatcher smoke tests, and a mocked send_email test.
  • 58 pass (up from 52); ruff clean on src/ main.py.

Note (dead code)

_make_email_safe and _build_fallback_html had no production caller. They're retained on EmailRenderer for now; a follow-up can remove or wire them in.

🤖 Generated with Claude Code

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>
@royavrahami royavrahami merged commit ccd05a1 into main Jun 1, 2026
1 check passed
@royavrahami royavrahami deleted the refactor/decompose-notifier branch June 1, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant