Add Gmail X-GM-LABELS support + increase sync to 4x/day #1

Closed
opened 2026-09-22 16:08:36 +00:00 by ben · 0 comments
Owner

Summary

Two enhancements to support compendium's migration to using ben-email as its email source:

1. Gmail Label Population

All 22,599 emails currently have empty labels arrays. The IMAP fetch (BODY.PEEK[] FLAGS) doesn't request Gmail's proprietary X-GM-LABELS extension. The labels column exists in the schema but is never populated.

Changes needed:

  • email_sync/imap_client.py: Add X-GM-LABELS to the IMAP FETCH command for Gmail accounts
  • email_sync/sync.py: Parse the Gmail extension response and populate the labels column
  • One-time full re-sync (email-sync sync --full) to backfill labels for existing emails

Labels are used by compendium's email quality gate:

  • compendium/* labels → auto-pass (pre-sorted as relevant)
  • Promotions, Social, Spam → auto-reject

2. Increase Sync Frequency to 4x/Day

Update ben-email-sync.timer from daily (~02:35) to 4x/day:

[Timer]
OnCalendar=*-*-* 02,08,14,20:35:00

Reduces data freshness lag from ~24h to ~6h, which matters for confirmation detection and newsletter link scraping timeliness in compendium.

  • compendium #151: Refactor email sync to use ben-email standalone SQLite DB
## Summary Two enhancements to support compendium's migration to using ben-email as its email source: ### 1. Gmail Label Population All 22,599 emails currently have **empty `labels` arrays**. The IMAP fetch (`BODY.PEEK[] FLAGS`) doesn't request Gmail's proprietary `X-GM-LABELS` extension. The `labels` column exists in the schema but is never populated. **Changes needed:** - `email_sync/imap_client.py`: Add `X-GM-LABELS` to the IMAP FETCH command for Gmail accounts - `email_sync/sync.py`: Parse the Gmail extension response and populate the `labels` column - One-time full re-sync (`email-sync sync --full`) to backfill labels for existing emails Labels are used by compendium's email quality gate: - `compendium/*` labels → auto-pass (pre-sorted as relevant) - `Promotions`, `Social`, `Spam` → auto-reject ### 2. Increase Sync Frequency to 4x/Day Update `ben-email-sync.timer` from daily (~02:35) to 4x/day: ```ini [Timer] OnCalendar=*-*-* 02,08,14,20:35:00 ``` Reduces data freshness lag from ~24h to ~6h, which matters for confirmation detection and newsletter link scraping timeliness in compendium. ## Related - compendium #151: Refactor email sync to use ben-email standalone SQLite DB
ben closed this issue 2026-09-22 17:01:09 +00:00
Sign in to join this conversation.
No labels
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.

Dependencies

No dependencies set.

Reference
ben/ben-email#1
No description provided.