Architecture Decision Records
This page is the project's decision register: the log of the significant technical decisions made while designing and building the system. Each decision is recorded with its context, the options that were considered, the rationale for the choice, and its consequences, following the lightweight ADR format proposed by Nygard (2011). Decisions that are later replaced are kept, not deleted: their status changes to "Superseded" and the record points to its successor, so the reasoning behind both choices stays visible. The master records are kept in the project's private repository; this site shows public summaries of them.
These records serve as a living architectural memory -- enabling future team members to understand not just what was decided, but why.
Decision Summary
Statuses follow the master records. Where a page number on this site differs from the master-register number, the master number is given in parentheses (see the numbering note below the table).
| ADR | Title | Status | Key Decision |
|---|---|---|---|
| 0001 | Configurable Text Chunking | Accepted | Tiktoken + markdown-aware chunking with 350/450/70 parameters |
| 0002 | No Mocking Policy | Accepted | Testcontainers for real integration tests |
| 0003 | Incremental Crawling Architecture | Proposed (the implementation has drifted from the record; flagged by an audit) | Incremental crawling with change detection instead of full re-crawls |
| 0004 | Analytics and Audit Improvements | Accepted | Prometheus metrics + structured audit logging |
| 0005 | Nomic-Embed-Text for Dutch RAG | Superseded by ADR-0033 | Local Ollama embeddings replacing OpenAI, 768 dimensions |
| 0006 | Fuzzy Matching Strategy | Accepted | Standard-library sequence matching for entity deduplication and search matching of Dutch medical terms |
| 0007 | Metadata Filtering and Boosting | Accepted | Intent-to-category filtering with metadata-driven re-ranking boosts |
| 0008 | User Feedback and Think Harder | Accepted | Thumbs up/down + escalated search with reranking |
| 0009 | Pipeline Progress Indicator | Accepted | WebSocket-based real-time stage reporting |
| 0010 | Python 3.13 Upgrade Path | Accepted (all three phases shipped) | Phased upgrade of the backend runtime to Python 3.13 |
| 0011 | Inline S4U Modules | Accepted | Monorepo replacing 5 external packages |
| 0012 | Mega-Menu Content Selector Fix | Accepted | Content-selector priority change so that navigation menus are not extracted as page content |
| 007 (legacy) | RAG Pipeline Enrichment | Accepted; consolidated into ADR-0017 | BM25 hybrid search, context assembly, canonical questions |
| 0013 (site record) | Reasoning Model Token Budget | Accepted; superseded in effect (the reasoning model was replaced, so the problem no longer applies) | Raise the token budget for a reasoning model after intent classification silently failed |
| 0014 (master 0013) | LLM Entity Validation & Contextual Retrieval | Accepted; consolidated into ADR-0017 | Tier 2 validates graph entities; generates page summaries for contextual retrieval |
| 0015 (master 0014) | Taxonomy-Driven Entity Normalization | Accepted | Single source of truth for all domain knowledge, 4-tier LLM routing, cost tracking |
| 0016 (master 0015) | SNOMED CT Terminology Integration | Accepted (Phase 1 implemented; Phase 2 parked after the Neo4j removal) | SNOMED CT Belgian Edition (280K Dutch concepts) replaces hand-maintained medical aliases |
| 0017 | Context Retrieval Architecture | Accepted (amended 2026-05-09) | 8-stage multi-signal hybrid RAG pipeline; embedding model and graph backend later reversed by ADR-0048 and ADR-0053 -- see the amendment block at the top of the master record |
| 0018 | AI URL Category Assessment | Accepted | Two-dimensional AI assessment (category + value) using Tier 3 model for crawled URL classification |
| 0019 | Contextual Embeddings | Accepted | Anthropic-style chunk context prepended before embedding and BM25 indexing |
| 0020 | Reciprocal Rank Fusion | Accepted | RRF (k=60) replaces weighted linear score combination for hybrid search |
| 0021 | Self-RAG | Deferred | Multi-pass generation with self-reflection -- deferred due to latency cost |
| 0022 | Dynamic Retrieval | Deferred | Mid-generation retrieval (FLARE/DRAGIN) -- deferred for short-form answers |
| 0023 | Prompt Caching | Deferred | Explicit prompt caching -- deferred, OpenAI automatic caching already active |
| 0024 | RAG Full Mode | Accepted | Always-on Jina reranking, Tier 3 model, 20 candidates for demo quality |
| 0025 | Novation UI Integration | Accepted | Document-style Q&A thread replacing chat bubbles for consistency with the hospital website |
| 0026 | RAG Pipeline Quality & Speed | Accepted | Condition-aware doctor queries, condition-to-department fallback, Tier 2 skip, cached query resolution |
| 0027 | Multilingual Prompts & LLM Best Practices | Accepted | Cross-lingual RAG: English system prompts, 8-language responses, citation dedup |
| 0028 | Golden-Page Taxonomy Gating | Accepted | Three-phase pipeline: scrape → seed → gate. Source page type determines entity creation permissions |
| 0029 | Remove Graphiti -- Direct Neo4j | Accepted; superseded in part by ADR-0053 (Neo4j removed: primary removal 2026-03-07, cleanup completed 2026-05-02) | Replace the Graphiti library with the direct Neo4j driver, remove the OpenAI embedding dependency |
| 0030 | LLM Entity Extraction | Accepted | Structured entity extraction from intent LLM replaces dictionary-gated graph routing |
| 0031 | Two-Tier Semantic Query Cache | Accepted | PostgreSQL + pgvector cache with SHA-256 hash (Tier 1) and embedding similarity (Tier 2) on reformulated queries |
| 0032 (site record) | Query Decomposition | Accepted (implemented behind a feature flag, off by default) | LLM-powered multi-hop query decomposition into parallel sub-question retrieval |
| 0033 | BGE-M3 Embedding Migration | Superseded by ADR-0048 | Migrated from nomic-embed-text (768-dim) to BGE-M3 (1024-dim); itself superseded on 2026-04-30 by OpenAI text-embedding-3-large (1536-dim, hosted) |
| 0034 | Pipeline Latency Optimization | Accepted | Jina Reranker v2 API replacing local BGE cross-encoder, 20 candidates default |
| 0035 | Think Harder - Dedicated Escalation Configuration | Accepted | Dedicated escalation model and parameters for Think Harder pipeline |
| 0036 | Adversarial Input Hardening | Accepted | Perplexity-based anomaly detection, LLM-as-judge, burst rate limiting, streaming retraction |
| 0037 | Lingua Language Detection Validation | Accepted | Lingua-based language detection for query language validation |
| 0038 | Corrective RAG / CRAG Quality Gate | Accepted (feature-flagged, off by default) | CRAG quality gate for retrieval result validation |
| 0039 | ColBERT Multi-Vector Reranking | Accepted (feature-flagged, off by default) | ColBERT as a secondary reranking signal rather than a primary retrieval mechanism |
| 0040 | Ingestion-Side Language Detection Filter | Accepted | Chunk-level language detection that skips content not in the tenant's expected language |
| 0046 | Clarifying Questions for Ambiguous Queries | Accepted | Clickable clarification cards when a condition maps to three or more departments |
| 0047 | Tech Stack Baseline | Accepted | Adopt the methodology's canonical stack baseline, with listed deviations |
| 0048 | OpenAI Embeddings Migration | Accepted (supersedes ADR-0033) | Migrate from BGE-M3 (Ollama, 1024-dim) to OpenAI text-embedding-3-large (hosted, 1536-dim) -- voice-channel latency and a serialization bottleneck forced the move |
| 0049 | Thin Voice Architecture | Superseded by ADR-0051 | Collapse multi-stage voice pipeline (3-4 sequential LLM calls) to a deterministic regex pre-filter → FAQ → RAG path |
| 0050 | Twilio + LiveKit SIP Integration | Accepted | Twilio Elastic SIP into self-hosted LiveKit SIP for PSTN voice termination |
| 0051 | Agentic-only Voice Orchestrator | Accepted (supersedes ADR-0049) | Make the agentic voice orchestrator (GPT-4.1 + tool use) the only voice path; delete the deterministic thin orchestrator |
| 0052 | Voice Language Locked at First Utterance | Accepted | Lock the call's language at the first transcribed turn; mid-call switching is unsupported (Deepgram single-mode silence on cross-language speech) |
| 0053 | Neo4j Removal + pgvector Consolidation | Accepted (documented retroactively) | Neo4j removed (primary removal 2026-03-07, cleanup completed 2026-05-02), the knowledge graph now lives in PostgreSQL -- completes the second half of ADR-0029 |
| 0054 | Intent Classification Cache | Accepted | Cache of intent-classification results per tenant, normalized query and language, with memory and Redis backends and an administrator kill switch; ~2 300 ms saved per cache hit |
| 0055 | FAQ-Corpus Drift Prevention | Accepted (Phase 1 executed) | Purge 10 hand-curated FAQs; trust the nightly-refreshed corpus; preserve only safety/policy entries. Phase 2 (nightly drift audit) + Phase 3 (demand-driven promotion) planned. |
| 0056 | Chat Answer-Shape Typology | Accepted | Six universal shape patterns (point fact, step-by-step, attribute list, multi-entity, comparison, decision tree) replace ad-hoc per-defect rules; chat-only injection |
| 0057 | Tenant-Scoped Prompt Addendums + Doctor-Profile Boost | Accepted | A tenant-scoped registry isolates tenant-specific prompt rules; tenant-agnostic 1.50× boost for documents titled after the doctor |
| 0058 | Data-Quality Layer Parity | Accepted | Four complementary data-quality layers at the matching points of the ingest pipeline |
| 0059 | Tenant- and Language-Extension of Clusters 1 and 3 | Proposed | Three-phase migration plan (audit and plan only; no code shipped with the record) |
| 0060 | Chat Conversation Language Lock | Accepted (implemented behind a flag, off by default; pilot validation pending) | Lock a chat conversation to one language, with re-lock only on an explicit switch request |
| 0061 | Query Rewriting to the Corpus Language | Accepted (principle in force; per-tenant parameterization planned) | Rewrite every query to the corpus language once, instead of enumerating per-language spellings |
| 0062 | Corpus-Grounded Medical Content | Superseded by ADR-0065 | On 2026-05-14, allowed dosing information when it came from the hospital's validated brochures; reversed on 2026-06-01 after the dose incident |
| 0063 | Trust-LLM Pipeline Simplification | Accepted (implementation complete; pilot validation pending) | Replace the 7-stage voice/RAG pipeline with 3 stages and trust the answer LLM for classification and refusal |
| 0064 | LLM-First Agentic Voice | Accepted (implementation complete; pilot validation pending) | The agentic LLM decides first on every voice turn, with search, transfer and end-call tools |
| 0065 | Refuse-and-Link Medical Content Policy | Accepted (supersedes ADR-0062) | Questions asking for dosing, self-medication, diagnosis or treatment choice are refused with a link to the validated hospital brochure |
| 0066 | React + Vite Frontend Deviation | Accepted (deviation record) | Keep React + Vite rather than migrating to the methodology's Next.js baseline |
| 0067 | Deploy-State Claims Must Name Image and Version | Accepted | Any written claim about what is deployed must name the image and the exact version it was validated on |
Five records on this site carry site-local numbers that differ from the master register. The pages titled ADR-0014, ADR-0015 and ADR-0016 are master records 0013, 0014 and 0015. The token-budget page (site ADR-0013) and the query-decomposition page (site ADR-0032) have no master-register number. The RAG pipeline enrichment page is the master's legacy ADR-007. The master register has no records numbered 0016, 0032 or 0041-0045; earlier foundational records (October 2025) use a separate three-digit scheme and are not listed here.
ADR Conventions
Each ADR follows a consistent structure:
- Context: The situation and forces that motivated the decision
- Decision: The specific choice made
- Consequences: The positive and negative outcomes of the decision
- Status: Proposed, Accepted, Deferred, Deprecated, or Superseded
Some numbers in the master register were never allocated (0016, 0032, 0041-0045). ADR-0006 (fuzzy matching) and ADR-0010 (Python 3.13 upgrade path) are accepted decisions and appear in the table above.
Decision Timeline
Thematic Groups
Data Processing
- ADR-0001 (Chunking): How documents are split for embedding
- ADR-0005 (Embeddings): Original embedding model selection (superseded by ADR-0033)
- ADR-0033 (BGE-M3 Migration): Migration to BGE-M3 (1024-dim) for superior Dutch retrieval
- ADR-0007 (Metadata Boosting): How retrieval results are re-ranked using metadata signals
- ADR-007 legacy (RAG Enrichment): BM25 hybrid search, context assembly, canonical questions
- ADR-0014 (LLM Validation): Post-extraction entity validation and contextual retrieval page summaries
- ADR-0015 (Taxonomy): Single source of truth for all domain knowledge and normalization
- ADR-0016 (SNOMED CT): SNOMED CT Belgian Edition for scalable medical terminology
- ADR-0017 (Context Retrieval): Complete 8-stage retrieval pipeline documentation
- ADR-0018 (URL Assessment): AI-powered category and value assessment for crawled URLs
- ADR-0019 (Contextual Embeddings): Anthropic-style chunk context for enriched embedding and BM25 indexing
- ADR-0020 (RRF): Reciprocal Rank Fusion replacing weighted linear score combination
- ADR-0026 (Pipeline Quality & Speed): Condition-aware doctor queries, condition-to-department fallback, Tier 2 skip
- ADR-0028 (Golden Pages): Three-phase pipeline: scrape → seed → gate entity creation
- ADR-0030 (LLM Extraction): Structured entity extraction replaces dictionary-gated graph routing
- ADR-0032 (Query Decomposition): LLM-powered multi-hop query decomposition into parallel sub-question retrieval
Quality and Testing
- ADR-0002 (No Mocking): How the system is tested
- ADR-0004 (Analytics): How quality is monitored
User Experience
- ADR-0008 (Feedback): How users signal quality issues
- ADR-0009 (Progress): How pipeline progress is communicated
- ADR-0024 (Full Mode): Always-on quality settings for demo presentation
- ADR-0025 (Novation UI): Document-style Q&A thread matching the hospital website design
- ADR-0027 (Multilingual): Cross-lingual RAG with 8-language support
Infrastructure
- ADR-0003 (Incremental Crawling): Architecture for incremental content crawling (proposed)
- ADR-0006 (Fuzzy Matching): How entity variations are resolved
- ADR-0011 (Module Inlining): How the codebase is organized
- ADR-0013 (Token Budget): How reasoning model token limits are managed
- ADR-0023 (Prompt Caching): Deferred -- OpenAI automatic caching sufficient at current scale
- ADR-0029 (Remove Graphiti): Direct Neo4j driver replacing Graphiti library (Neo4j removed: primary removal 2026-03-07, cleanup completed 2026-05-02; replaced by PostgreSQL)
- ADR-0031 (Semantic Cache): Two-tier PostgreSQL + pgvector cache on reformulated queries
- ADR-0034 (Latency Optimization): Jina Reranker v2, reduced candidates, latency improvements
Safety and Security
- ADR-0036 (Adversarial Hardening): Perplexity-based anomaly detection, burst rate limiting, streaming retraction
- ADR-0062 (Corpus-Grounded Medical Content, superseded): relaxed the no-medical-advice rule for brochure-sourced dosing; reversed after the 1 June 2026 dose incident
- ADR-0065 (Refuse-and-Link): medical-advice questions are refused with a link to the validated brochure. See the Safety overview for the incident.
Voice Channel
- ADR-0048 (OpenAI Embeddings Migration): voice-channel latency forced the move from on-premise Ollama bge-m3 to OpenAI
text-embedding-3-large - ADR-0049 (Thin Voice Architecture, superseded): collapsed an 8-stage voice pipeline to regex pre-filter → FAQ → RAG; subsequently superseded by ADR-0051
- ADR-0050: Twilio Elastic SIP into self-hosted LiveKit SIP for PSTN voice termination
- ADR-0051 (Agentic-only Voice Orchestrator): GPT-4.1 with tool use becomes the only voice path; deterministic thin pipeline deleted
- ADR-0052 (Voice Language Locking): voice channel locks language at first utterance; mid-call switching unsupported (Deepgram single-mode silence)
Knowledge Representation
- ADR-0053: Neo4j removed (2026-03-07, cleanup completed 2026-05-02); the knowledge graph now lives in PostgreSQL -- completes the second half of ADR-0029
Deferred Investigations
- ADR-0021 (Self-RAG): Multi-pass generation with self-reflection -- deferred due to latency
- ADR-0022 (Dynamic Retrieval): Mid-generation retrieval (FLARE/DRAGIN) -- deferred for short-form answers