Page:
ADR 0001 deepen classification safety auditor
Pages
0001 deepen classification safety auditor
0002 deepen rules registry
0003 prune legacy script shims
0004 decouple rfc codecs from mailbox gateway
0005 collapse workflow into mailbox pipeline
0006 decouple gateway orchestration into pipeline
0007 incremental scan cache and progress feedback
0008 port mailsweep to synchronous rust
0009 retire python baseline and complete rust cutover
0010 automated multi platform forgejo release workflow
ADR 0001 deepen classification safety auditor
ADR 0002 deepen rules registry
ADR 0003 prune legacy script shims
ADR 0004 decouple rfc codecs from mailbox gateway
ADR 0005 collapse workflow into mailbox pipeline
ADR 0006 decouple gateway orchestration into pipeline
ADR 0007 incremental scan cache and progress feedback
ADR 0008 port mailsweep to synchronous rust
ADR 0009 retire python baseline and complete rust cutover
ADR 0010 automated multi platform forgejo release workflow
ADRs
CLI Reference
Domain Context
FAQ
Home
Internals
Python API
Rules Schema
Rust API
No results
1
ADR 0001 deepen classification safety auditor
MailSweep Doc Bot edited this page 2026-08-24 02:23:29 +00:00
1. Deepen Classification Safety Auditor into a Domain Module
Date: 2026-08-23
Status
Accepted
Context
MailSweep performs safety audits across scan summaries, cleanup plans, and offline backup archives to ensure no critical personal, medical, legal, financial, or direct conversation emails are targeted for deletion.
Previously, src/mailsweep/audit.py existed only as a procedural function (run_deep_audit) that loaded filesystem JSON snapshots, executed heuristics with direct standard output print() calls, and returned None. This prevented:
- Pure in-memory unit testing without disk I/O or stdout capture.
- Programmatic consumption of audit findings by automated pipelines or downstream gateways.
- Verification of
CleanupPlanandBackupArchiveobjects directly across a single deep interface.
Decision
We deepened the safety auditing capability into a domain module:
-
SafetyAuditor(aliased asClassificationSafetyAuditor):- Accepts domain entities directly (
ScanResult,BackupArchive,CleanupPlan,Sequence[EmailHeader],Sequence[ArchivedMessage], or path strings). - Injects
ClassificationEnginevia constructor (engine: ClassificationEngine | None = None) for test isolation. - Provides specialized operations:
audit_scan(),audit_backup(),audit_plan(), and unifiedaudit().
- Accepts domain entities directly (
-
SafetyAuditReport&AuditFinding:- Pure, immutable dataclass models encapsulating total analyzed counts, partition metrics (
trash_count,keep_count), categorized findings (critical_findings,receipt_findings,shipping_findings,suspicious_trash), and sender distributions. - Decoupled
render_text()formatter for CLI display andto_dict()for JSON serialization. - Derived boolean properties:
is_cleanandhas_warnings.
- Pure, immutable dataclass models encapsulating total analyzed counts, partition metrics (
-
Domain Vocabulary:
- Formally registered
Classification Safety AuditorandSafety Audit ReportinCONTEXT.md.
- Formally registered
Consequences
- Callers and tests can evaluate mailbox datasets in-memory with zero side-effects.
run_deep_auditremains fully backwards-compatible as a thin CLI wrapper delegating toSafetyAuditor.- Improved maintainability and locality for 13-language European heuristic safety checks.