Mosaic one model, many lenses

AI in Mosaic

Mosaic projects a full AI stack into every app from the same tessera.yaml that derives its REST routes, web pages, and CLI — a RAG assistant (and, for normal apps, the branded Mosaic Aide), a voice channel (STT → LLM → TTS), a knowledge engine (hybrid + graph-augmented RAG over text, code, and books), and MCP servers and a client that expose all of it to agents. There is no separate "AI framework" you bolt on: the capability is declared as a few YAML keys (vector_dbs, voice, app.mcp, model_registry, workflow nodes) and the rest is generated Rust.

An agent talking to a Mosaic app is not a special integration you write — the app's own commands (every exposed CQRS command, ADR 0027) are already MCP tools, and the app's own knowledge is already a queryable, graph-augmented engine. The same model a human drives from the CLI or web app is the model an LLM drives over MCP.

This page is the map: which capability lives where, when to reach for which one, and how it compares to EE's building-block approach.


Why Mosaic's AI is a projection, not an integration

Most frameworks treat AI as an external integration: you call an LLM from a handler you write, hand-wire a tool list, and maintain a second surface alongside your "real" API. Mosaic inverts this in two specific ways:

  • Surfaces derive from the DSL, not from code you write. Declaring vector_dbs projects the RAG engine, the assistant, the Aide, the knowledge REST API, and the 23 knowledge MCP tools into the generated app. Declaring voice projects the whole voice channel; app.mcp projects a client. Nothing is hand-wired per app (ADR 0008, ADR 0029).
  • The engine is vendored, pure Rust, and environment-pure. mosaic-knowledge has no network deps and reads no env inside the crate; it is include_str!-vendored into every generated app that declares a vector_db. LLM/embedding/rerank calls happen only at the app's env seams, never in the engine.
  • The tool catalog is the app itself. The app's MCP server (stdio) exposes one tool per exposed CQRS command, domain service, and workflow — so an agent can operate the app end-to-end with exactly the operations a human performs (ADR 0027, ADR 0029).
  • Provider seams are env, not code. MOAIC_CHAT_*, MOAIC_EMBED_*, MOAIC_RERANK_*, MOAIC_VOICE_* are all OpenAI-compatible by default; a missing key degrades a surface gracefully (a grounded no-LLM answer, or a named 503) rather than failing the build.

Mosaic vs. EE in one line. EE ships building blocks (ee-llm, ee-agent, ee-knowledge, ee-mcp, ee-voice, …) that an app composes. Mosaic is a codegen platform: the same capability is not a block you import — it is generated Rust, projected from tessera.yaml. The map below gives each layer its Mosaic equivalent.


The feature map

LayerMosaicDeclared viaWhat it gives you
Model & providerModel registry + env seamsmodel_registry[], MOAIC_{CHAT,EMBED,RERANK,OPENAI,GROQ,…}_*LLM/embedding/rerank routing by named role (chat, embed, rerank) to any OpenAI-compatible endpoint; runtime model overrides persist to .runtime/models.json (ADR 0017). No vendor is hard-wired.
Knowledge & retrievalmosaic-knowledge enginevector_dbs[]A pure-Rust, vendored RAG engine: hybrid BM25+vector retrieval (reciprocal-rank fusion), graph-augmented re-ranking (Personalized PageRank), a knowledge graph, code/book/docs/git ingestion, and a typed-entity gazetteer. Deep-dive: Knowledge & Graph-RAG.
Assistant & chatRAG assistant + Mosaic Aide + web chatvector_dbs (auto-derives assistant + Aide); web-lens built-in /chatA streamed (SSE) RAG chat grounded in the app's knowledge and the viewed page, with deterministic citation rewriting and in-process multi-turn memory (ADR 0029). Assistant & Mosaic Aide.
VoiceVoice channelvoiceSTT → LLM → TTS over WebSocket with server-side VAD endpointing, a server-side search_docs grounding loop, per-sentence TTS, barge-in; or a provider-direct realtime relay (OpenAI Realtime / Gemini Live). Voice.
MCPApp server + knowledge server + clientapp.mcp (client); app + knowledge servers alwaysA stdio MCP server over the app's own commands, an HTTP MCP server exposing the 23 knowledge tools, and a client for external servers (workflow mcp/agent nodes + GET /api/mcp/{server}/tools). MCP.
Workflow AI nodesllm, agent, mcp, searchworkflow DSLComposable AI nodes in the same workflow engine: a single-shot llm, a tool-calling agent loop (the only workflow tool loop), an external-mcp call, and a search (retrieval) node you compose as search → llm.
ReimplementationReimplementation Playbookvector_dbs (git source) + knowledge MCPA deterministic, LLM-free loop where an agent re-implements a legacy system from the app's MCP knowledge tools. Reimplementation Playbook.

How an agent reaches a Mosaic app

flowchart LR
  subgraph App["Your Mosaic app (generated)"]
    CMD["Exposed CQRS commands\n+ domain services + workflows"]
    KN["mosaic-knowledge\n(hybrid + graph RAG)"]
    AS["Assistant / Aide\n(grounded RAG chat)"]
  end
  APPMCP["App MCP server\n(stdio, cargo run -- mcp)"]
  KNOWMCP["Knowledge MCP server\n(POST /mcp, rmcp)"]
  EXT["External agent\n(an IDE, another app, a workflow agent node)"]
  CMD --> APPMCP
  KN --> KNOWMCP
  AS --> KN
  EXT -->|tools/call| APPMCP
  EXT -->|23 knowledge tools| KNOWMCP
  1. Act on the app's own commands — the app MCP server (stdio, cargo run -- mcp) exposes one tool per exposed CQRS command / domain service / workflow. An external agent (or the workflow agent node) calls them over tools/call; the call is method-aware (path substitution, realm headers, API key — ADR 0029). This is the "agent operates the app" path and the substrate of the Reimplementation Playbook.
  2. Query the app's knowledge — the knowledge MCP server (POST /mcp, rmcp streamable-HTTP) exposes the 23 knowledge tools: hybrid search, citation, graph query, code-RAG symbol/call-graph lookups, book concepts, and the typed-entity gazetteer (including runtime add_entity/remove_entity).
  3. Chat, grounded in the app — the assistant / Aide is the in-app RAG surface: each turn retrieves from the app's knowledge base and the viewed page, then answers with deterministic citation rewriting. It has no tool-calling loop — that lives in the workflow agent node and the voice loop.

Where to use which retrieval

A full RAG stack is not always the right tool. Pick based on what the question actually needs:

NeedReach for
Recall facts from the conversation itselfThe assistant's in-process history (MOAIC_ASSISTANT_HISTORY_*) — no vector store needed. (In-process only: no cross-replica, no long-term memory — see honest gaps.)
Act on the app's own data/commandsThe app MCP tools (one per exposed command) — structured tool-calling, not search.
Free-text search over a document/book/code corpusvector_dbs hybrid (default) — BM25 + vector, reciprocal-rank-fused, MMR-diversified.
Baseline/debugging, or a corpus with no structurevector_dbs[].retrieval.mode: naive — vector-only (or keyword-only without an embedder).
Retrieval should follow relationships, not just similarityvector_dbs[].retrieval.graph: true — Personalized PageRank re-ranking over the knowledge graph (graph_weight blends it in).
Source code should be searchable as codeThe code-RAG tools (find_symbol, find_callers, get_call_graph, find_similar_implementation) over a code source.
Retrieval as a pipeline step, not a chat turnThe workflow search → llm node pair.
A grounded voice answerThe voice channel's server-side search_docs loop (scoped to voice.site_search.kb).
One page's assistant should answer only from that pageThe assistant's viewed-page context (a second retrieval scoped to the page) + the page system note.

Honest note vs. EE. Mosaic currently exposes two retrieval modes (hybrid, naive) and one graph signal (query-personalized PageRank + Louvain communities). It does not have EE-style Local/Global/Mix query modes or Leiden community detection — the full gap list and the "ideas to adopt" roadmap are in Knowledge & Graph-RAG.


Getting an assistant running

vector_dbs:
  - name: kb
    sources:
      - { path: ./docs, kind: docs }
    retrieval:
      mode: hybrid
      top_k: 6
      graph: true

Then set the seams (secret-backed in the deploy spec):

export MOAIC_CHAT_API_KEY=…     # assistant LLM (OpenAI-compatible)
export MOAIC_EMBED_LOCAL=1      # deterministic 256-dim embedder, no network
# export MOAIC_RERANK_BASE_URL=…   # optional cross-encoder re-rank

With one vector_db declared, the assistant (POST /api/assistant/chat), the Mosaic Aide (/aide, POST /api/aide/chat), the knowledge REST API (/api/vectordb/kb/…), the knowledge MCP server (POST /mcp), and the app's stdio MCP server are all present — nothing else to author. Add voice: for the voice channel and app.mcp.servers to consume external MCP servers.