Clean up stale comments, dead code, and code quality issues
- Remove dead code: unused PENDING_FILE, _extract_domain(), sender_domain field, imap_uid fallback, check_unseen_only config key - Fix stale comments: removed tag references in README and docstrings, top_domains -> top_senders, 1-based number -> scan_index number - Make _extract_email_address public (used by 3 modules) - Extract _format_address helper to deduplicate from/to parsing - Batch pending queue disk I/O in review act/accept (load once, save once) - Reuse cleared pending dict in scan instead of redundant disk load - Track envelope IDs during scan loop to catch duplicates - Fix default confidence_threshold 75 -> 85 to match config and docs - Update get_relevant_examples default n=10 -> n=5 to match caller - Add graceful error for --recent with non-numeric value
This commit is contained in:
@@ -47,8 +47,8 @@ def _build_prompt(email_data, config):
|
||||
max_body = config.get("rules", {}).get("max_body_length", 1000)
|
||||
|
||||
# Gather learning context from decision history
|
||||
examples = decision_store.get_relevant_examples(email_data, n=10)
|
||||
sender_email = decision_store._extract_email_address(email_data.get("sender", ""))
|
||||
examples = decision_store.get_relevant_examples(email_data, n=5)
|
||||
sender_email = decision_store.extract_email_address(email_data.get("sender", ""))
|
||||
sender_stats = decision_store.get_sender_stats(sender_email) if sender_email else {}
|
||||
known_labels = decision_store.get_known_labels()
|
||||
|
||||
@@ -80,7 +80,7 @@ def _build_prompt(email_data, config):
|
||||
# Section 4: Few-shot examples (top 5 most relevant past decisions)
|
||||
if examples:
|
||||
parts.append("\n--- Past decisions (learn from these) ---")
|
||||
for ex in examples[:5]:
|
||||
for ex in examples:
|
||||
parts.append(
|
||||
f"From: {ex['sender'][:60]} | To: {ex['recipient'][:40]} | "
|
||||
f"Subject: {ex['subject'][:60]} -> {ex['action']}"
|
||||
@@ -135,9 +135,9 @@ def _parse_response(output):
|
||||
|
||||
Expected format (one per line):
|
||||
Action: delete
|
||||
Tags: promotion, marketing, newsletter
|
||||
Tags: promotion, newsletter, social
|
||||
Summary: Promotional offer from retailer
|
||||
Reason: Clearly a marketing email with discount offer
|
||||
Reason: Clearly a promotional email with discount offer
|
||||
|
||||
Falls back to safe defaults (keep, empty tags) on parse failure.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user