Planned Indexes

Keep Raw Store As-Is

~/.email3.mail.gdbm: UIDL → raw_bytes. Natural POP3 incremental sync key.

Add Message-ID Index

~/.email3.msgid.gdbm: normalized_message_id → uidl. Normalized = lowercased, stripped whitespace, wrapped in <…> consistently. Update on ingest: when storing maildb[uidl] = raw, parse headers, extract Message-ID, store msgid_index[msg_id] = uidl. Gives O(1) lookup by Message-ID without scanning.

Optional Reverse Index

~/.email3.uidl.gdbm: uidl → message_id. Helps debugging — quick "what is this UIDL?" introspection.

Optional Header Cache

~/.email3.headers.gdbm: uidl → {Message-ID, Date, Subject, From, To, …}. Avoids repeatedly parsing raw bytes for common headers. Strictly a performance optimization.

Proposed Code Abstractions

MessageKey — small helper: uidl (bytes|None) + message_id (str|None). Acknowledges reality: sometimes you have UIDL (POP3 world), sometimes Message-ID (email world).

RawMailStore — facade wrapping GDBM: uidl → raw_bytes.

MessageIdIndex — facade wrapping GDBM: message_id → uidl.

Higher-level code can then do: uidl = msgid_index.lookup(msgid)raw = raw_store.get(uidl) without scanning.

version1