Chaima Gharbiai · data
← projects

Compliance analysis engine, Vamisec

llm agents · rag · oscal · pgvector · langfuse

This was my graduation project, during my internship at Vamisec in Germany (March to September 2026). Vamisec does IT security and compliance consulting, and builds a platform, VamiGRC, to automate part of what their consultants do by hand. The diagrams and charts here are my own, made from my thesis, you won’t see the platform itself.

The problem

Before an audit, a company needs to know if it actually meets a standard. So for each requirement (we call it a control), a consultant asks: is it compliant, partially compliant, a gap, or not applicable? To answer, they compare the control with the company’s own policies and procedures.

For one control that’s fine. But ISO 27001 alone has 93 controls in Annex A, and companies often need several standards at once, so it quickly becomes hundreds. Read the control, search the documents, find the evidence, decide, again and again. By hand, one gap analysis took about two weeks.

The goal was never to replace the consultant. The system does the first pass: it proposes a verdict with its evidence, and the human keeps the final decision.

Part 1: getting the standards in

Before the system can check anything, it needs the standard in a form it can work with. But standards are written for people: PDFs with headings, tables and page numbers, legal XML, vendor formats, sometimes a structured file we’ve never seen. We need every control separately, with its ID, title, exact text, parent group and where it comes from in the source.

So everything is converted to OSCAL, an open format from NIST that describes controls as data. Every control becomes addressable, the structure can be validated against a public schema, and each control still links back to its place in the source.

The important rule: the model never rewrites the source. An LLM reads the blocks to classify them and to learn the numbering patterns, but code copies the exact original text. In compliance a small change in wording can change the legal meaning, so the text has to stay verbatim.

The hard part is structure. One standard can switch numbering systems several times, so the pipeline first splits it into regimes by the shape of the identifiers (not by words like “Annex”, so it works in any language), then learns the hierarchy for each one. Before anything is published, a validation gate checks fidelity, coverage, references and the OSCAL schema, and a reviewer can fix the structure by hand.

tested on 22 documents, from 13 standards bodies, in 3 languages
controls extracted 6,195
source text accounted for 99.95% (median)
ISO 27001 Annex A 93 of 93, none missing, none extra

The hardest one was the German BSI B3S standard. The first version found 1 control out of 361. After learning the document’s own numbering, it found 263, and 97% of its main family. Still not perfect, but a standard that was almost unreadable became usable.

first version 1 of 361 learned numbering 263 of 361 (72.9%)

Part 2: the assessment

The company’s policies follow a separate path: they’re split into passages, embedded and indexed. The standards and the evidence only meet once, at retrieval, when a control pulls up the most relevant passages.

The first engine was simple: one LLM call per control, with the control and the retrieved passages. It worked in demos, but it showed a real problem. Retrieval always returns something, even when the company has no policy for that control. Ask about clock synchronisation in a company with no such policy, and it returns a change approval procedure, and the model writes a fluent “compliant” verdict on top of it.

And the two mistakes don’t cost the same. A false gap costs a consultant some extra checking. A false “compliant” can hide a real problem. With one single call, there was nothing to push back, and the confidence was just the model grading itself.

So I split the reasoning into three roles:

Policy documentsthe company's own Controlsfull text, not the title Retrieval vectors: same meaning BM25: same words cross-encoder reranks keeps the best 8 Reasonerverdict, confidence,rationale, evidence Criticagree, revise,or ask a human revise: one more pass, max Routerconfidence≥ 0.80 ? Committedconfident verdicts Human reviewthe rest, and everythin "compliant"

The Reasoner proposes, the Critic checks, and the Router decides. The loop can only run twice, so it always ends.

  • Retrieval. Vector search finds passages that say the same thing with other words, because a policy never copies the standard’s wording. BM25 keyword search in Postgres finds the exact technical terms. A cross-encoder reranks everything and keeps the best 8.
  • Reasoner. One verdict per control, with a confidence, a rationale and the evidence.
  • Critic. A second model that rereads the same evidence and can agree, ask for a revision, or send it to a human. An objection has to quote the evidence, otherwise the two agents just become one agent with extra steps.
  • Router. Plain code, not a model. It commits the verdict, allows one revision, or sends it to the consultant.
  • One safety rule above all of it: any “compliant” or “partial” verdict that rests on a single document always goes to a human.

The consultant then sees everything in a workbench: the Reasoner’s verdict and the documents it used, the Router’s decision, the Critic’s analysis, and the exact evidence. They can override the status, write why, and confirm or dispute. A confirmed gap becomes a finding.

For one framework, a cheaper single-pass engine is enough. The multi-agent path is for several frameworks at once, where related controls can share evidence.

On real client work

Two security consultants at Vamisec each did 3 gap analyses on their own, before seeing the system’s output: 548 controls across ISO 27001, DORA and GDPR. One of them combined all three frameworks in 356 controls, so the cross-framework path was really used.

They reported about 95% agreement with the system, and the gap analysis that used to take about two weeks was done in about three hours, with their checking included.

The Critic sees the answer first

Even with good results on real work, the deployed design has one weakness: the Critic reads the Reasoner’s verdict before it forms its own opinion, so it can get anchored to it.

So I built an experimental version where the Critic is replaced by an independent Verifier. It gets the control but not the draft, plans its own searches, investigates, and freezes its findings. Only then are the two views compared, and the reconciliation is done in code, not by a model. The result goes to the same Router and the same human review.

To test it I needed cases where the right answer is known. I took 360 controls from frameworks outside the company’s scope, so the system should never claim they’re covered. Retrieval still returned passages for every one of them, which is exactly the trap.

no review 90 false compliant Critic (sees the draft) 90: fixed 11, broke 11 independent Verifier 70: 20 fewer (−22%)

False "compliant" claims on 360 controls that should never be compliant.

The independent Verifier removed 20 false “compliant” claims, a 22% drop. The anchored Critic changed verdicts too, but it fixed 11 and broke 11 others, so no real gain. I also tested the other direction, on controls where the evidence really exists: the Verifier added 3 false gaps. 20 fewer dangerous mistakes for 3 more cheap ones is a good trade here.

Honestly, I don’t claim more than that yet. A small pilot on 30 controls showed the full workflow behaves as designed (it reran all 15 revisions it asked for, rejected 3 malformed records, kept 6 disagreements for a human), but it costs about 5.7 times the input of a single pass, and it needs a bigger expert-labelled evaluation before it becomes the default.

Next

Better links back to the exact place in the source, handling harder layouts like multi-column documents, and a larger expert-labelled evaluation.