Sequence Diagrams¶
This section contains Mermaid sequence diagrams documenting the major workflows and interaction patterns in Synapse.
Workflows¶
The following diagrams illustrate key operational flows:
Ingest loop¶
The ingest loop is the core workflow that processes raw documents into wiki pages. It involves:
- Watcher detects a file change (mtime-then-hash)
- Orchestrator chooses an inference provider (capability-aware routing)
- Provider analyzes the document and generates wiki pages
- Validation checks the output; on failure, refine and retry (bounded loop)
- Indexing updates Postgres metadata and Qdrant embeddings
Diagrams: ingest-loop.mmd (legacy JSON loop, rollback path) ·
ingest-routing.mmd (capability routing) ·
ingest-blocks.mmd (v1.7.0 block-based pipeline — markdown analysis +
FILE/REVIEW blocks, ADR-0076; the delegated-CLI path is the 1:1 E2E path).
Retrieval (4-phase)¶
The chat retrieval pipeline assembles a context window for the LLM:
- Tokenized vector search — find candidate pages via bge-m3 embeddings
- Graph expansion — expand the search results using the knowledge graph
- Budget constraint — select pages within the token window
- Assembly — assemble the retrieved context as citations for the LLM
Deep Research¶
The deep-research loop fetches and synthesizes information from the web:
- Query generation — form search queries from the user's question
- Web search — retrieve results via SearXNG
- Assessment — evaluate results for relevance and sufficiency
- Refinement — iterate if needed (bounded loop)
- Synthesis — combine findings into a wiki page
- Ingest — auto-ingest the synthesized page
Cascade delete¶
Deletion of a wiki page with referential integrity:
- Find dependents — identify pages that reference the deleted page
- Match & categorize — direct links, indirect (via shared concepts)
- Preserve shared — keep concepts referenced elsewhere
- Cleanup — remove wikilinks from dependents, update index.md
Lint-fix loop¶
The bounded lint-fix workflow maintains wiki health:
- Scan rules — check all pages against the schema
- Find violations — missing frontmatter, broken wikilinks, type mismatches
- Propose fixes — generate corrected pages
- Human gate — show fixes to the user for approval
- Apply — update pages with approved fixes (bounded loop, max iterations)
Chat retrieval mode + web-search block (B2 / ADR-0059)¶
The chat turn retrieval pipeline with B2 composer controls:
- Retrieval-mode preset —
retrieval_modeenum maps to frozen(k, expansion_depth, budget)table - 4-phase retrieve() — vector/lexical seeds → BFS graph expansion (depth ≤ 2) → budget gate → context assembly with
[n]wiki citations - Web-search block (opt-in) —
use_web_search=truetriggers one bounded SearXNG call; results assembled as## Web results (external)with[W1]…[Wn]namespace; appended AFTER wiki block; single-shot, no loop - Provider chat() — capability gate (
supports_vision) decides whether images are included; stream carries text deltas only (I3) - done event — dual citation fields:
citations(wiki[n]) andweb_citations([Wn]external); distinct namespaces never interleaved
Diagram files¶
All sequence diagrams are stored as Mermaid .mmd files and are rendered during the docs build. They are:
- Version controlled — committed alongside code changes
- Validated in CI — Mermaid syntax checked via
mmdc - Linked from ADRs — each major decision references its sequence diagram
- Buildable offline — no external dependencies
To regenerate diagrams locally:
npm install -g @mermaid-js/mermaid-cli
for f in docs/sequences/*.mmd; do
mmdc -i "$f" -o "${f%.mmd}.png"
done
Related resources¶
- Architecture Diagrams — C4 system and component views
- ADRs — detailed rationale for each workflow decision
- API Reference — REST endpoints and contracts