# learning.json Format The learning file at `~/.hermes/email-organizer/learning.json` accumulates email classification rules across cron runs. ## Structure ```json { "corrections": [], "patterns": { "rechnung": { "": { "sender": "exact@sender.com", "sender_pattern": "@appleid.com", "subject_keywords": ["keyword1", "keyword2"], "content_keywords": ["rechnung", "rechnungsnummer"], "folder": "Rechnungen_YYYY_MM", "source": "Vendor name", "notes": "Description and context" } }, "bestellbestaetigung": { "": { ... } }, "ignorieren": { "": { ... } } }, "structured_ignore_patterns": [], "last_scan": "2026-06-10 09:13", "total_processed": 554, "total_moved": 20 } ``` ## Pattern Fields | Field | Required | Description | |-------|----------|-------------| | `sender` | Conditional | Exact email address (use with `sender_pattern` only) | | `sender_pattern` | Conditional | Email domain pattern with `@` prefix (e.g., `@appleid.com`) | | `subject_keywords` | Yes | Keywords matched case-insensitively in subject | | `content_keywords` | Conditional | Keywords matched in email body | | `folder` | Conditional | Override target folder (defaults based on category) | | `source` | Yes | Human-readable vendor/source name | | `notes` | Yes | Context: what type of email, whether it's an invoice or order, any caveats | ## Decision Criteria ### Invoice (Rechnung) Contains a **factored charge**: Rechnungsnummer, Gesamtbetrag, Steuern, Fälligkeitsdatum, Lastschrift. ### Order Confirmation (Bestellbestätigung) Contains an **order number and items** but NO invoice details. Invoice arrives separately. ### Ignore - Delivery notifications ("zugestellt", "versendet") - Newsletters, marketing emails - Social media notifications - Job alerts - Technical reports (solar, DMARC) ## Update Workflow When a new pattern emerges during a scan: 1. Add entry under the correct category in `patterns` 2. Include `source` with vendor name 3. Include `notes` with distinguishing characteristics 4. Increment `total_processed` and `total_moved` 5. Update `last_scan` timestamp