LearnSystem design

Permission-aware enterprise knowledge assistant

Design an assistant that answers 50,000 employees’ questions over Confluence, Google Drive, Slack and a ticketing system, with citations, respecting each source’s permissions, in English, French and German.

Applied LLM8 parts

Contents

What to cover

Sketch your own design first. A complete answer has these parts; the notes say what each should settle.

  1. Requirementscorpus size and churn; permission models of each source; latency target; acceptable error/abstention; data residency; who maintains connectors; languages
  2. Estimates
  3. API
  4. Data model
  5. Architectureconnectors with change capture and ACL sync; parsing/chunking with metadata; embeddings + lexical index (per-language handling); permission pre-filter at query time; query rewriting; hybrid retrieval; reranker; grounded generation with per-claim citations; citation verification/abstention; feedback capture; observability with per-request retrieval traces; offline eval set by department and language
  6. Deep divesa user loses access to a doc — how fast does the assistant stop citing it?; How do you evaluate retrieval with no labels at first?; What breaks if you remove the reranker?
  7. Trade-offsper-tenant index vs shared index with filters; freshness vs ingestion cost; reranker latency vs precision; long-context stuffing vs top-k; one multilingual embedder vs per-language
  8. EvaluationACLs enforced before generation and in every cache; retrieval and generation evaluated separately; concrete latency budget; deletion and revocation paths; rollout plan with a pilot group and feedback loop

Reference design

One way to answer it, part by part. Open a part once you have your own version of it.

Requirements

Functional

  • Answer free-text questions in English, French and German, including cross-lingual ones (ask in French, cite an English page), with numbered citations that link to the exact passage.
  • Multi-turn follow-ups; optional filters by source, space and date.
  • Abstain (“I can’t find this in sources you can access”) rather than guess.

Assumptions to confirm

  • Corpus and churn: ~2M Confluence pages, ~3M text-bearing Drive files, ~50M Slack threads (channels only, no DMs at launch), ~5M tickets. ~1% of documents change per day; Slack and tickets change by the minute.
  • Permission models: Confluence space permissions plus inherited page restrictions; Drive per-file ACLs with groups, domain-wide and “anyone with the link” sharing; Slack channel membership; ticketing project roles. Group membership comes from the IdP via SCIM.
  • Latency: first token p95 < 2 s, full answer p95 < 8 s.
  • Error tolerance: a confident wrong answer with a citation is worse than abstaining. Target ≥ 95% claim-level faithfulness; accept 10–15% abstention at launch.
  • Data residency: index, caches, traces and LLM inference stay in UK/EU regions; no training on company data.
  • Connector ownership: a platform team owns connectors and their freshness SLOs; source admins own ACL correctness.
  • Zero permission leaks is a hard constraint, not a metric to trade off.

Estimates

  • Traffic: 50k users × 30% daily active × 5 questions = 75k questions/day. Spread over a ~10-hour UK/EU working window: 75k / 36,000 s ≈ 2 QPS average, ~8 QPS peak (4×).
  • Chunks: Confluence 2M × 8 = 16M; Drive 3M × 12 = 36M; Slack 50M threads ≈ 50M; tickets 5M × 2 = 10M → ~110M chunks of ~400 tokens ≈ 44B tokens.
  • Vector index: 110M × 1,024 dims × 1 byte (int8) ≈ 113 GB, plus ~15–30 GB for the HNSW graph (32–64 four-byte neighbour ids per vector at layer 0) → ~130–145 GB in memory, a handful of shards plus replicas. BM25 over 44B tokens ≈ 0.3–0.5 TB.
  • Embedding: backfill 44B tokens ÷ an assumed ~50k tokens/s per GPU ≈ 880k GPU-seconds ≈ 245 GPU-hours (days on a few GPUs). Daily churn 1.1M chunks × 400 = 0.44B tokens ≈ 2.5 GPU-hours.
  • Generation: 10 chunks × 400 + 1.5k system/history ≈ 5.5k input and 400 output tokens. 75k × 5.5k ≈ 410M input + 30M output tokens/day. At an assumed $3/M input and $15/M output: $1,230 + $450 ≈ $1.7k per working day, ~2 cents per question (~$37k/month).
  • Rerank: 50 candidates × 8 QPS = 400 pairs/s at peak — one or two GPUs.
  • Latency budget (p95): group expansion 50 ms, query rewrite 300 ms, filtered hybrid retrieval 150 ms, rerank 200 ms, LLM first token 800 ms → TTFT ≈ 1.5 s; 400 tokens at ~80 tokens/s adds ~5 s, streamed.

API

POST /v1/ask                         (Server-Sent Events)
{ "conversation_id": "c_9f2",
  "question": "Quelle est la politique de congé parental ?",
  "filters": {"sources": ["confluence", "drive"], "updated_after": "2025-01-01"} }

events:
  status   {"stage": "retrieving"}
  token    {"text": "..."}
  citation {"n": 1, "doc_id", "title", "url", "snippet", "source", "updated_at", "verified": true}
  final    {"abstained": false, "trace_id": "t_81c", "latency_ms": 4210}

POST /v1/feedback  {"trace_id", "rating": "up|down", "reason": "wrong|outdated|missing|leak", "comment"}
GET  /v1/conversations/{id}

Internal contract every connector implements:

PUT    /ingest/docs/{source}/{source_id}      {blob_ref, mime, title, url, acl, version, updated_at}
PATCH  /ingest/docs/{source}/{source_id}/acl  {acl: {allow: [...], deny: [...]}, acl_version}
DELETE /ingest/docs/{source}/{source_id}
PUT    /ingest/groups/{group_id}              {members: [...], version}

Identity comes from SSO (OIDC) at the gateway; the client never sends a user id. ACL changes have their own endpoint so they never queue behind content re-embedding.

Data model

  • Document: doc_id, source, source_id, url, title, lang, owner, version, content_hash, updated_at, deleted_at.
  • Chunk: chunk_id, doc_id, text, section_path (heading breadcrumb, Slack thread, ticket field), lang, position, embedding (int8), acl_tokens[], acl_version. ACLs are denormalised onto chunks as principal tokens (user:42, group:eng-fr, space:HR, domain:all) so the index filters natively.
  • Principal store: user → groups, transitively expanded from the IdP and source-native groups, versioned, cached per user for ≤ 60 s.
  • ACL store: doc_id → allow/deny + acl_version; source of truth for the final pre-generation check.
  • Conversation / Turn: question, rewritten queries, answer, citations.
  • Trace: principal-set hash, retrieved ids and scores per stage, reranked ids, prompt and model versions, per-sentence verification verdicts, stage latencies, cost. Traces quote documents, so they inherit ACLs, stay in-region and expire after 30 days.
  • Feedback and EvalItem (question, language, department, expected doc ids, reference answer, answerable flag).

Storage: OpenSearch or Vespa for the hybrid index with per-language analysers; Postgres for documents, ACLs and conversations; Kafka for change events; object storage for raw files.

Architecture

Flow · 4 stepsReference architecture: ingestion and query path

Reference architecture: ingestion and query pathIngestion flows from Confluence, Drive, Slack and Ticketing through connectors and Kafka into parsing, chunking and embedding, with a priority ACL path patching acl_tokens in place and the ACL store. The query path expands principals, rewrites the question, runs ACL-filtered hybrid retrieval, reranks to the top 8-10 with neighbouring chunks, re-checks the reranked set against the ACL store, then generates, verifies and streams the answer.SourcesConfluence · Drive · Slack ·TicketingConnectorschange capture + ACL syncKafkadoc-events | acl-events |group-eventsParse +chunk +embedlayout-aware ·languagedetectionOrchestratorexpand ·rewrite ·retrieve ·rerankACL updaterpatchacl_tokens inplaceHybrid indexBM25 per language + HNSW +acl_tokensCross-encoder reranktop 8-10 + neighbour chunksACL storedoc_id → allow/deny + acl_versionGrounded generationevery sentence cites [n]Citation verifierentailment per sentenceClientSSE · trace · feedbackdoc-eventsacl-events (priority)top-kre-check reranked setverified setSSE1234IngestionMemoryQuery
  1. Ingest Connectors stream change events to Kafka; parsing, chunking and embedding fill the index while the ACL updater patches acl_tokens and the ACL store.
  2. Expand and rewrite The orchestrator expands principals (user to groups, cached <= 60 s) and rewrites the question into a standalone query with EN/FR/DE variants and filters.
  3. Retrieve ACL-filtered hybrid retrieval (k = 100) feeds the cross-encoder rerank (top 8-10 + neighbours); the reranked set is re-checked against the ACL store.
  4. Generate and verify Grounded generation cites every sentence, the citation verifier keeps, drops or abstains, and the answer streams to the client with a trace.

The query path filters retrieval by ACLs, reranks the top-k, re-checks the reranked set against the ACL store, then generates and verifies citations.Diagram drafted by a local AI model (Inkling 2 Mini) from this page's text and drawn from data. Checked by an independent reviewer.
Data
Steps
StepTitleWhat happens
1IngestConnectors stream change events to Kafka; parsing, chunking and embedding fill the index while the ACL updater patches acl_tokens and the ACL store.
2Expand and rewriteThe orchestrator expands principals (user to groups, cached <= 60 s) and rewrites the question into a standalone query with EN/FR/DE variants and filters.
3RetrieveACL-filtered hybrid retrieval (k = 100) feeds the cross-encoder rerank (top 8-10 + neighbours); the reranked set is re-checked against the ACL store.
4Generate and verifyGrounded generation cites every sentence, the citation verifier keeps, drops or abstains, and the answer streams to the client with a trace.

Source: This page's text

Boxes
BoxGroupDetail
SourcesIngestionConfluence · Drive · Slack · Ticketing
ConnectorsIngestionchange capture + ACL sync
KafkaIngestiondoc-events | acl-events | group-events
Parse + chunk + embedIngestionlayout-aware · language detection
ACL updaterIngestionpatch acl_tokens in place
Hybrid indexMemoryBM25 per language + HNSW + acl_tokens
ACL storeMemorydoc_id → allow/deny + acl_version
OrchestratorQueryexpand · rewrite · retrieve · rerank
Cross-encoder rerankQuerytop 8-10 + neighbour chunks
Grounded generationQueryevery sentence cites [n]
Citation verifierQueryentailment per sentence
ClientQuerySSE · trace · feedback

Source: This page's text

Sequence · 8 stepsLife of one question

Life of one questionA user asks a question with identity established by SSO at the gateway. The orchestrator expands principals, rewrites the query, runs hybrid retrieval with the ACL filter, reranks candidates, re-checks the final set against the ACL store, asks the LLM for a grounded answer, verifies citations itself, and streams the answer back over SSE.UserOrchestratorHybrid indexRerankerACL storeLLM1ask question2expand principals + rewrite3hybrid retrieval k=100candidates4candidatestop 8-105re-check final setfinal set6grounded answeranswer7verify citations8SSE answer
Life of one questionA user asks a question with identity established by SSO at the gateway. The orchestrator expands principals, rewrites the query, runs hybrid retrieval with the ACL filter, reranks candidates, re-checks the final set against the ACL store, asks the LLM for a grounded answer, verifies citations itself, and streams the answer back over SSE.UserOrchestratorHybrid indexRerankerACL storeLLM1ask question2expand principals + rewrite3hybrid retrieval k=100candidates4candidatestop 8-105re-check final setfinal set6grounded answeranswer7verify citations8SSE answer
  1. Ask The user asks; identity comes from SSO at the gateway.
  2. Expand and rewrite The orchestrator expands the user's principals and rewrites the query.
  3. Retrieve Hybrid retrieval runs with the ACL filter at k = 100.
  4. Rerank The cross-encoder reranker returns the top 8-10.
  5. Re-check The final set is re-checked against the ACL store.
  6. Generate The LLM produces a grounded answer citing every sentence.
  7. Verify The orchestrator verifies the citations itself.
  8. Stream The answer streams to the user over SSE.

One question flows from the user through orchestration, filtered retrieval, reranking, ACL re-check and grounded generation, then streams back over SSE.Diagram drafted by a local AI model (Inkling 2 Mini) from this page's text and drawn from data. Checked by an independent reviewer.
Data
Messages
StepFromToMessage
1UserOrchestratorask question
2OrchestratorOrchestratorexpand principals + rewrite
3OrchestratorHybrid indexhybrid retrieval k=100
3Hybrid indexOrchestratorcandidates (reply)
4OrchestratorRerankercandidates
4RerankerOrchestratortop 8-10 (reply)
5OrchestratorACL storere-check final set
5ACL storeOrchestratorfinal set (reply)
6OrchestratorLLMgrounded answer
6LLMOrchestratoranswer (reply)
7OrchestratorOrchestratorverify citations
8OrchestratorUserSSE answer

Source: This page's text

 Confluence   Drive   Slack   Ticketing
      | webhooks / change feeds + nightly full ACL crawl
      v
 Connectors ──► Kafka: doc-events | acl-events (priority) | group-events
      v                                      v
 Parse + chunk (layout-aware, headings,   ACL updater: patch acl_tokens
 tables, language detection)              in place + ACL store (no re-embed)
      v
 Multilingual embedder ──► Hybrid index: BM25 per language + HNSW + acl_tokens

 User ─SSO─► Gateway ─► Orchestrator
   1. expand principals (user → groups, cached ≤ 60 s)
   2. rewrite query (small LLM): standalone question, EN/FR/DE variants, filters
   3. hybrid retrieval WITH the ACL filter (k = 100) → reciprocal-rank fusion
   4. cross-encoder rerank → top 8–10, expand to neighbouring chunks
   5. re-check the final set against the ACL store
   6. grounded generation: every sentence cites [n]
   7. citation verifier (entailment per sentence) → keep / drop / abstain
   ─► SSE to client · trace → observability · feedback → eval store

Retrieval and answer caches key on (normalised query, principal-set hash, index version) and are purged on ACL version bumps. Per-request traces make every answer reproducible.

Deep dives

A user loses access — how fast do we stop citing it? Group removals flow from the IdP via SCIM into the principal store; expansion happens at query time with a ≤ 60 s cache, so revocation applies within a minute without touching the index. Per-document changes (unsharing a Drive file, restricting a page) arrive by webhook on the priority ACL topic and patch acl_tokens in place, target p99 < 5 minutes. Backstops: step 5 re-checks the cited set; caches are keyed by principal set; a nightly ACL crawl repairs missed webhooks. Canary documents are shared and unshared every 10 minutes while a probe user asks about them; any leak pages on-call.

Evaluating retrieval with no labels. Generate synthetic questions from sampled chunks per department and language (filtered for low word overlap with the source) to get known positives for recall@k. Judge pilot users’ real queries with an LLM relevance grader calibrated on ~300 SME labels, then have SMEs label ~50 hard queries per department. Citation clicks and reformulations are weak online signals.

Removing the reranker. Top-10 precision drops, so more distractors reach the LLM: more irrelevant citations, more abstention on answerable questions, and pressure to pass 30+ chunks, which raises cost and latency. Cross-lingual queries suffer most. Show it with an ablation on nDCG@10 and faithfulness.

Trade-offs

  • Per-tenant index vs shared index with filters: one shared index with ACL filters gives better utilisation and one ranking stack. Risk: very selective filters degrade HNSW recall — use filter-aware HNSW and fall back to exact search when a user can see few documents. Keep legal and HR spaces in a separate index to limit blast radius.
  • Freshness vs ingestion cost: ACLs within minutes, Slack and tickets near-real-time, Confluence and Drive content within 15 minutes; re-embed only chunks whose hash changed; very large files nightly.
  • Reranker latency vs precision: ~200 ms for 50 pairs is the biggest single quality gain; skip it for navigational queries where BM25 top-1 is confident.
  • Long-context stuffing vs top-k: stuffing 100k tokens costs ~20× per query, adds seconds and weakens per-claim attribution. Use top-k with neighbour expansion; reserve long context for “summarise this document” on one permitted document.
  • One multilingual embedder vs per-language: one model enables cross-lingual retrieval in one index; per-language BM25 analysers (German compound splitting, French elision) keep lexical recall. Revisit only if a language trails by more than ~5 points on its slice.

Evaluation

  • Security gates (must be zero): a permission-leak suite of synthetic users with known ACLs, run on every release and against every cache layer; revocation canaries in production.
  • Retrieval offline: ~1,500 questions stratified by department × language × source; recall@50, nDCG@10, a cross-lingual slice.
  • Generation offline, scored separately: claim-level faithfulness (each sentence entailed by its citation), citation precision and recall, correctness against references, abstention quality on an unanswerable slice.
  • Latency: per-stage p50/p95 against the budget; TTFT p95 < 2 s.
  • Deletion and revocation: deleted sources gone from index, caches and traces within 24 hours; revocation p99 < 5 minutes.
  • Rollout: four-week pilot with two departments (~500 users, all three languages); weekly triage of thumbs-down and abstentions into fixes and new eval items; then expand department by department, A/B testing retrieval changes.
  • Monitoring: thumbs-up rate, citation click-through, abstention rate per language, connector lag, ACL sync lag, verifier failure rate, cost per answer; alerts on lag SLO breaches.

What a strong design shows

  • Treats permissions as correctness: ACL filter inside retrieval, re-check before generation, principal set in every cache key, and a revocation SLO verified by canaries.
  • Evaluates retrieval and generation separately and has a credible plan for starting with no labels.
  • Handles three languages concretely: one multilingual embedder, per-language lexical analysers, per-language eval slices.
  • Gives a per-stage latency budget and a cost per answer, not just boxes.
  • Runs connectors as an operational product: change capture, ACL events on a priority path, nightly reconciliation, deletion propagation.
  • Rolls out through a pilot group whose failures become eval items.

Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.