KOS_COMPTA — Project Story

Inspiration

I am not a typical developer. My background starts in chemistry — I completed a vocational degree (BTS Métiers de la Chimie) where I became fascinated not just by molecules, but by the systems around them: how chemical and food resources are managed, distributed, and accounted for across countries and enterprises. That curiosity pulled me toward economics — debt systems in Europe, capital markets, mathematical pattern recognition in financial data.

At the same time, I was using GPT-3.

Back then, I genuinely thought I might be losing my mind — talking to a language model in 2021, building mental frameworks around it, imagining what it could become. Today I use it professionally every day. The loop closed.

One thing kept coming back across every environment I worked in — chemistry labs, accounting internships, small French businesses: the gap between what the rules say and what actually gets recorded. Compliance is never the bottleneck people think it is. The bottleneck is the absence of a system that enforces it before the damage is done.


What I Built

KOS_COMPTA is a Compliance ERP Middleware — an AI agent that intercepts accounting documents before they enter any ERP system, audits them against French law (régularité, sincérité, image fidèle — Art. L123-14 Code de Commerce), and routes them accordingly: clean payload to ERP, or a motivated rejection with the exact legal article cited.

It runs entirely inside a GitLab CI/CD pipeline, triggered on Merge Request or push, powered by the Claude API (Anthropic) for the legal reasoning layer, and backed by a local Knowledge Operating System — a vector knowledge base (ChromaDB) storing French accounting norms, PCG classes, TVA rules, and cycle procedures as structured JSON root files.

The architecture follows a single principle:

The KOS is the legislator. The LLM is the executor. The CI/CD is the tribunal.

flowchart TD
    A["Incoming Document<br/>invoice / expense report / journal entry"] --> B

    subgraph PIPELINE["GitLab CI/CD Pipeline"]
        B["Stage 1 - Detect<br/>Document type identified"]
        C["Stage 2 - Load KOS<br/>Applicable norms loaded<br/>E1 legal corpus + E2 internal SOP"]
        D["Stage 3 - Analyse<br/>Claude API<br/>regularity - sincerity - true and fair view"]
        E["Stage 4 - Report<br/>Automatic MR comment published"]
        B --> C --> D --> E
    end

    E --> O1["COMPLIANT<br/>ERP Payload generated"]
    E --> O2["WARNING<br/>Human review required"]
    E --> O3["REJECTED<br/>Legal article cited + corrections listed"]

How I Built It

Everything is grounded in a methodology I have been developing for the past two years called the KOS — Knowledge Operating System. It is a hybrid infrastructure combining local AI models (Ollama), vector storage (ChromaDB), and cloud LLM APIs, organized around root files — structured JSON documents that define the rules of any domain before any model is ever called.

The insight behind root files is simple: compliance should live in the knowledge base, not inside the model. If you encode French accounting law into a system prompt, you are locked to one provider. If you encode it into structured JSON files that any LLM reads first, you can swap models freely — Gemini, Llama, Mistral — and the compliance does not move.

I am currently a BTS Accounting student in alternance in Toulouse, and I am also financing a 5-year Bachelor and Master program in Data and AI. This project sits at the intersection of everything I have been building: accounting knowledge from my studies, AI infrastructure from my personal projects, and the compliance gap I observe every week in real French SME environments.

The pipeline was built in this order:

  1. KOS_COMPTA_Taxonomie.json — the constitutional file, maps every folder and every rule
  2. E1 Legal Corpus — French accounting norms as structured Markdown with YAML frontmatter
  3. agent_compliance.py — the Python engine: read, RAG, Claude, route, log
  4. KOS_COMPTA_Client_Log.json — operational context for the client, separate from technical logs
  5. .gitlab-ci.yml — the trigger that makes it a real CI/CD system, not just a script

Challenges

The hardest part is not the code — it's the knowledge formalization.

Encoding French accounting law into machine-readable JSON root files means making explicit what most accountants leave implicit. Every norm has exceptions. Every rule has a hierarchy. The loi_tva_cadeaux.md file — TVA on client gifts, 73€ TTC threshold, CGI Art.236 — took longer to write correctly than the agent that reads it.

The second challenge was LLM trust boundaries. Claude produces reliable structured JSON for compliance verdicts — but the system is designed so that the verdict logic never depends on what the model thinks. The model applies the rules loaded from the KOS. If the rules are wrong, the verdict is wrong. That is a feature: it makes the system auditable, correctable, and LLM-agnostic.

The third challenge is the one I live every day: being a solo builder across accounting school, alternance work, and a full technical infrastructure. The KOS exists precisely because of this constraint — a system that retains context, tracks iterations, and lets me work in continuity even when I can only give it 45 minutes between classes.


What I Learned

I work as an accounting assistant in alternance in a French company. I see this problem every week — documents that go directly into the ERP without any structured verification layer, errors caught only at year-end closing, and compliance checks that depend entirely on one person's attention.

That is the gap this project addresses. And building it taught me that the most valuable thing an AI system can do in a compliance context is produce a motivated rejection — not just a score, but an explanation with a legal reference that a human can verify, challenge, or learn from. That is what distinguishes a tool from a black box.

Building in public, even as a student, even solo, is the fastest way to close the loop between learning and doing.


Built with Claude API (Anthropic) · GitLab Duo · ChromaDB · Python · French Accounting Law KOS_COMPTA is part of the ERGO Capital project — an agent-native compliance infrastructure for French SMEs.

Built With

Share this project:

Updates