← Context/ issues
Backfilled Mail Has No Conversation IDs
Only 221 of about 42,700 indexed messages carry a conversation ID: the ones the Worker synced itself. The backfill indexed everything else before reading the metadata that holds the ID, and never goes back.
Related: Backfill-Runs-Ended-Before-Writing-Status, Plan-C3-Backfill-Index-From-R2.
What we saw
Claude, in its first session with the connector (2026-11-27), said messages on
the work accounts had no conversation ID, and read_message came back with an
empty thread, so a back-and-forth can't be followed. It saw IDs only on
Gmail.
The index says the problem is wider than that. Primary messages in D1:
| Account | Messages | With thread_id | Synced live by the Worker | Live with thread_id |
| Gmail | 41,249 | 220 | 221 | 221 |
| humain.vc | 714 | 1 | 1 | 1 |
| mandatory.ventures | 714 | 0 | 0 | 0 |
So it isn't about Workspace against Gmail. Mail the Worker synced itself always has a conversation ID; mail the backfill indexed from R2 almost never does.
Why
The live path asks for
X-GM-THRIDwhenever the server advertisesX-GM-EXT-1(sync-worker/src/imap.ts,isGmail), which Workspace accounts do, and stores it on the row.The backfill (
sync-worker/src/backfill.ts) takesthread_idfrom the account'sr2_metarow for that message.r2_metais filled by reading themeta/files a page at a time (metaBudget), so a large account's metadata arrives over many runs.Indexing doesn't wait for it. A message indexed before its meta row exists gets
threadId: null. Later runs find the message already indexed (outcome.status === "exists") and skip it, so the ID that arrives later is never written.
r2_meta agrees: the 1,218 Gmail rows read so far all have a thread_id. The
data exists; it just landed after the messages were indexed.
Fix
Backfill the column once. Write
thread_idonto existing rows fromr2_metawhere the row has none (matched by account and sha256). One UPDATE per account, run after the meta read finishes.Stop it recurring. Either hold indexing for an account until its meta read is done, or have the meta read update
messages.thread_idfor rows that already exist. The second is simpler and survives any ordering.Check the meta files exist for the work accounts. humain.vc has 1 meta row and mandatory.ventures has none. If the laptop never wrote meta files for them, step 1 can't help, and those accounts need either a one-off
X-GM-THRIDfetch by UID or the fallback below.Fallback threading for mail without an ID. Group by
ReferencesandIn-Reply-To(both already in the stored message), with normalized-subject matching as a last resort. This also covers any future non-Google account.
How we'll know
The D1 table above shows
thread_idon nearly every row for every account.read_messageon a work-account reply lists the rest of its conversation.
Resolved (2026-11-27)
The laptop index turned out to hold every message's conversation id (100% on all four accounts), so step 3's worry didn't apply and step 4's fallback isn't needed yet.
mail/push_meta_to_d1.pywrites the laptop's per-message metadata (mailbox, UID, flags, labels, thread id) into D1'sr2_metaand fillsthread_idon rows already indexed. Run for humain.vc, mandatory.ventures, and Gmail: 230,938r2_metarows.fillThreadIdsinsync-worker/src/backfill.tsdoes the same fill when an account's meta read finishes, so the ordering can't strand ids again. Test:backfill.test.ts, "rows indexed before their meta arrived…".After: humain.vc 714 of 714, mandatory.ventures 714 of 714, Gmail 44,092 of 44,100 indexed rows have a
thread_id. Gmail's remaining backfill picks the ids up fromr2_metaas it indexes.Threading by
References/In-Reply-Tostays a fallback for any future non-Google account.