The vector index we built, measured, and switched off
A governed generative-AI platform for a regulated financial institution: four-eyes content approval, division-scoped retrieval, and a retrieval stack that measurement reshaped.
Client details removed
This engagement is covered by a non-disclosure agreement. The client, the product, the vendors and anything that could identify them have been intentionally removed or generalised. Everything described about the problem, the engineering and the outcome is real.

Executive summary
A regulated financial institution needed a generative-AI assistant its risk function could sign off on. The hard part was never the model. It was proving who may ask what, which documents an answer is allowed to draw on, and who approved that document being visible in the first place. We built a three-surface platform (an ingestion and retrieval backend, an employee assistant, and a governance console) in which the institution's existing maker-checker control model is the architecture rather than a layer on top of it. Along the way an offline retrieval study overturned the design: a hybrid vector and keyword stack lost to plain keyword search over model-generated page summaries, and we shipped the simpler thing.
Business context
The institution operates under supervisory expectations that treat an unexplainable automated answer as an unacceptable one. Its knowledge lives in long, densely formatted documents: policies, procedures, product terms and disclosures, full of tables, charts and multi-page sections where only the first page carries a heading. Those documents belong to different divisions, and one division's material is not automatically readable by the rest of the organisation. Any assistant had to respect that boundary inside retrieval, not merely in the interface, and every document reaching the assistant had to have been approved by someone other than the person who uploaded it. Staff also work bilingually, so the same question arrives in two languages and has to reach the same evidence.
The challenge
Staff could not find what the institution already knew. The answers existed, filed across long policy and product documents owned by separate divisions, but finding them meant knowing which document to open and reading past the tables and charts to get there. The obvious fix, an assistant over the whole corpus, was the one thing the risk function would not approve: it could not be shown who was allowed to see which document, who had approved that document, or where a given sentence in an answer had come from. An assistant that could not answer those three questions was not deployable, however good its answers were.
Objectives
- Answer only from approved internal documents, with a citation behind every claim
- Enforce division boundaries inside the retriever, not just in the interface
- Require a second pair of eyes before any document becomes answerable
- Let an administrator reproduce exactly what an end user would see
- Keep spend bounded and attributable to a division
- Ingest long, image-heavy documents without a human watching the job
Solution architecture
We split the platform along the line the institution already governs by. Ingestion turns documents into retrievable, attributable page units. Retrieval is a tool the agent calls with arguments the agent does not get to choose: identity and division scope are injected server-side on every call. Decisioning is where the maker-checker model lives, unchanged in shape from how it governs everything else. And the console exists so an administrator can reproduce an end user's exact view, because "it works for me" is not an answer a risk function accepts.
End-to-end workflow
- User
A division owner uploads a document
- System
Format and type are cross-checked, then stored immutably
The declared type and the file itself have to agree before anything else runs, because a mislabelled file fails much later and much more expensively.
- System
A durable orchestration takes over the long job
Indexing a several-hundred-page document runs for minutes, well past any request timeout, so it leaves the request path entirely.
- System
Pages are rendered serially and read in parallel
The renderer is not thread-safe but character recognition is network-bound, so the two halves of the same batch run under different concurrency models.
- AI
A vision model summarises each page in section context
Page forty-seven refers to the figure above, and the figure is on page forty-six, so pages travel to the model together within a section and never across sections.
- System
Summaries and chunks are written to the search index
- Human review
A second approver publishes the document
Until someone other than the uploader approves it, the document exists but cannot be retrieved.
- User
An employee asks a question
- AI
The agent rewrites the question into a small set of queries
The first query is always the question verbatim, and every query is generated in both working languages, because the same answer may be filed in either one.
- System
Retrieval, reranking and a cited answer stream back
Scope is applied as a filter inside the query itself, so what the retriever can see is decided before the model sees anything.
Engineering challenges and decisions
We built a vector index, measured it, and stopped querying it
The first retriever was the expected one: hybrid keyword-plus-vector search with reciprocal rank fusion. An offline study on real questions showed the vector leg actively hurting. Pages that were semantically adjacent but topically wrong kept displacing the right page, because in a corpus where every page shares the same institutional vocabulary, embedding similarity mostly measures whether two pages are the same kind of document rather than whether either answers the question.
Decision
Retrieve with keyword search over the model-generated page summary rather than over the raw text. That summary is written during ingestion to be structurally normalised and keyword-dense, which is precisely what a term-matching engine rewards. The ingestion pipeline stopped being a preprocessing step and became the thing that produces the retrieval surface.
Trade-off
The index still defines and populates three vector fields that nothing queries. We kept them rather than run a migration for storage we were not meaningfully paying for, and because the measurement could change. Carrying an unused field is cheaper than pretending the study said something it did not.
Governance had to be the architecture, not a layer on it
Maker-checker is how the institution governs everything, and an AI system that bolted approval on at the edges would have been refused. The harder half was retrieval: a user interface that hides another division's documents is not a control, because the model can still be asked to summarise what it just read.
Decision
Four independent authorisation checks, with the innermost one re-reading the caller's permissions from the database on every privileged action rather than trusting the session token, so a revoked role stops working immediately instead of at next sign-in. Division scope is compiled into a filter inside the retrieval query itself, which means a prompt-injection attempt cannot widen what the retriever is able to see.
Trade-off
Four checks means four places to keep in step, and they will drift if nobody watches them. Menu visibility is documented in as many words as not being a security boundary, precisely so that no future contributor mistakes a hidden link for an enforced permission.
Long documents fail halfway, and the system has to notice
Indexing a several-hundred-page document is minutes of orchestration across parallel workers. The renderer is not thread-safe, the model needs the previous page to resolve a reference to the figure above, and jobs die: a worker restarts, an upstream stalls, or the orchestrator code changes while an instance is still in flight.
Decision
Render serially and read in parallel. Parallelise across document sections but stay sequential within one, so context rolls forward exactly where it matters and nowhere else, with an overlapping seed page carrying context across an arbitrary split. Then a reconciliation loop every ten minutes compares orchestration state against the database and repairs the difference, and retries resume from the last page that actually made it into the index rather than from the beginning.
Trade-off
The reconciler only sweeps a stalled job when it can positively confirm what is running. If it cannot reach the orchestration API it does nothing at all, because marking a healthy job failed is worse than marking it late.
The model gets to compose, not to decide
A tenant-editable system prompt is a genuine requirement and a genuine attack surface. Divisions need to shape tone, scope and refusal behaviour, but the same field is the obvious place to try to talk the system out of its own rules, and reasoning models add a second problem: their internal deliberation arrives in the same token stream as the answer.
Decision
The tenant prompt may change tone, scope and refusal behaviour, but the query-generation contract is immutable and stated as such: the first query is always the user's question verbatim, and every query is generated in both working languages. Identity and division are overwritten server-side on every tool call, so the model never supplies its own scope. A streaming state machine splits hidden deliberation from user-visible text by holding back any buffer suffix that could be the start of a hidden tag.
Trade-off
The spend gate fails open. If the quota service is unreachable the question goes through, because denying a legitimate user over a telemetry failure is the worse outcome, and the shortfall reconciles afterwards. That is a deliberate asymmetry: the access checks fail closed, the budget check does not.
Results and lessons
- 0 of 3Vector fields queried in production
- -75%Request cost of the analytics group query
- 4Independent authorisation layers
- 30%Model context reserved for platform prompts
- 50Retrieval candidates per question
- 10 minIndexing reconciliation interval
The platform runs three surfaces on one governed core. Every answer carries citations that resolve to a specific approved page rather than to a document, so a reader can check the sentence rather than the source. Administrators can replay any question under an end user's exact retrieval scope, which turned disagreements about correctness into reproducible cases instead of arguments.
The durable result is not the assistant. It is that approval, scope and spend became properties of the system rather than promises about it. Each one is enforced somewhere a reviewer can point at, which is what made the assistant approvable at all, and what makes the next model swap a configuration change rather than a fresh risk assessment.
Lessons learned
- Measure retrieval before assuming the embedding earns its place
- Write the text you intend to retrieve, then retrieve on that
- Identity and scope belong in the tool call, never in the prompt
- Parallelise across sections, stay sequential inside them
- Reconciliation loops beat careful error handling for long jobs
- Decide in advance which gates fail open and which fail closed
Production considerations
Secrets are pulled from a managed vault at startup and re-checked on a short interval, with dependent clients rebuilt in place, so a rotation does not need a redeploy. Every request writes a structured event keyed on a correlation id, which is what makes spend attributable per division rather than only in aggregate. Sessions slide on activity under an absolute cap, so an idle workstation logs out without punishing a long working session. A penetration test drove the security-header posture, and the content-security policy deliberately forbids the browser from calling the AI backend directly: every call goes through the application's own server, which is where identity is attached.
What we would do next
The reranker already makes a relevance judgement on every question it sees, and those judgements are thrown away. Capturing them turns an implicit opinion into a labelled evaluation set, which is the missing piece for deciding whether the vector leg deserves to come back rather than arguing about it. The second thread is moving approval closer to ingestion, so a document that will be rejected never reaches the index at all instead of being indexed and then withheld. The third is narrowing the gap between what the reranker discards and what a reader would have wanted, which today is only visible through the thumbs-down feedback that arrives after the fact.
Technologies
10- Azure AI Search
- Azure Document Intelligence
- Azure Durable Functions
- Cosmos DB
- Azure Blob Storage
- Azure Key Vault
- Microsoft Entra ID
- LangGraph
- FastAPI
- Next.js
