Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

docs(ultrawiki): add Personal-Brain design specs (pipeline, retrieval, accuracy, roadmap)

Ruben Lütke404b88e80638
diff --git a/UltraWiki/01-architecture.md b/UltraWiki/01-architecture.md
new file mode 100644
index 0000000000..35317315ef
--- /dev/null
+++ b/UltraWiki/01-architecture.md
@@ -0,0 +1,106 @@
+# 01 · Architecture
+
+Five layers. Data flows **down** on the write path and **up** on the read path.
+The middle layer — the **Unified Store** — is the whole point: everything from
+every source lands in one schema and becomes queryable through one interface.
+
+```
+ WRITE PATH ↓ READ PATH ↑
+ ┌─────────────────────────────────────────────────────────────────┐
+ │ L1 CONNECTORS Slack · WhatsApp · GitHub · Drive · Cal · │
+ │ Notion · Mail · Obsidian · Screenshots │
+ ├─────────────────────────────────────────────────────────────────┤
+ │ L2 INGEST & ENRICH fetch delta → distill (LLM) → extract │
+ │ entities/relations/time → embed │
+ ├─────────────────────────────────────────────────────────────────┤
+ │ L3 UNIFIED STORE one row per unit: │
+ │ ├ vector index (HNSW) ← meaning │
+ │ ├ FTS5 index ← exact tokens │
+ │ ├ metadata indexes ← who/where/when filters │
+ │ └ entity+temporal graph ← multi-hop, bi-temporal │
+ ├─────────────────────────────────────────────────────────────────┤
+ │ L4 HYBRID RETRIEVAL plan → parallel fan-out → RRF → rerank → │
+ │ context expansion │
+ ├─────────────────────────────────────────────────────────────────┤
+ │ L5 ANSWER synthesis LLM → cited answer / voice │
+ └─────────────────────────────────────────────────────────────────┘
+```
+
+Legend for the reuse tags used across the docs: **[HAVE]** exists in Jarvis
+today · **[EXTEND]** exists but needs a small addition · **[NEW]** genuinely new.
+
+---
+
+## L3 — the Unified Store (the core data model)
+
+Two tables plus the derived indexes. Everything is keyed so ingestion is
+**idempotent** (re-processing the same source item updates in place, never
+duplicates).
+
+### Table A — `memory_unit` (one row per distilled unit)
+
+| Field | Purpose |
+|---|---|
+| `id` | internal primary key |
+| `source` | `slack` \| `whatsapp` \| `github` \| `drive` \| `calendar` \| `notion` \| `mail` \| `obsidian` \| `screenshot` |
+| `external_id` | stable id in the source (thread ts, file id, PR number) — **dedup/update key** |
+| `kind` | `message_thread` \| `doc_section` \| `pr` \| `issue` \| `event` \| `note` \| `email` \| `image` |
+| `one_line` | the searchable "what is this about" question/summary |
+| `distilled_text` | the LLM-normalized document — **this is what gets embedded**, not the raw text |
+| `raw_ref` | URI/pointer back to the original (open in Slack/Drive); raw text is *not* stored |
+| `embedding` | dense vector (dim = provider's, e.g. 1024–3072) → HNSW index |
+| `participants` | array of entity ids (people in the unit) → metadata index |
+| `place` | entity id / geo string → metadata index |
+| `valid_from`, `valid_to` | **bi-temporal**: when the fact was true in the world |
+| `ingested_at`, `expired_at` | **bi-temporal**: system time; supersede, don't delete |
+| `scope` | project/permission tag (which sources a query may see) |
+| `source_meta` | JSON blob: author, url, reactions, thread length, etc. |
+
+Local backend: **sqlite-vec** on the existing `data/jarvis.db` (the `wiki_fts`
+table already lives there). Cloud backend: **Postgres + pgvector**. Same schema,
+swappable driver.
+
+### Table B — the entity/temporal graph (GraphRAG + Graphiti style)
+
+- **`entity`**: `id`, `type` (`person` \| `place` \| `org` \| `project` \|
+ `event` \| `thing`), `name`, `aliases[]`, `canonical_ref` (e.g. a Jarvis
+ Contact id — **[HAVE]** contacts already exist), `embedding` (for fuzzy entity
+ match).
+- **`edge`**: `subject → predicate → object`, each carrying `valid_from`,
+ `valid_to`, `source_unit_id`, `confidence`. Facts are **invalidated, not
+ deleted** when superseded (Graphiti's rule) — so "who is Viktoria *now*" and
+ "who was Viktoria *in 2024*" are both answerable.
+
+Example edges written from one WhatsApp thread:
+
+```
+(Ruben) —[had_dinner_with]→ (Viktoria) valid_from=2024-06-23 src=wa#123
+(dinner#88) —[took_place_in]→ (San Francisco) valid_from=2024-06-23
+(dinner#88) —[at_venue]→ (Trestle)
+(Viktoria) —[is_a]→ (person) canonical_ref=contact:viktoria-m
+```
+
+This graph is what makes the Viktoria query precise instead of "semantically
+nearby". See [`04-accuracy-techniques.md`](04-accuracy-techniques.md).
+
+---
+
+## Why one store, not one-per-source
+
+Cerebras's key move: a Slack thread, a PR, a Drive doc, a calendar event all
+become **the same shape** — a distilled document with a vector and metadata. A
+query never has to know "which source do I search"; it searches the union and the
+metadata/scope tags sort out provenance and permissions. New sources join by
+emitting rows in this schema — no retrieval code changes.
+
+---
+
+## Where each layer maps in Jarvis (short form; full map in doc 07)
+
+| Layer | Jarvis today |
+|---|---|
+| L1 Connectors | `marketplace/` OAuth, `channels/`, `plugins/tool/` (Drive, Calendar), wiki `watcher.py` **[EXTEND]** |
+| L2 Distill | `wiki/extractor.py` + `consolidator.py` + `curator.py` **[HAVE]**; + embed step **[NEW]** |
+| L3 Store | `data/jarvis.db` + `wiki_fts` **[HAVE]**; + vector index + graph tables **[NEW]** |
+| L4 Retrieval | `wiki/search.py` (FTS) **[HAVE]**; + vector/graph/fusion/rerank **[NEW]** |
+| L5 Answer | `provider_chain.py` **[HAVE]** |
diff --git a/UltraWiki/02-ingestion-write-path.md b/UltraWiki/02-ingestion-write-path.md
new file mode 100644
index 0000000000..7ccf794ae6
--- /dev/null
+++ b/UltraWiki/02-ingestion-write-path.md
@@ -0,0 +1,140 @@
+# 02 · Ingestion — the Write Path ("always the latest data")
+
+This is where "it always pulls the newest data" is earned. The goal: the moment
+someone posts in a Slack/WhatsApp thread, that knowledge is in the brain within
+seconds — **without** re-scanning the whole history each time.
+
+```
+ SOURCE CHANGES ─► (1) TRIGGER ─► (2) FETCH DELTA ─► (3) DISTILL(LLM)
+ ─► (4) EXTRACT entities/relations/time(LLM) ─► (5) EMBED
+ ─► (6) UPSERT unit + graph edges ─► (7) CONSOLIDATE (add/update/invalidate)
+```
+
+Steps 3–7 are exactly Jarvis's existing `extractor → consolidator → curator →
+atomic_writer` pipeline, plus an embed step. So the write path is mostly reuse.
+
+---
+
+## (1) Trigger — three ways to know something changed
+
+The connector declares **how it learns about changes**. Pick per source; prefer
+push over poll.
+
+| Strategy | How | Best for | Jarvis today |
+|---|---|---|---|
+| **Push / realtime** | the source calls us: webhook or a socket the bot holds open | Slack (Socket Mode WS), GitHub/Notion (webhooks), Telegram/Discord (bot gateway), Obsidian (filesystem watcher) | `channels/` bots + wiki `watcher.py` **[HAVE]** |
+| **Cursor poll (CDC)** | we ask on an interval, but only for items **after a stored cursor** (sync token / page token / IMAP `IDLE`) | Google Drive (changes feed), Calendar (sync tokens), e-mail | Drive/Calendar tools exist **[EXTEND]** |
+| **Backfill (one-time)** | on first connect, import bounded history, rate-limited, in the background | every source, once | **[NEW]** |
+
+**"Actions" the user asked about** = this trigger layer. In practice it is a mix
+of webhooks/sockets (instant) and cursor-based polling (for sources that don't
+push). The important part is **incremental**: every source stores a
+`last_cursor` / `last_seen_ts`, and each run only touches the delta.
+
+### Idempotency & completeness (two Cerebras tricks worth copying)
+
+- **Re-fetch the whole thread on any reply.** When one new Slack/WhatsApp message
+ arrives, fetch the *entire parent thread* and store it as **one** unit keyed by
+ `external_id = thread_id`. An update replaces the row — the unit is always
+ complete, never a pile of fragments.
+- **`external_id` upsert.** Same source item → same row, always. Reprocessing is
+ safe; no duplicates.
+
+---
+
+## (2) Fetch delta
+
+The connector returns raw items for the changed `external_id`s. Raw text is
+**transient** — used for distillation, then dropped (only `raw_ref` is kept). This
+keeps the store small and side-steps storing giant transcripts.
+
+Durability: enqueue fetched items on a work queue so bursts (a busy channel)
+don't drop and don't block. Jarvis's `EventBus` + a lightweight persistent queue
+covers this; a crash mid-ingest resumes from the cursor.
+
+---
+
+## (3) Distill — the single biggest accuracy lever
+
+Do **not** embed raw messages. An LLM rewrites each unit into a normalized
+document with fixed fields:
+
+- `one_line` — the question this unit answers ("Dinner plan with Viktoria in SF")
+- `summary` — 2–4 sentences, self-contained
+- `resolution / outcome` — what was decided/what happened
+- `entities` — people, places, orgs, dates mentioned
+- `refs` — systems, files, links referenced
+
+Then, per **Anthropic Contextual Retrieval**, prepend a short **context prefix**
+("This is a WhatsApp thread between Ruben and Viktoria, June 2024, about…") to the
+text *before* embedding. Anthropic measured **−49% failed retrievals** from this
+alone, **−67%** combined with reranking. This is cheap and it is where most of the
+accuracy comes from.
+
+> Speed note: distillation is many small LLM calls. This is exactly why Cerebras
+> stresses that **fast inference enables the architecture** — with a fast model
+> you can afford to distill everything. Distillation is off the hot path (runs in
+> the background on ingest), so it never touches query latency.
+
+---
+
+## (4) Extract entities, relations, time (the graph write)
+
+The same or a second LLM pass emits graph triples with timestamps:
+
+```
+(Ruben)—[had_dinner_with]→(Viktoria) valid_from=2024-06-23 src=wa#123 conf=0.9
+(event#88)—[at_venue]→(Trestle, San Francisco) valid_from=2024-06-23
+```
+
+- **Entity resolution on write:** "Viktoria" is linked to the existing Contact
+ (alias match + embedding similarity) so all her mentions collapse to one node.
+ Jarvis already builds person-pages from contacts (`contact_mirror.py`) — extend
+ it to graph nodes.
+- **Bi-temporal (Graphiti):** store both *when the fact was true* (`valid_from/to`)
+ and *when we learned it* (`ingested_at/expired_at`). When a later message
+ contradicts an earlier fact, **invalidate** the old edge (set `valid_to`),
+ don't delete it. History stays answerable.
+- **Relative-time resolution:** "last Tuesday" is resolved to an absolute date
+ using the message's own timestamp as the reference point.
+
+---
+
+## (5) Embed
+
+`distilled_text` (+ context prefix) → dense vector via the configured embedding
+provider (local Ollama model or a cloud API — see doc 06). Only changed units are
+re-embedded, per commit/edit. Optionally also compute a **ColPali multi-vector**
+for image/screenshot/PDF units (doc 04, VisionRAG).
+
+---
+
+## (6) Upsert
+
+One transaction writes: the `memory_unit` row (updating the vector, FTS, metadata,
+bi-temporal fields) and the graph edges. `atomic_writer.py` already does
+lock+tempfile+BOM-safe writes for the vault (AP-7) — the DB upsert follows the
+same atomic discipline.
+
+---
+
+## (7) Consolidate
+
+Jarvis's `consolidator.py` already judges **ADD / UPDATE / NOOP / INVALIDATE**
+against existing knowledge. UltraWiki extends this to the graph: a new fact that
+contradicts an old one triggers **INVALIDATE** (bi-temporal supersede) rather than
+a silent overwrite. This is what keeps the brain consistent instead of
+accumulating contradictions.
+
+---
+
+## End-to-end example (one WhatsApp message triggers all of this)
+
+1. Viktoria replies in the SF-dinner thread → **Socket push**.
+2. Jarvis re-fetches the **full thread** (external_id = `wa#123`).
+3. LLM distills → `one_line: "Dinner with Viktoria at Trestle, SF, 23 Jun"`.
+4. Extract → edges `(Ruben)-[had_dinner_with]->(Viktoria) @ SF, 2024-06-23`.
+5. Embed the distilled doc (+ context prefix).
+6. Upsert row `wa#123` (replaces the earlier version) + edges.
+7. Consolidate: no conflict → **UPDATE**. Done, in seconds. The brain can now
+ answer the north-star question.
diff --git a/UltraWiki/03-retrieval-read-path.md b/UltraWiki/03-retrieval-read-path.md
new file mode 100644
index 0000000000..4d410b2d8e
--- /dev/null
+++ b/UltraWiki/03-retrieval-read-path.md
@@ -0,0 +1,136 @@
+# 03 · Retrieval — the Read Path (fast + exact)
+
+This is the live path. It must return a cited, exact answer in a budget the
+**realtime voice model** can live with (first token well under ~1 s). The trick is
+that all the expensive work (distilling, embedding, graph-building) already
+happened on the write path — the read path is mostly index lookups plus two small
+LLM calls (plan + synthesize).
+
+```
+ QUESTION
+ └─(1) PLAN (LLM) → {entities, place, time-window, semantic core, sources}
+ └─(2) RESOLVE ENTITIES → "Viktoria" → contact:viktoria-m ; "SF" → place node
+ └─(3) FAN-OUT (parallel, all metadata-prefiltered)
+ ├ vector search (meaning) ┐
+ ├ FTS5 search (exact tokens) │→ candidate sets
+ ├ graph traversal (multi-hop) │
+ └ temporal filter (time-window) ┘
+ └─(4) FUSE (RRF) → one ranked list
+ └─(5) RERANK (cross-encoder) → top few
+ └─(6) EXPAND CONTEXT → pull full thread / calendar event / photo
+ └─(7) SYNTHESIZE (LLM) → cited answer
+```
+
+---
+
+## (1) Plan — turn a vague question into structured facets
+
+A single fast LLM call converts the question into a query object. This is where
+"even if the user describes it imprecisely" is handled.
+
+For **"Wann war ich mit Viktoria beim Essen in San Francisco?"**: <!-- i18n-allow: quoted German example query — the specimen being traced through the pipeline -->
+
+```json
+{
+ "intent": "temporal_lookup", // the answer is a DATE
+ "entities": { "person": ["Viktoria"], "place": ["San Francisco"] },
+ "activity": "dinner | restaurant | essen",
+ "time_window": null, // unspecified → all-time
+ "sources": ["whatsapp", "slack", "calendar"],
+ "semantic_core": "dinner with Viktoria in San Francisco"
+}
+```
+
+Optional **HyDE** (Hypothetical Document Embeddings): for very vague queries, the
+LLM also writes a fake ideal answer and embeds *that* — it often matches the real
+distilled unit better than the raw question. Use only when the plan is thin;
+skip it when metadata filters are strong (they usually are here).
+
+---
+
+## (2) Resolve entities — the accuracy multiplier
+
+"Viktoria" is ambiguous text; the graph needs a **node id**. Resolve via the
+contact store (alias + embedding match) → `contact:viktoria-m`. "San Francisco" →
+place node. Now retrieval can **filter on ids**, not fuzzy strings — which is the
+difference between "restaurants that sound like something Viktoria-ish" and
+"units where participant = Viktoria AND place = San Francisco".
+
+Jarvis already has contacts and person-pages — this reuses them.
+
+---
+
+## (3) Fan-out — four retrievers in parallel, all pre-filtered
+
+The metadata filter (`participants ⊇ {Viktoria} AND place ≈ SF`) runs **first**
+and shrinks the search space from years-of-everything to a handful of candidates.
+Then the four retrievers run **concurrently**:
+
+| Retriever | Finds | Why it's needed here |
+|---|---|---|
+| **Vector** | meaning: "dinner ≈ essen ≈ restaurant reservation" | catches paraphrase; the user's word "Essen" ≠ the thread's word "reservation" |
+| **FTS5** | exact tokens: "Viktoria", "San Francisco", "Trestle" | nails proper nouns embeddings blur |
+| **Graph** | `Viktoria —had_dinner_with→ event —in→ SF` with its date | this is what actually produces the exact date, by traversal not similarity |
+| **Temporal** | orders/filters candidates by `valid_from` | if the user *had* said "in June" this narrows hard |
+
+The graph retriever is the star of this particular query: a two-hop traversal
+from the resolved Viktoria node to dinner-events located in SF returns the event
+with its `valid_from` date directly — no ranking needed to *find* it, only to
+confirm it.
+
+---
+
+## (4) Fuse — Reciprocal Rank Fusion
+
+Merge the four ranked lists into one with RRF: `score(d) = Σ 1/(k + rank_i(d))`,
+`k=60`. RRF needs no score calibration between retrievers (a vector cosine and a
+BM25 score aren't comparable) — it only uses ranks, which is why it's the
+production standard. Anthropic's default leans ~80% semantic / 20% keyword;
+tunable.
+
+---
+
+## (5) Rerank — precision on the shortlist
+
+Pass the top ~50–150 fused candidates through a small **cross-encoder reranker**
+that scores query-vs-document jointly (0–10) and keep the top few. Anthropic:
+reranking is what takes contextual retrieval from −49% to **−67% failed
+retrievals**. Local option: a small cross-encoder; cloud option: Cohere Rerank;
+zero-key fallback: an LLM-rerank through `provider_chain`, or skip reranking (RRF
+alone is decent). Keep it optional so a keyless install still works.
+
+---
+
+## (6) Expand context
+
+For the surviving top hits, pull the **neighbourhood**: the full WhatsApp thread,
+the linked calendar event, the venue's other mentions, an attached photo. This
+gives the synthesis LLM complete evidence instead of a snippet, so it can state
+the exact venue and cross-confirm the date across two sources.
+
+---
+
+## (7) Synthesize — cited answer
+
+The synthesis LLM (via `provider_chain`) gets the plan + expanded evidence and
+writes:
+
+> **"On 23 June 2024 you had dinner with Viktoria at Trestle in San Francisco."**
+> Sources: WhatsApp thread (23 Jun 2024) · Calendar 'Dinner w/ Viktoria'.
+
+Rules: **never answer beyond the evidence** (no hallucinated dates — if only a
+month is known, say the month), always cite, and honour the runtime output
+language resolver so voice answers come back in the conversation's language.
+
+For **voice/realtime**, the answer streams token-by-token; first token is the
+latency that matters, not the full answer (see doc 05).
+
+---
+
+## Two interfaces (like Cerebras)
+
+- **Full pipeline** — the above, for the user asking Jarvis (voice or UI).
+- **Retrieval primitives (MCP)** — expose `search_unified`, `graph_lookup`,
+ `who_knows`, `timeline` as MCP tools with **no synthesis LLM**, so external
+ agents (or Jarvis's own workers) can pull raw evidence fast. This is doc 08's
+ Phase 4 and turns the personal brain into a platform.
diff --git a/UltraWiki/04-accuracy-techniques.md b/UltraWiki/04-accuracy-techniques.md
new file mode 100644
index 0000000000..aaa5534348
--- /dev/null
+++ b/UltraWiki/04-accuracy-techniques.md
@@ -0,0 +1,119 @@
+# 04 · Accuracy Techniques — how to be *exact* on vague questions
+
+The whole point of UltraWiki over a naïve vector store. Each technique below
+attacks a specific failure mode of "just embed chunks and cosine-search". They
+stack; the design uses all of them, gated so a keyless install still degrades to
+something useful.
+
+| # | Technique | Failure mode it fixes | Cost | Priority |
+|---|---|---|---|---|
+| 1 | Contextual distillation | chunks lose context; paraphrase misses | ingest-time LLM | **must** |
+| 2 | Hybrid search (vector + FTS) | embeddings blur exact tokens | cheap | **must** |
+| 3 | Entity resolution | "Viktoria" ≠ a searchable id | contacts reuse | **must** |
+| 4 | Temporal / bi-temporal graph | "when" questions; stale facts | graph store | **must** |
+| 5 | GraphRAG multi-hop | relational questions ("who did X with Y") | graph store | **high** |
+| 6 | RRF fusion | scores across retrievers aren't comparable | trivial | **must** |
+| 7 | Reranking | top-k precision | small model | **high** |
+| 8 | HyDE / query expansion | very vague queries | 1 LLM call | medium |
+| 9 | VisionRAG (ColPali) | screenshots/photos/PDFs, no OCR | vision model | later |
+| 10 | Metadata prefiltering | searching everything is slow & noisy | trivial | **must** |
+
+---
+
+## 1 · Contextual distillation (the biggest single win)
+
+Rewrite each unit into a self-contained document and **prepend a context
+sentence** before embedding (Anthropic Contextual Retrieval). A raw line "yeah
+Trestle at 8" is useless embedded; distilled to "Dinner with Viktoria at Trestle,
+San Francisco, 23 Jun 2024, 20:00" it matches the query directly. Measured
+**−49% failed retrievals**, **−67%** with reranking. Done on the write path (doc
+02), so it's free at query time.
+
+## 2 · Hybrid search (vector + keyword)
+
+Vector finds meaning ("Essen" ≈ "dinner"); FTS5 finds exact strings ("Trestle",
+error codes, hostnames, `--flags`) that embeddings smear together. You need both.
+Jarvis has FTS5 today; vector is the new half. Merge with RRF (#6).
+
+## 3 · Entity resolution
+
+Collapse every mention/alias of a person/place/thing to one canonical node
+(reusing Jarvis contacts). Turns fuzzy text matching into exact id filtering —
+the single biggest precision lever for "questions about a specific person". Do it
+**on write** (link mentions to contacts) and **on read** (resolve query names to
+ids).
+
+## 4 · Temporal & bi-temporal (Graphiti/Zep model)
+
+Every fact and edge carries two timelines:
+
+- **valid-time** — when it was true in the world (`valid_from/valid_to`)
+- **ingestion-time** — when we learned it (`ingested_at/expired_at`)
+
+This is what makes "**when** was I with Viktoria" answerable at all, and what lets
+"who is my manager" return the *current* answer while "who was my manager in 2023"
+returns the historical one. Superseded facts are **invalidated, not deleted**.
+Without this, a memory system either forgets or contradicts itself. Graphiti is
+the open-source reference implementation (Neo4j-based) if you don't want to build
+the temporal layer from scratch.
+
+## 5 · GraphRAG (multi-hop relational retrieval)
+
+Pure similarity can't answer "who did I travel with to the offsite that Anna
+organized" — that's three hops. A knowledge graph traverses `Anna →organized→
+offsite →attended_by→ {people}`. For UltraWiki the graph is entity-centric
+(people/places/events/projects). Microsoft GraphRAG's community-summarization is
+overkill for a personal brain; the lightweight entity-graph + traversal is the
+right size. The graph is also what returns **exact facts** (a date, a venue) by
+lookup instead of by ranking.
+
+> **On "Mantis":** no established RAG framework by that name was found. The intent
+> — a graph/temporal memory that answers relational + time questions precisely —
+> is exactly techniques #4 and #5, best embodied by **Graphiti/Zep**. If a
+> specific tool was meant, flag it and it can be slotted in here.
+
+## 6 · Reciprocal Rank Fusion
+
+Combine retriever outputs by **rank**, not score: `Σ 1/(60+rank)`. No calibration
+needed between incomparable scorers. De-facto standard.
+
+## 7 · Reranking
+
+A cross-encoder re-scores the shortlist jointly (query×doc), far more precise than
+bi-encoder cosine. Retrieve wide (top ~150), rerank to a tight top-k. Optional
+(local cross-encoder / Cohere / LLM-rerank / skip) so it never becomes a hard
+dependency.
+
+## 8 · HyDE & query expansion
+
+For thin/vague queries, have the LLM (a) generate a hypothetical ideal answer and
+embed that, and/or (b) expand synonyms and the user's language ("Essen" → dinner,
+meal, restaurant). Use selectively — strong metadata filters usually make it
+unnecessary and it adds a call.
+
+## 9 · VisionRAG (ColPali / ColQwen2) — for later
+
+Screenshots, photos of receipts/whiteboards, and visually-rich PDFs lose their
+meaning through OCR. ColPali embeds the **page image** as multi-vector patch
+embeddings and scores with late-interaction MaxSim — retrieving figures, tables,
+and layout that text extraction misses, no OCR pipeline. Relevant once the brain
+ingests images (a photo from the Viktoria dinner, a screenshot of a reservation).
+Store the ColPali multi-vector alongside the unit; keep it an opt-in extra
+(needs a vision model). Byaldi is the easy wrapper.
+
+## 10 · Metadata prefiltering
+
+Before any similarity work, filter by the resolved facets (participant, place,
+time, source, scope). Shrinks the candidate set by orders of magnitude → both
+faster (doc 05) and more precise (less room for a semantically-close-but-wrong
+hit). Cheap and always on.
+
+---
+
+## How they combine for the north-star query
+
+`Viktoria` (resolve→id) + `SF` (resolve→place) → **prefilter** (#10) → **graph
+hop** finds the dinner event with its date (#4/#5) while **vector+FTS** (#1/#2)
+confirm the thread → **RRF** (#6) → **rerank** (#7) → **cited answer**. Six of the
+ten techniques fire on this one question — that's why it lands the exact date
+instead of "some restaurant, maybe".
diff --git a/UltraWiki/05-performance-realtime.md b/UltraWiki/05-performance-realtime.md
new file mode 100644
index 0000000000..463ea89dd0
--- /dev/null
+++ b/UltraWiki/05-performance-realtime.md
@@ -0,0 +1,70 @@
+# 05 · Performance — fast enough for the realtime voice model
+
+Target: a spoken question returns its **first token in ≲ 800 ms**, so UltraWiki
+feels like part of the conversation, not a lookup. The full answer streams after.
+This is achievable because the heavy work is pre-computed on the write path.
+
+## The latency budget (read path, personal-scale, local sqlite-vec)
+
+| Stage | Typical | Note |
+|---|---|---|
+| Plan (LLM) | 50–150 ms | one small/fast call; Cerebras-class inference makes this ~free |
+| Entity resolve | < 5 ms | local id lookup |
+| Metadata prefilter | < 10 ms | indexed; shrinks the space first |
+| Vector search (HNSW) | 5–20 ms | approximate-NN over a filtered subset |
+| FTS5 | < 10 ms | already fast today |
+| Graph traversal | 5–20 ms | 1–2 hops on an indexed adjacency |
+| RRF fuse | < 5 ms | pure arithmetic |
+| Rerank | 0–150 ms | optional; skip or small model for voice |
+| Context expand | < 20 ms | a few keyed DB reads |
+| **Synthesis first token** | 200–400 ms | streaming |
+| **Total to first token** | **~400–800 ms** | fan-out stages run in parallel |
+
+The retrievers run **concurrently**, so their wall-clock is the slowest one
+(~20 ms), not the sum. The two LLM calls (plan + synth) dominate — which is why
+model speed is the lever.
+
+## The seven speed principles
+
+1. **Precompute everything expensive.** Distillation, embedding, entity/graph
+ extraction all happen on ingest, in the background. Query time never embeds a
+ document or calls an LLM to summarize a source.
+2. **Prefilter before similarity.** Metadata filters (participant/place/time) cut
+ the vector search space by orders of magnitude. Searching 300 candidates is
+ both faster and more accurate than searching 3 million.
+3. **ANN index, not brute force.** HNSW (in sqlite-vec / pgvector) gives
+ sub-20 ms nearest-neighbour at personal scale and stays sub-100 ms at millions
+ of units.
+4. **Parallel fan-out.** The four retrievers are independent — fire them at once.
+5. **Small models on the hot path, big models off it.** Use a fast planner and a
+ fast/streaming synthesizer for voice. Reserve larger models for background
+ distillation where latency doesn't matter.
+6. **Stream the answer.** For voice, first-token latency is what the user feels.
+ Start speaking as soon as synthesis emits.
+7. **Cache.** Cache resolved entities, hot query plans, and recent answers. Repeat
+ and follow-up questions ("and where exactly?") reuse the retrieved evidence.
+
+## Two-tier retrieval for voice
+
+- **Fast tier (default for voice):** prefilter → vector + FTS + graph → RRF →
+ **skip rerank** → synth. ~400–600 ms first token.
+- **Deep tier (UI / hard questions):** add HyDE, wider retrieval, cross-encoder
+ rerank, more context expansion. ~1–2 s, higher precision.
+
+The planner picks the tier from the question (a crisp entity+place+time question
+→ fast tier; an open "tell me everything about my SF trips" → deep tier).
+
+## Scale notes
+
+- **Personal (one user):** sqlite-vec + HNSW handles millions of units on a
+ laptop. This is the default and it is enough essentially forever for one person.
+- **Cloud / team:** pgvector with an HNSW index, same query shape. Cerebras runs
+ 15k queries/day on a single Postgres embeddings table — the shape scales.
+
+## Speed is an architecture enabler (the Cerebras thesis)
+
+Fast inference doesn't just make the same pipeline quicker — it makes a **richer**
+pipeline affordable. Because plan/distill/rerank/synth are cheap, you can run all
+of them and still be realtime. On a slow model you'd have to drop steps and lose
+accuracy. This is the direct argument for pairing UltraWiki with the realtime
+model tier.
diff --git a/UltraWiki/06-deployment-local-cloud.md b/UltraWiki/06-deployment-local-cloud.md
new file mode 100644
index 0000000000..e78e026f83
--- /dev/null
+++ b/UltraWiki/06-deployment-local-cloud.md
@@ -0,0 +1,59 @@
+# 06 · Deployment — local *and* cloud, every layer
+
+Hard requirement (from the maintainer and from AP-22/23): the whole thing runs
+**fully local** on a normal machine and a headless Linux box, and **scales to
+cloud** when wanted — provider-agnostic, key-aware, degrading honestly. Nothing is
+load-bearing on a single vendor.
+
+## The matrix — each layer has both a local and a cloud path
+
+| Layer | Local (private · free · default) | Cloud (stronger · costs) | Degrades to |
+|---|---|---|---|
+| **Embeddings** | Ollama model (nomic-embed, bge, gte) — offline, nothing leaves the box | OpenAI, Gemini, Voyage, Cohere embeddings | **Normal Wiki** (FTS5 only), stated honestly |
+| **Vector store** | sqlite-vec on `data/jarvis.db` — no server, headless-ok | Postgres + pgvector | local is enough for one user ~forever |
+| **Entity/temporal graph** | tables in the same SQLite DB (or embedded Neo4j/Kùzu) | Neo4j / managed Graphiti | metadata-only retrieval (no multi-hop) |
+| **Reranker** | small local cross-encoder, or none | Cohere Rerank / LLM-rerank | RRF without rerank |
+| **Synthesis brain** | local LLM via Ollama | existing `provider_chain` (OpenRouter, Gemini…) | raw ranked evidence, no prose |
+| **VisionRAG** | local ColQwen2 (opt-in extra) | hosted vision model | text-only retrieval |
+
+Everything routes through **one key-aware chain** (the pattern
+`provider_chain.py` already implements): try the configured provider, else any
+other credential-ready provider, else degrade. New providers auto-join; no
+allowlist. Gate on **capability** ("can embed", "can rerank"), never a provider
+name (AP-21).
+
+## Privacy posture (matches Jarvis's "STT local, brain cloud" hybrid)
+
+"Pull everything in" means Slack/WhatsApp/mail/docs live — **distilled and
+embedded** — in the local DB. Two honest options, user's choice:
+
+- **Local embeddings (recommended default):** the distilled text is embedded on
+ the user's own machine; **nothing leaves the box**. Best privacy, slightly lower
+ retrieval quality, zero cost.
+- **Cloud embeddings (opt-in):** the *distilled* text (not raw messages) is sent
+ to an embedding API. Better quality, a per-token cost, and a deliberate privacy
+ trade the user opts into per source.
+
+Raw messages are never stored (only `raw_ref`), so even the local DB holds
+summaries + vectors, not full transcripts.
+
+## Headless / VPS
+
+Base install must boot on `python:3.11-slim` with no GPU, keyring, or audio:
+- sqlite-vec is pure SQLite — works.
+- Local embeddings need a model; on a tiny VPS, either use a small CPU embedding
+ model or configure a cloud embedding key. If neither is present, UltraWiki
+ **cleanly reports "not configured" and Normal Wiki keeps working** — never a
+ crash, never a silent brick.
+
+## Cost shape
+
+- **One-time backfill:** embedding the historical import. Bounded, rate-limited,
+ runs in the background. Local model = free (just time); cloud = a one-off token
+ bill proportional to history size.
+- **Ongoing:** only deltas are embedded — cheap. A few distillation + embedding
+ calls per new thread/doc.
+- **Query:** two small LLM calls (plan + synth) + index lookups. Negligible.
+
+The zero-cost, zero-key configuration (local everything) is a first-class,
+fully-supported path — not a degraded afterthought.
diff --git a/UltraWiki/07-reuse-map-and-gaps.md b/UltraWiki/07-reuse-map-and-gaps.md
new file mode 100644
index 0000000000..827e400664
--- /dev/null
+++ b/UltraWiki/07-reuse-map-and-gaps.md
@@ -0,0 +1,53 @@
+# 07 · Reuse Map & Gaps — what exists vs what's new
+
+The honest scope. Jarvis already ships roughly two-thirds of this system. The
+genuinely new work centers on **one keystone (embeddings + vector index)** and its
+downstream wiring. This doc names the existing modules a coding agent should build
+on, so nothing is rebuilt from scratch.
+
+## Already in Jarvis — reuse it **[HAVE]**
+
+| Capability | Where | Use for |
+|---|---|---|
+| Two-stage distill pipeline | `jarvis/memory/wiki/extractor.py`, `consolidator.py`, `curator.py` | L2 distill + consolidate — add an embed step at the end |
+| Atomic writes (lock+tempfile+BOM) | `wiki/atomic_writer.py`, `core/config_writer.py` | safe upserts (AP-7) |
+| FTS5 keyword index | `wiki/fts_index.py`, `search.py`, migration `0004_wiki_fts.sql` | the keyword half of hybrid search |
+| Key-aware provider fallback | `wiki/provider_chain.py` | plan + synth LLM calls, embedding-provider chain |
+| Live filesystem sync | `wiki/watcher.py` (+ `wiki_ws.py`) | Obsidian connector; live UI updates |
+| Contacts / person-pages | `wiki/contact_mirror.py`, `memory/people.py` | entity resolution + graph nodes |
+| Candidate journal / audit | `wiki/journal.py`, extraction-audit tables | ingest provenance |
+| OAuth + connectors | `jarvis/marketplace/` (registry, token_store, oauth_*, discord/telegram connect, Drive/Calendar/Slack/Notion cards) | L1 connectors — most of the auth is done |
+| Channel bots | `jarvis/channels/{discord,telegram}.py` | realtime push connectors |
+| External data tools | `plugins/tool/drive_rest.py`, `google_calendar_rest.py` | Drive/Calendar fetch |
+| Wiki frontend + graph | `frontend/src/components/wiki/` (`WikiGraph.tsx`, search, renderer), `wiki_routes.py` | the UI to extend into the brain view |
+| Episodic memory | `jarvis/awareness/` | complementary time-ordered signal |
+| EventBus | `core/bus.py` | ingest queue / event fan-out |
+
+## Genuinely new — build it **[NEW]**
+
+| Piece | Effort | Notes |
+|---|---|---|
+| **Embedding layer** | **keystone** | capability-gated provider (local Ollama / cloud API) through a key-aware chain; the one thing everything else depends on |
+| **Vector index** | small | sqlite-vec on the existing `jarvis.db` (+ pgvector driver for cloud) |
+| **Entity/temporal graph** | medium | `entity` + `edge` tables, bi-temporal fields, write-time extraction; or embed Graphiti |
+| **Hybrid fusion + rerank** | small–medium | RRF over FTS+vector+graph, optional cross-encoder rerank |
+| **Query planner** | small | one LLM call → structured facets (+ entity resolution on read) |
+| **RAG synthesizer** | small | evidence → cited answer via `provider_chain` (reuse) |
+| **Connector "source" interface** | medium | the plugin contract: *what / how to connect / how to sync*; wrap existing OAuth + add cursor/backfill |
+| **New connectors** | per-source | Slack (socket), WhatsApp, GitHub, mail — reuse marketplace auth |
+| **Brain UI** | medium | "Ask your brain" search + the graph over all sources + connector dashboard |
+| **VisionRAG** | later/opt-in | ColPali multi-vector for images/PDFs |
+
+## Extend (exists, needs a bit) **[EXTEND]**
+
+- `consolidator.py` → also do bi-temporal INVALIDATE on the graph.
+- `contact_mirror.py` → also emit graph nodes/edges, not just pages.
+- Drive/Calendar tools → add cursor-based incremental sync + backfill.
+- `WikiGraph.tsx` → render all-source nodes + semantic neighbourhood, not just
+ wikilinks.
+
+## One-line scope summary
+
+> Build the **embedding + vector + graph** core, wrap the **existing OAuth/distill/
+> FTS/provider-chain** machinery around it, and add the **planner + fusion +
+> synthesizer** on top. ~1/3 new, ~2/3 wiring.
diff --git a/UltraWiki/08-roadmap-and-open-questions.md b/UltraWiki/08-roadmap-and-open-questions.md
new file mode 100644
index 0000000000..8ed9e6aecf
--- /dev/null
+++ b/UltraWiki/08-roadmap-and-open-questions.md
@@ -0,0 +1,96 @@
+# 08 · Roadmap & Open Questions
+
+## Build order — each phase is usable on its own
+
+No big-bang. Every phase ships something the user can feel, and the first one
+needs **no external connector at all**.
+
+### Phase 0 — Semantics on what's already there
+- Add the **embedding layer** + **vector index** (sqlite-vec) on the existing
+ distilled wiki pages.
+- Add **hybrid search** (FTS5 + vector + RRF) to `wiki/search.py`.
+- **Win:** search in today's wiki gets noticeably better. Zero new connectors,
+ lowest risk, proves the keystone.
+- Touches: `provider_chain`, `search.py`, `fts_index.py`, a new `vector_index`,
+ an embed step in `curator.py`.
+
+### Phase 1 — First external connector + the source interface
+- Define the **`source` plugin contract** (what / how to connect / how to sync).
+- Wire **Google Drive** through it (the tool already exists) with cursor sync +
+ a bounded backfill.
+- **Win:** first real outside knowledge in the brain; the connector pattern is
+ proven end-to-end.
+
+### Phase 2 — Entity/temporal graph + realtime sources
+- Add `entity` + `edge` tables, **bi-temporal** fields, write-time entity/relation
+ extraction; hook it to contacts.
+- Add **realtime** connectors: Slack (Socket Mode), Telegram/Discord (channels
+ exist), incremental only.
+- **Win:** "who/when/where" questions work; "always up to date" becomes real.
+ This is the phase that makes the **Viktoria query** answerable.
+
+### Phase 3 — Full RAG read path + Brain UI
+- **Planner → fan-out → RRF → rerank → context expand → synthesize** with
+ citations; two-tier (fast for voice / deep for UI).
+- Frontend: **"Ask your brain"** search, the **all-source graph**, a **connector
+ dashboard** with sync status.
+- **Win:** the second brain talks back, in voice and UI, with sources.
+
+### Phase 4 — Scale & platform
+- Optional **pgvector** backend for team/cloud.
+- **MCP retrieval primitives** (`search_unified`, `graph_lookup`, `who_knows`,
+ `timeline`) with no synthesis LLM — Jarvis's memory becomes a source other
+ agents (and Jarvis's own workers) can query.
+- Optional **VisionRAG** (ColPali) for images/PDFs.
+- **Win:** scales past one machine; the brain becomes a platform.
+
+## Rough dependency graph
+
+```
+Phase 0 (embeddings+vector) ─┬─► Phase 1 (connector interface)
+ └─► Phase 2 (graph + realtime) ─► Phase 3 (RAG + UI) ─► Phase 4 (scale/MCP/vision)
+```
+
+Phase 0 unblocks everything. Phases 1 and 2 can proceed in parallel once 0 lands.
+
+---
+
+## Open questions — only the maintainer can answer
+
+1. **Audience: single-user or teams/cloud too?**
+ - Impact: whether to design the pgvector/permission path from the start or
+ defer it. *Recommendation:* **local-first, cloud as an open option** — matches
+ the privacy-hybrid posture; pgvector is a swap-in, not a rewrite.
+
+2. **Privacy: local or cloud embeddings by default?**
+ - Impact: does distilled text ever leave the machine. *Recommendation:*
+ **local embeddings default, cloud opt-in per source.** Nothing leaves the box
+ unless the user says so.
+
+3. **Where to start: Phase 0 or a flashy connector first?**
+ - Impact: fastest visible win vs fastest "wow". *Recommendation:* **Phase 0** —
+ lowest risk, improves what exists immediately, and de-risks the keystone
+ before any connector work.
+
+4. **How much history to backfill on connect?**
+ - All-time vs last N months. Affects one-time cost/time. *Recommendation:*
+ a bounded default (e.g. 12 months) with an "import everything" opt-in.
+
+5. **Graph store: hand-rolled SQLite tables or embed Graphiti/Kùzu?**
+ - Impact: build effort vs a dependency. *Recommendation:* start with **SQLite
+ tables** (no new infra, headless-safe); revisit Graphiti if temporal logic
+ gets heavy.
+
+6. **"Mantis" — did you mean a specific tool?**
+ - Not found as a known RAG framework. Currently interpreted as the
+ temporal/graph memory need (Graphiti/Zep). If a specific product was meant,
+ name it and it gets slotted into doc 04.
+
+---
+
+## Definition of done for the whole thing (the north-star test)
+
+Ask, by voice: **"When was I at dinner with Viktoria in San Francisco?"** →
+Jarvis returns the **exact date, venue, and sources** in **under ~1 second to
+first spoken word**, entirely from the user's own connected data, and does it on
+a machine with **only local models** as well as with cloud keys.
diff --git a/UltraWiki/README.md b/UltraWiki/README.md
new file mode 100644
index 0000000000..7cd072ebf3
--- /dev/null
+++ b/UltraWiki/README.md
@@ -0,0 +1,99 @@
+# UltraWiki — the Personal Brain
+
+> **Status: design & idea collection. No implementation yet.** This folder is the
+> spec that coding agents will later build from. All artifacts here are English
+> per the repo language rule; conversation about them happens in the maintainer's
+> language.
+
+UltraWiki turns Jarvis's existing wiki from a local keyword-searched Obsidian
+vault into a **semantic personal memory** that ingests everything the user
+already produces — Slack, WhatsApp, GitHub, Google Drive, Calendar, Notion,
+e-mail, the Obsidian vault itself — and answers questions about the user's own
+life **fast enough for the realtime voice model** and **accurate enough to name
+the exact date, place, and people** behind a vague question.
+
+The north-star query, used as the worked example throughout these docs:
+
+> **"When was I at dinner with Viktoria in San Francisco?"**
+>
+> → *"On 23 June 2024, at Trestle in San Francisco. Sources: WhatsApp thread
+> (23 Jun), calendar event 'Dinner w/ Viktoria'."*
+
+Answering that well is the whole design problem. It needs **entities** (who is
+Viktoria), **places** (San Francisco), **time** (a specific date is the answer),
+**activity semantics** (dinner ≈ essen ≈ restaurant), and it must read the *right*
+chat thread out of years of history in a few hundred milliseconds.
+
+---
+
+## The two modes (like Realtime vs Pipeline for the API keys)
+
+| | **Normal Wiki** (ships today) | **Ultra Wiki** (this design) |
+|---|---|---|
+| Store | Obsidian markdown + SQLite FTS5 | + vector index + entity/temporal graph |
+| Search | keyword (BM25) | hybrid: keyword + vector + graph + time |
+| Sources | Jarvis conversations | + every connected external source |
+| Answers | page links | cited RAG answers with exact facts |
+| Needs | nothing (offline, free) | 1 embedding provider (local or cloud) |
+| Fallback | — | degrades cleanly back to Normal Wiki |
+
+Ultra is an **add-on, not a replacement**. If the embedding provider is missing,
+Ultra falls back to Normal Wiki and says so. This mirrors the AP-22/AP-23 mandate:
+provider-agnostic, key-aware, degrades honestly, runs on a headless Linux box.
+
+---
+
+## The two paths (the whole system in one sentence each)
+
+- **Write path (background, always-on):** a source changes → Jarvis fetches the
+ delta → an LLM **distills** it into a clean document → **extracts entities,
+ relations, and timestamps** → **embeds** it → **upserts** one row into the
+ unified store and edges into the graph. Incremental, idempotent, never
+ re-scans everything. → [`02-ingestion-write-path.md`](02-ingestion-write-path.md)
+
+- **Read path (live, must be fast):** a question arrives → an LLM **plans** it
+ into `{entities, place, time-window, semantic core, sources}` → resolves
+ "Viktoria" to a real contact → **fans out in parallel** over vector + keyword +
+ graph + time → **fuses** (RRF) → **reranks** → **expands context** →
+ **synthesizes** a cited answer. → [`03-retrieval-read-path.md`](03-retrieval-read-path.md)
+
+---
+
+## Document index
+
+| File | What it covers |
+|---|---|
+| [`01-architecture.md`](01-architecture.md) | The 5 layers, the unified store schema, the entity/temporal graph |
+| [`02-ingestion-write-path.md`](02-ingestion-write-path.md) | Connectors, how "always latest" works (webhook / socket / poll / CDC), distill → extract → embed → upsert |
+| [`03-retrieval-read-path.md`](03-retrieval-read-path.md) | Query understanding → fan-out → fuse → rerank → synthesize, with the Viktoria query traced end-to-end |
+| [`04-accuracy-techniques.md`](04-accuracy-techniques.md) | Every trick for "extremely accurate on vague questions": contextual retrieval, GraphRAG, bi-temporal, entity resolution, HyDE, reranking, VisionRAG |
+| [`05-performance-realtime.md`](05-performance-realtime.md) | The latency budget, ANN/HNSW, prefilter-first, precompute, streaming — how it stays realtime-fast |
+| [`06-deployment-local-cloud.md`](06-deployment-local-cloud.md) | Local vs cloud for every layer, privacy, graceful degradation |
+| [`07-reuse-map-and-gaps.md`](07-reuse-map-and-gaps.md) | What Jarvis already has vs what is genuinely new (the ~1/3 to build) |
+| [`08-roadmap-and-open-questions.md`](08-roadmap-and-open-questions.md) | Phased build order + the decisions only the maintainer can make |
+
+---
+
+## How to use this with coding agents later
+
+Each doc is written so a coding agent can take one phase from
+[`08-roadmap-and-open-questions.md`](08-roadmap-and-open-questions.md), read the
+relevant design doc, and implement it against the existing Jarvis modules named
+in [`07-reuse-map-and-gaps.md`](07-reuse-map-and-gaps.md). The design deliberately
+reuses Jarvis's `curator`/`extractor`/`consolidator` distill pipeline, the
+`provider_chain` key-aware fallback, the FTS5 index, the wiki watcher, the
+`marketplace/` OAuth machinery, and the `contacts` store — so most of the work is
+wiring, not greenfield.
+
+## Prior art these docs lean on
+
+- **Cerebras Knowledge** — the "meet the data where it lives / one embeddings
+ table / distill before embed / hybrid search / speed enables architecture"
+ doctrine.
+- **Anthropic Contextual Retrieval** — prepend context to each chunk before
+ embedding; hybrid + RRF + rerank (−67% failed retrievals).
+- **Graphiti / Zep** — bi-temporal knowledge graph for agent memory (valid-time
+ vs ingestion-time, invalidate-don't-delete). This is the backbone of temporal
+ accuracy.
+- **ColPali / ColQwen2** — vision-based document retrieval (late interaction) for
+ screenshots, photos, and visually-rich PDFs, no OCR.