Skip to main content

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).

ADRTitleStatusKey Decision
0001Configurable Text ChunkingAcceptedTiktoken + markdown-aware chunking with 350/450/70 parameters
0002No Mocking PolicyAcceptedTestcontainers for real integration tests
0003Incremental Crawling ArchitectureProposed (the implementation has drifted from the record; flagged by an audit)Incremental crawling with change detection instead of full re-crawls
0004Analytics and Audit ImprovementsAcceptedPrometheus metrics + structured audit logging
0005Nomic-Embed-Text for Dutch RAGSuperseded by ADR-0033Local Ollama embeddings replacing OpenAI, 768 dimensions
0006Fuzzy Matching StrategyAcceptedStandard-library sequence matching for entity deduplication and search matching of Dutch medical terms
0007Metadata Filtering and BoostingAcceptedIntent-to-category filtering with metadata-driven re-ranking boosts
0008User Feedback and Think HarderAcceptedThumbs up/down + escalated search with reranking
0009Pipeline Progress IndicatorAcceptedWebSocket-based real-time stage reporting
0010Python 3.13 Upgrade PathAccepted (all three phases shipped)Phased upgrade of the backend runtime to Python 3.13
0011Inline S4U ModulesAcceptedMonorepo replacing 5 external packages
0012Mega-Menu Content Selector FixAcceptedContent-selector priority change so that navigation menus are not extracted as page content
007 (legacy)RAG Pipeline EnrichmentAccepted; consolidated into ADR-0017BM25 hybrid search, context assembly, canonical questions
0013 (site record)Reasoning Model Token BudgetAccepted; 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 RetrievalAccepted; consolidated into ADR-0017Tier 2 validates graph entities; generates page summaries for contextual retrieval
0015 (master 0014)Taxonomy-Driven Entity NormalizationAcceptedSingle source of truth for all domain knowledge, 4-tier LLM routing, cost tracking
0016 (master 0015)SNOMED CT Terminology IntegrationAccepted (Phase 1 implemented; Phase 2 parked after the Neo4j removal)SNOMED CT Belgian Edition (280K Dutch concepts) replaces hand-maintained medical aliases
0017Context Retrieval ArchitectureAccepted (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
0018AI URL Category AssessmentAcceptedTwo-dimensional AI assessment (category + value) using Tier 3 model for crawled URL classification
0019Contextual EmbeddingsAcceptedAnthropic-style chunk context prepended before embedding and BM25 indexing
0020Reciprocal Rank FusionAcceptedRRF (k=60) replaces weighted linear score combination for hybrid search
0021Self-RAGDeferredMulti-pass generation with self-reflection -- deferred due to latency cost
0022Dynamic RetrievalDeferredMid-generation retrieval (FLARE/DRAGIN) -- deferred for short-form answers
0023Prompt CachingDeferredExplicit prompt caching -- deferred, OpenAI automatic caching already active
0024RAG Full ModeAcceptedAlways-on Jina reranking, Tier 3 model, 20 candidates for demo quality
0025Novation UI IntegrationAcceptedDocument-style Q&A thread replacing chat bubbles for consistency with the hospital website
0026RAG Pipeline Quality & SpeedAcceptedCondition-aware doctor queries, condition-to-department fallback, Tier 2 skip, cached query resolution
0027Multilingual Prompts & LLM Best PracticesAcceptedCross-lingual RAG: English system prompts, 8-language responses, citation dedup
0028Golden-Page Taxonomy GatingAcceptedThree-phase pipeline: scrape → seed → gate. Source page type determines entity creation permissions
0029Remove Graphiti -- Direct Neo4jAccepted; 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
0030LLM Entity ExtractionAcceptedStructured entity extraction from intent LLM replaces dictionary-gated graph routing
0031Two-Tier Semantic Query CacheAcceptedPostgreSQL + pgvector cache with SHA-256 hash (Tier 1) and embedding similarity (Tier 2) on reformulated queries
0032 (site record)Query DecompositionAccepted (implemented behind a feature flag, off by default)LLM-powered multi-hop query decomposition into parallel sub-question retrieval
0033BGE-M3 Embedding MigrationSuperseded by ADR-0048Migrated 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)
0034Pipeline Latency OptimizationAcceptedJina Reranker v2 API replacing local BGE cross-encoder, 20 candidates default
0035Think Harder - Dedicated Escalation ConfigurationAcceptedDedicated escalation model and parameters for Think Harder pipeline
0036Adversarial Input HardeningAcceptedPerplexity-based anomaly detection, LLM-as-judge, burst rate limiting, streaming retraction
0037Lingua Language Detection ValidationAcceptedLingua-based language detection for query language validation
0038Corrective RAG / CRAG Quality GateAccepted (feature-flagged, off by default)CRAG quality gate for retrieval result validation
0039ColBERT Multi-Vector RerankingAccepted (feature-flagged, off by default)ColBERT as a secondary reranking signal rather than a primary retrieval mechanism
0040Ingestion-Side Language Detection FilterAcceptedChunk-level language detection that skips content not in the tenant's expected language
0046Clarifying Questions for Ambiguous QueriesAcceptedClickable clarification cards when a condition maps to three or more departments
0047Tech Stack BaselineAcceptedAdopt the methodology's canonical stack baseline, with listed deviations
0048OpenAI Embeddings MigrationAccepted (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
0049Thin Voice ArchitectureSuperseded by ADR-0051Collapse multi-stage voice pipeline (3-4 sequential LLM calls) to a deterministic regex pre-filter → FAQ → RAG path
0050Twilio + LiveKit SIP IntegrationAcceptedTwilio Elastic SIP into self-hosted LiveKit SIP for PSTN voice termination
0051Agentic-only Voice OrchestratorAccepted (supersedes ADR-0049)Make the agentic voice orchestrator (GPT-4.1 + tool use) the only voice path; delete the deterministic thin orchestrator
0052Voice Language Locked at First UtteranceAcceptedLock the call's language at the first transcribed turn; mid-call switching is unsupported (Deepgram single-mode silence on cross-language speech)
0053Neo4j Removal + pgvector ConsolidationAccepted (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
0054Intent Classification CacheAcceptedCache 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
0055FAQ-Corpus Drift PreventionAccepted (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.
0056Chat Answer-Shape TypologyAcceptedSix universal shape patterns (point fact, step-by-step, attribute list, multi-entity, comparison, decision tree) replace ad-hoc per-defect rules; chat-only injection
0057Tenant-Scoped Prompt Addendums + Doctor-Profile BoostAcceptedA tenant-scoped registry isolates tenant-specific prompt rules; tenant-agnostic 1.50× boost for documents titled after the doctor
0058Data-Quality Layer ParityAcceptedFour complementary data-quality layers at the matching points of the ingest pipeline
0059Tenant- and Language-Extension of Clusters 1 and 3ProposedThree-phase migration plan (audit and plan only; no code shipped with the record)
0060Chat Conversation Language LockAccepted (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
0061Query Rewriting to the Corpus LanguageAccepted (principle in force; per-tenant parameterization planned)Rewrite every query to the corpus language once, instead of enumerating per-language spellings
0062Corpus-Grounded Medical ContentSuperseded by ADR-0065On 2026-05-14, allowed dosing information when it came from the hospital's validated brochures; reversed on 2026-06-01 after the dose incident
0063Trust-LLM Pipeline SimplificationAccepted (implementation complete; pilot validation pending)Replace the 7-stage voice/RAG pipeline with 3 stages and trust the answer LLM for classification and refusal
0064LLM-First Agentic VoiceAccepted (implementation complete; pilot validation pending)The agentic LLM decides first on every voice turn, with search, transfer and end-call tools
0065Refuse-and-Link Medical Content PolicyAccepted (supersedes ADR-0062)Questions asking for dosing, self-medication, diagnosis or treatment choice are refused with a link to the validated hospital brochure
0066React + Vite Frontend DeviationAccepted (deviation record)Keep React + Vite rather than migrating to the methodology's Next.js baseline
0067Deploy-State Claims Must Name Image and VersionAcceptedAny written claim about what is deployed must name the image and the exact version it was validated on
Numbering note

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
Numbering gaps

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