[gmail-safety-and-standards-hardening] #06: Encapsulate Label Queries on Domain Model #25

Closed
opened 2026-08-28 17:32:19 +03:00 by jalmari · 1 comment
Owner

Feature: gmail-safety-and-standards-hardening | Source: .scratch/gmail-safety-and-standards-hardening/issues/06-encapsulate-label-queries-on-emailheader.md

06: Encapsulate Label Queries on Domain Model

What to build: Add domain query properties and methods to EmailHeader (normalized_labels, has_label(), is_promotional, is_social), eliminating Primitive Obsession and Feature Envy in ClassificationEngine.classify(). Remove unrequested top-level export of DEFAULT_GMAIL_CATEGORY_PREFIXES.

Blocked by: None (can start immediately)

Status: ready-for-agent

  • Add normalized_labels property to EmailHeader.
  • Add has_label(label: str) -> bool, is_promotional -> bool, and is_social -> bool to EmailHeader.
  • Refactor ClassificationEngine.classify() in src/mailsweep/classifier.py to use domain methods instead of ad-hoc set comprehensions.
  • Remove DEFAULT_GMAIL_CATEGORY_PREFIXES from __all__ in src/mailsweep/__init__.py.
  • Add unit tests in test_mailsweep.py verifying label query methods and backwards-compatibility.
**Feature**: `gmail-safety-and-standards-hardening` | **Source**: `.scratch/gmail-safety-and-standards-hardening/issues/06-encapsulate-label-queries-on-emailheader.md` # 06: Encapsulate Label Queries on Domain Model **What to build:** Add domain query properties and methods to `EmailHeader` (`normalized_labels`, `has_label()`, `is_promotional`, `is_social`), eliminating Primitive Obsession and Feature Envy in `ClassificationEngine.classify()`. Remove unrequested top-level export of `DEFAULT_GMAIL_CATEGORY_PREFIXES`. **Blocked by:** None (can start immediately) **Status:** ready-for-agent - [ ] Add `normalized_labels` property to `EmailHeader`. - [ ] Add `has_label(label: str) -> bool`, `is_promotional -> bool`, and `is_social -> bool` to `EmailHeader`. - [ ] Refactor `ClassificationEngine.classify()` in `src/mailsweep/classifier.py` to use domain methods instead of ad-hoc set comprehensions. - [ ] Remove `DEFAULT_GMAIL_CATEGORY_PREFIXES` from `__all__` in `src/mailsweep/__init__.py`. - [ ] Add unit tests in `test_mailsweep.py` verifying label query methods and backwards-compatibility.
Author
Owner

Implemented label query encapsulation on EmailHeader (normalized_labels, has_label(), is_promotional, is_social), refactored ClassificationEngine.classify() to eliminate primitive obsession, removed DEFAULT_GMAIL_CATEGORY_PREFIXES top-level export, and added unit tests in commit 3a13959.

Implemented label query encapsulation on `EmailHeader` (`normalized_labels`, `has_label()`, `is_promotional`, `is_social`), refactored `ClassificationEngine.classify()` to eliminate primitive obsession, removed `DEFAULT_GMAIL_CATEGORY_PREFIXES` top-level export, and added unit tests in commit `3a13959`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Lavisys/mailsweep#25
No description provided.