Tenant Overlay System
The voice channel is designed as a multi-tenant service. Each hospital tenant has a different name, different campus addresses, different doctors, and (sometimes) different speech-to-text mishears specific to its directory. The challenge: serve all of these correctly without hardcoding any of them in shared code or in configuration files.
This page documents the tenant overlay architecture introduced in May 2026.
Two material updates since the original architecture:
- FAQ purge (ADR-0055). All 10 hospital-specific hand-curated FAQ entries were removed on 2026-05-12. The surviving FAQ surface for the pilot tenant now contains only safety and policy entries (crisis, emergency dispatch) plus one clarification entry. Patient-facing factual answers come from the retrieval corpus, not from the overlay file.
- Admin UI. Hospital administrators can now create, edit, delete, import and export their overlay through the administration interface: a routing-rule edit dialog, inline taxonomy editing, an import/export tab and an onboarding banner for empty tenants. No engineer-only file editing is required for routine changes.
The problem
Before the overlay system, two places contained tenant-specific data:
- The shared FAQ entries had a hardcoded general-address answer with a specific street address. When the hospital relocated, the FAQ silently served stale content.
- The shared STT normalisation table mixed generic Dutch phonetic mishears with tenant-specific corrections (for example, a correction for how the hospital name is commonly misheard).
Both patterns failed multi-tenant correctness: shipping hospital #2 would mean either editing shared code (bad) or shipping their data with hospital #1's still in place (worse).
The architecture
Three categories of voice configuration, each with a different home:
| Category | Where it lives | Why |
|---|---|---|
| Generic patterns + language rules | Source code (shared FAQ entries and normalisation table) | Hospital-agnostic; benefits any tenant |
| Tenant-specific phonetic recovery (STT mishears) | Per-tenant overlay file | Phonetic data that does not exist anywhere else |
| Tenant data (addresses, names, hours) | Database plus a registered answer renderer | Single source of truth; no duplication |
At request time the three are composed:
- The shared registry (generic, language-level) comes from source code.
- The tenant overlay (STT mishears) is added from the tenant's overlay file.
- Database-driven renderers (such as the campus listing) read the tenant's taxonomy.
- The result is the effective voice configuration for this turn.
Components
The overlay package
- Schema — a validated structure for the overlay file with three top-level fields: tenant, FAQ entries and STT normalisations. Each FAQ entry has per-language pattern and answer maps. Unknown fields are rejected, so typos fail loudly at start-up.
- Loader — reads one overlay file, validates it against the schema, compiles its patterns, and returns an immutable overlay object. Any error (bad file, invalid pattern, unknown language code, filename that does not match the tenant) stops start-up. This is designed to keep bad configuration from reaching a request.
- Registry — loads every tenant overlay at start-up. An unknown tenant gets an empty overlay (graceful fallback, not an error). Overlays can be re-scanned for development hot-reload.
- Overlay files — one per tenant. They carry STT mishears today and can hold tenant-specific FAQ overrides in the future.
Database-driven answer composition
The shared FAQ entries declare an intent and its match patterns in code. For entries whose answer depends on tenant database data, the entry names an answer renderer instead of a static answer. At match time the matcher looks the renderer up and invokes it with the language and tenant. For example, the campus-listing renderer reads the tenant's campuses from the cached hospital taxonomy and formats per-language prose. House numbers and postal codes stay as digits per the TTS rule.
Add a campus to the database and the next request reflects it. There is no sync gap.
What an overlay file contains
An overlay file names its tenant and lists STT normalisations: pairs mapping a commonly misheard word to the intended one. Typical entries correct the hospital name when speech recognition hears a homophone, and correct clinician surnames that the recogniser mishears. A section for tenant-specific FAQ overrides is left empty until needed.
Wiring across the voice path
The tenant is resolved once per connection from the deployment configuration and passed down the voice path: the connection layer hands it to the voice orchestrator, which passes it to the FAQ matcher (which dispatches to renderers, which read the cached taxonomy) and to the STT normalisation step. Inside the retrieval service the tenant is already resolved upstream via a database lookup, so no extra plumbing is needed.
Onboarding a new hospital tenant
- Create an overlay file for the new tenant, with any STT phonetic mishears specific to its hospital name and clinician surnames.
- Configure the deployment to use the new tenant.
- Populate the hospital, campus and department records in the database (the hospital-agnostic work from April 2026 already enables this, with no code changes).
- Restart the backend.
The same shared FAQ entries (campus listing, visiting hours, parking, phone numbers, etc.) and the same renderer code then serve the new tenant automatically.
Failure modes — the design wants these to be loud
| Failure | Where it surfaces |
|---|---|
| Malformed pattern in an overlay | The backend refuses to start |
| Unknown language code (typo) | Same — start-up failure naming the file and entry |
| Overlay filename does not match its tenant field | Same — silent renames are forbidden |
| Renderer returns nothing (no database data, unknown language) | FAQ matcher falls through to the next entry, eventually to retrieval |
| Tenant not in the registry | Empty overlay returned; the shared registry still applies (graceful) |
The asymmetry is deliberate: start-up errors are non-recoverable (an operator must fix the file), runtime fall-throughs are recoverable (retrieval handles unknown queries fine).
What is NOT in the overlay file
By policy:
- Campus addresses, phone numbers, opening hours live in the database, accessed via renderers.
- Doctor names and canonical department names live in the database (hospital taxonomy).
- The hospital website and branded full name come from the tenant's database record.
Anything that already lives in the database stays there.
Reference
- The implementation, schema, loader, renderers and tests are kept in the project's private repository.