001Notes
Inside ThunderbirdAI: From Raw Email to a Grounded AI Answer
On this page21
An implementation-level walkthrough of how ThunderbirdAI queues mail, builds canonical local records, indexes evidence, enforces scope, and uses an optional endpoint without treating the model as the mailbox.
Article details
- Status
- Building Publicly
- Subcategory
- Thunderbird AI
- Last reviewed
- 6 Sept 2026
- Prerequisites
- No Thunderbird internals or retrieval knowledge required
21 sections
inbox → language model → answer
The model is neither the mailbox nor the source of truth. Thunderbird owns the mail, policy, scope, retrieval, evidence, persistence, and citations. A model is an optional, bounded worker inside that larger pipeline.
1. Start with one question and one source message
Subject: Debit Card transaction of INR 805 at Book Nook
From: Aster Bank Alerts <alerts@asterbank.test>
Date: 24 Aug 2026
INR 805.00 was debited from account ending 1842 at Book Nook.
Reference: TXN-HC-100005
Find transaction TXN-HC-100005. Give me its amount and source message.
2. The system at a glance
flowchart LR
M[Thunderbird mail store] --> Q[Bounded analysis queue]
Q --> P[Canonical body + parser sidecar]
P --> L[Local analysis and policy]
L --> C[(Canonical AI records)]
C --> R[(Rebuildable RAG index)]
U[Question + frozen scope] --> X[Query planner]
X --> R
X --> C
R --> E[Bounded evidence cards]
C --> E
E --> D{Direct RAG?}
D -->|on| A[Local evidence rendering]
D -->|off| O[Configured Assistant endpoint]
O --> V[Citation URI mapping]
V --> A
3. Intake begins with Thunderbird, not the model
queue
→ worker batch
→ per-message analysis
→ changed-row checkpoint
→ observer and UI update
→ next batch
4. One message passes through ordered stages
flowchart TD
A[Read rendered message] --> B[Read parser and trust sidecar]
B --> C[Local category, tags, baseline text]
C --> D[Template match or mining]
D --> E[Optional locally trained category]
E --> F[Deterministic field extraction]
F --> G[Security assessment]
G --> H[PII decision and policy-safe text]
H --> I[Embedding or deterministic fallback]
I --> J[Summary with deterministic fallback]
J --> K[Persist canonical record]
K --> L[Index contextual child passages]
The parser sidecar preserves how text became text
Local classification is routing, not evidence
Extraction creates candidates with provenance
| Field | Value | Authority |
|---|---|---|
| Amount | INR 805.00 | Exact source span |
| Transaction ID | TXN-HC-100005 | Exact source span |
| Date | 24 Aug 2026 | Header or body source |
| Status | debited | Exact source span |
| Category | finance | Derived routing metadata |
5. Privacy is an execution decision, not a slogan
localRawText exact locally available analysis text
redactedText text after policy-driven replacements
externalSafeText
the bounded representation permitted for the chosen endpoint
Which exact representation left Thunderbird, for which operation, under which permission?
6. What remains local and what may use an endpoint
| Operation | Endpoint requirement |
|---|---|
| Normal deterministic message analysis | None |
| Per-message generated summary | Optional and policy-gated |
| Learned endpoint embedding | Optional and policy-gated |
| Direct RAG answer | None |
| Natural-language Assistant synthesis | Configured usable source |
| Exhaustive scope digest | Explicit workflow plus private or loopback source |
7. Two SQLite stores have different authority
| Store | Responsibility | Rebuildable? |
|---|---|---|
ai/mail-intelligence.sqlite | Canonical AI records, jobs, digest maps, provider state, traces | Not from the RAG index alone |
ai/rag-index.sqlite | FTS5 passages, vectors, contextual chunks, index-generation state | Yes, from canonical records |
Name the canonical state, name the derived state, and make rebuildability directional.
8. Passage indexing keeps the child connected to the parent
message L-88
├── chunk 0: parent context + early body passage
├── chunk 1: parent context + overlapping middle passage
└── chunk 2: parent context + final decision passage
9. Freeze scope before ranking
five selected message identities
→ zero in-scope transaction matches
→ no banking evidence card
→ not found or insufficient evidence
10. Exact constraints beat semantic plausibility
flowchart LR
Q[Question with TXN-HC-100005] --> C[Parse exact constraint]
C --> S[Search inside frozen scope]
S --> V[Verify identifier in record or passage]
V --> L[Lock matching evidence]
L --> B[Build one bounded evidence card]
11. Direct RAG and synthesized answers share evidence, not behavior
scope → local retrieval → evidence cards → deterministic rendering
scope → local retrieval → bounded evidence cards
→ policy-safe endpoint request → citation URI mapping → rendered answer
12. “All Mail” names two very different workloads
6,000 eligible AI records
→ local exact, lexical, vector, sender, and entity retrieval
→ perhaps eight final evidence records
→ one bounded synthesis request
flowchart TD
A[Freeze scope headers] --> B[Read available bodies]
B --> C[Redact and split bounded chunks]
C --> D[Map one structured node per source]
D --> E[Reduce long-message nodes]
E --> F[Reduce thread nodes]
F --> G[Reduce scope digest]
G --> H[Validate IDs and coverage]
H --> I[Persist maps, job, digest, and citations]
13. Follow the fictional transaction to its answer
| Stage | State |
|---|---|
| Intake | Thunderbird reads the Book Nook message and parser sidecar |
| Local analysis | Finance routing, deterministic summary, security and PII state |
| Extraction | INR 805.00 and TXN-HC-100005 retain source provenance |
| Persistence | Canonical record commits to mail-intelligence.sqlite |
| Indexing | Contextual passage enters FTS5 and vector storage |
| Scope | Human-Banking folder identities are frozen for the turn |
| Planning | TXN-HC-100005 becomes an exact identifier constraint |
| Retrieval | The matching message is verified and locked |
| Evidence | One bounded card contains the relevant passage and source URI |
| Answer | Direct local rendering or endpoint synthesis returns INR 805.00 |
| Citation | Open source resolves to the original parent message |
14. Debug the route, not the prose
route exact lookup, direct RAG, synthesized RAG, mailbox digest
scope selected messages, folder, account, or all mail
candidateSources exact, lexical, vector, sender, entity, template, thread
contextBudget included and excluded records, bytes, tokens, truncation
policy destination, redaction decision, endpoint attempt
citations parent messages and passage identities
storage generations, dirty records, checkpoints, rebuild state
15. What the build and evaluations establish
16. What I would reuse in another local-AI application
17. The compact mental model
mail
→ canonical local record
→ rebuildable evidence index
→ frozen scope
→ exact and semantic retrieval
→ bounded evidence
→ local rendering or optional synthesis
→ source-linked answer