> Source: https://souverana.ch/en/insights/anonymisierung-architektur/
> Language: en

# Protecting personal data in development, AI agents and chat

Personal data leaves the protected system by different routes: as a test copy for developers, through an AI agent with database access, or in a chat with a cloud model. The article shows, for each route, where the data is best protected and which tools exist for this.

Analysis · Published 11 Nov 2026 · Updated 12 Nov 2026 · Joel Barmettler

## Where personal data should disappear before developers, agents or cloud models see them

**When a development team, an AI agent or a cloud model gets access to customer data, each of them quickly sees more than it needs. How much more depends on where the company removes the personal data. There are five such points, from a cleaned copy of the database to a model the company runs itself. Each point suits one kind of recipient in particular.**

In brief

-   An external development team, such as the one at a practice software vendor, is best given a masked copy of the database in which related values are replaced together. If the columns are shuffled one by one, almost no invoice amount is correct any more in our measurement on an invented practice database. Even a well-made copy is not anonymous: anyone who knows Hildegard Kaufmann’s date of birth and municipality finds at most two women, and the diagnosis points to the right one. The copy therefore needs a contract with the recipient.
-   For dashboards inside the company, a mask at query time can be enough: at every query, the database hides the values a person may not see under their permissions. For outsiders this query mask is not enough, because anyone who writes their own queries can infer the hidden values, as Microsoft and Oracle state in their own documentation.
-   Instead of a full copy, a company can also pass on an extract of the data or an invented but realistic dataset. Even then, it has to check whether rare combinations of real information appear in it through which a person can be identified.
-   Anyone sending text to a language model in the cloud can put a proxy in between: a program that replaces names and numbers with placeholders before sending and puts them back into the answer. In our test with an invented doctor’s letter, the diagnosis went to the model unchanged. With patient rows, a proxy checks each value on its own and does not recognise which combination reveals a person. How many names and numbers a proxy misses depends heavily on whether the proxy is configured for Swiss formats such as the AHV number.
-   The least data leaves the company in two ways: the language model sees only the structure of the database, meaning table and column names without content, or the model runs in house.
-   Which route fits depends on the recipient. A company often needs two: a masked copy for development and, for working with real documents, a proxy or a model run in house.
-   To start: list all recipients of data and choose the fitting route for each. Check on twenty to fifty of your own examples how many items the detection tool misses. Extend the detection rules with every new database column.

The first two parts of this series showed how easily people can be recognised even in data without names, and what the law requires before such data leave the company. The series keeps to one example: a family practice in the Knonaueramt and its patient Hildegard Kaufmann, 87, from Maschwanden. The practice and the patient are invented. The technical question remains open: at which point in the data flow is it best to remove the personal data? There is no single answer, because the recipients differ. The vendor of the practice software needs a test database that behaves like the real one. An AI agent for the practice administration writes its own queries. A chat in which the doctor has a model draft referral letters receives whole letters, with names and diagnoses in the middle of sentences.

This article goes through the five points in order, with tools, strengths and limits. One graphic per point shows what stays in the practice and what goes outside. A matrix then shows which point suits which use case.

**Series · Anonymising data**

1.  [Data without names: pseudonymisation or anonymisation?](https://souverana.ch/en/insights/pseudonymisierung-anonymisierung/)
2.  [Anonymised data and AI: the legal position in Switzerland](https://souverana.ch/en/insights/anonymisierung-rechtslage-schweiz/)
3.  Protecting personal data in development, AI agents and chat (this part)

## Point 1: a masked copy of the database

Point 1: masked copy

In the practice

Practice database real values, stays in the practice

Anonymised here Anonymise once, before handing over

Masked copy substitute values instead of real names

Boundary

copy

Outside

Vendor’s developers work only with the copy

Only the masked copy goes to the vendor of the practice software. The real practice database stays in the practice.

Static masking creates a copy of the production database that holds substitute values. Names are replaced by other names, AHV numbers (the Swiss social security number) by other valid AHV numbers, and amounts are changed slightly. The copy goes to the development team, to a test system or to a service provider. Production stays untouched. In the copy for the vendor of the practice software, Hildegard Kaufmann has a different name and a different AHV number.

For PostgreSQL there are two widely used open-source tools. PostgreSQL Anonymizer, from the French company Dalibo, defines the rules directly in the database and can produce masked exports as well as static copies.[1] Greenmask works during export and can replace values so that the same original value receives the same substitute. That way the tables still fit together.[2] For larger environments with several database systems, commercial vendors such as Tonic, Perforce Delphix, DATPROF or Redgate offer test data platforms.[3–6]

The strength of this pattern: whoever receives the copy sees no real values in the columns covered by rules, regardless of the queries they write. The weakness: every column needs a rule. If a new column is added and nobody adds the rule, the new column reaches the copy unchanged.

### Why replacing columns one by one is not enough

The obvious route is to replace each column on its own, or to shuffle the values of a column between people. We measured this route and a consistent replacement with our own prototype on an invented practice database: 2,500 patients from the 14 municipalities of the Bezirk Affoltern, about 18,000 consultations with notes and as many invoices.[7] Hildegard Kaufmann is one of the patients. The table shows Hildegard Kaufmann and a second patient in three versions.

> **Interactive chart**
> 
> Interactive table with two patients of an invented practice database (real output of the Souverana prototype, 12 November 2026), each as original, with each column shuffled on its own, and consistently pseudonymised. Hildegard Kaufmann, AHV 756.4580.1234.27, 55.43 tariff points × 0.89 = CHF 49.35. Each column shuffled: name Til Winkler (a man's name in a woman's row), the AHV number of another real patient, 147.85 × 0.89 but amount 33.10, a note about another patient; the real note about Hildegard Kaufmann sits in another patient's record. Consistent: Wanda Berger, new valid AHV number, 107.72 × 0.89 = 95.85, note 'Kontrolle Wanda Berger, Herzinsuffizienz NYHA II … Tochter Ruth Berger begleitet die Patientin'. Second patient Hasan Herzog (accident, point value 1.00): consistent Léon Küng, the AHV number in the note is the same new number as in the column.

In the shuffled copy, the amount still matched tariff points times point value on only 0.06 per cent of invoices. None of the 1,539 email addresses still matched its name. Software that checks such values raises an alarm in the test, although the fault lies in the test data. Data protection weighs more: shuffling removes no value at all. All 2,500 real AHV numbers and 3,419 real names in the notes are still in the copy, only filed under other people.

In the consistently pseudonymised copy, the amount matched tariff points and point value on all of the roughly 18,000 invoices. All 1,539 email addresses matched the new name. All links stayed valid, and every consultation still hung on the same, renamed person.

### What a usable copy must deliver

The measurement yields five requirements. A company can demand them from a tool or from the service provider that produces the copy.

1.  **Same value, same replacement.** A patient number needs the same replacement in every table, otherwise consultations and invoices no longer fit together. The replacement is therefore computed from the real value and a secret key, usually with the HMAC method. A plain hash without a key is not enough: anyone with a list of possible AHV numbers recomputes the hashes and finds the real numbers. The FDPIC therefore recommends a hash with a secret key.[8] The key is kept separate from the copy.
2.  **One substitute person per human, in free text too.** Name, email address and mentions in notes get the same invented person. Of the 12,068 notes that name the patient’s own surname, none still contained the real surname in the copy.
3.  **Valid numbers.** AHV numbers and IBANs carry check digits that many programs verify on input. The substitute number is therefore produced with format-preserving encryption and a recomputed check digit. In the copy, all 2,500 AHV numbers were valid.
4.  **Treat related values together.** Tariff points, point value and amount are swapped as a package with another invoice of the same year and the same law (KVG or UVG). A person’s dates of birth and appointments are shifted by the same amount. This has a price: the amount then belongs to a different consultation, and for 4.6 per cent of consultations the shifted date moved into the future.
5.  **A check report after every run.** A program searches the finished copy for real values. The report shows where rules are missing. Our copy still contained 164 AHV numbers written without dots and 272 phone numbers written with 0 instead of +41, because the rules did not know these spellings, plus 116 full names of relatives. We built these cases into the invented notes on purpose to measure the limit of the rules. How often such spellings occur in real notes only the report on your own database shows. Such leftovers are found by a recognition model like the one in the proxy section below, or by a person who reads a sample.

The rules sit in a readable file, one rule per column, which a person approves. The same source, the same rules and the same key produce the same copy: two runs of our prototype produced a byte-identical database.

### Why the copy is still not anonymous

In the copy, Hildegard Kaufmann carries another name, yet she can still be found. Sex, date of birth and municipality stay in the copy because the vendor wants to test with realistic ages and places of residence. By sex, birth year and municipality, 86 per cent of patients in the copy sat in groups of fewer than five people, almost as many as in the original. The shifted date of birth helped little. Someone who knows that Hildegard Kaufmann was born on 14 March 1939 searches for women from Maschwanden with a date of birth up to 180 days before or after. We produced the copy with 1,000 different keys: every time, the search found one or two women. For all 1,000 keys, the only woman found with heart failure was Hildegard Kaufmann. Then there is the house number: the rule replaced the street name and kept the number. As the only woman in Maschwanden with this house number, Hildegard Kaufmann stayed unique.

Only coarser information changes that. With five-year age groups and the Bezirk instead of the municipality, nobody in the copy sat in a group of fewer than five. Many tests can live with this precision; analyses by municipality cannot. The first part of this series shows how to measure whether a coarsening is enough.

For the practice, which keeps the key, the copy remains personal data. Whether the copy also holds personal data for the vendor depends, as the second part explains, on whether the vendor can recognise people with reasonable effort. For Hildegard Kaufmann, sex, municipality, date of birth and diagnosis are enough. An employee of the vendor who knows Hildegard Kaufmann from the municipal newsletter or the neighbourhood finds the row. As long as that is possible, the copy belongs under a processing agreement under Art. 9 revFADP. Patient data are also subject to professional secrecy (Art. 321 of the Swiss Criminal Code). The second part describes which routes for passing them on remain.

## Point 2: a mask on every query

Point 2: mask at query time

In the practice

Practice database real values, no copy

Anonymised here Mask hides values at every query

XXXX

query

Practice team sees in the dashboard only what their role allows

Boundary

Outside

No copy leaves the practice. For outsiders the mask is not enough: anyone who writes their own queries can infer hidden values.

A mask directly on the real practice database hides, at every query, what a role may not see, for example the diagnoses at the reception desk.

Dynamic masking leaves the data unchanged. Only when a particular user runs a query does the database show a mask, such as “XXXX” instead of a phone number. SQL Server and Azure SQL call this Dynamic Data Masking, Oracle calls it Data Redaction, and PostgreSQL Anonymizer offers dynamic masking as well.

Dynamic masking is convenient because no copy is needed. The vendors themselves, however, describe its limit. Microsoft writes in its documentation that anyone allowed to run their own queries can infer the real data with skilful queries. According to Microsoft, masking prevents accidental exposure but does not protect against deliberate attempts to find out the values.[9] The documentation shows how this works with an example: a query with the condition “salary greater than 99,999 and less than 100,001” finds the person with exactly this salary, even though the salary is shown masked. Oracle states the same: Data Redaction does not protect against users who find out values through repeated queries.[10]

For a development team or an AI agent that writes its own queries, dynamic masking is therefore not sufficient protection. For a dashboard in which the practice team reads finished reports, dynamic masking can be enough. What a person may see on screen, they can still pass on, for example to a cloud model. Only the proxy at the fourth point protects against that.

## Point 3: a subset or synthetic data

Point 3: synthetic data

In the practice

Practice database real values, stays in the practice

Anonymised here Generator learns distributions and relationships

Invented records no real person

Boundary

invented

Outside

Vendor’s developers test with invented data

Only newly generated records go outside. A measurement still has to show whether rare real combinations reappear in them.

A test system often does not need all of the millions of records. A subset is enough as long as the links are correct: every consultation comes with its patient, every patient with their address. Tools such as the open-source program Jailer extract such a subset and keep the foreign keys intact.[11] The subset still has to be masked afterwards, because the subset contains real people.

Synthetic data go one step further. A generator learns the distributions and relationships of the real data and produces new records that are meant to match no real person. Well-known libraries are SDV from DataCebo, under a Business Source License, and the software development kit from MOSTLY AI, which has been under an open-source licence since 2025.[12, 13]

Synthetic data are well suited to development and testing. For analyses they are of limited use, because rare cases and individual values are not reliably reproduced. If a generator learns the original data too precisely, the generator can reproduce real records. A measurement is needed here too: do rare combinations from the original data reappear in the result?

## Point 4: a proxy in front of the language model

Point 4: proxy in front of the language model

In the practice

Doctor has a letter drafted

Kaufmann

Kaufmann

Anonymised here Proxy swaps names for placeholders, puts names back into the answer

Boundary

PERSON\_1

PERSON\_1

Outside

Cloud model sees placeholders instead of names

The cloud model receives the letter with placeholders instead of names and numbers. The proxy puts the real values back only in the answer.

In chat and document work, text goes to a language model. Proxies exist for this purpose: programs that sit between the application and the model. These programs detect names, numbers and addresses in the text, replace them with placeholders such as “PERSON\_1” and send only the cleaned text to the model. When the answer comes back, these programs put the original values back in.

A widely used open-source tool for this is Presidio. Presidio was developed at Microsoft and has continued as an independent community project since June 2026.[14] Presidio can encrypt the replaced original values and decrypt them later. By default, however, Presidio is configured for English. Other languages have to be set up separately.[15, 16] gheim is built specifically for Switzerland. The founder of Souverana developed this open-source tool, so we are not independent where gheim is concerned. gheim ships with a recognition model trained on texts in the four national languages.[17]

We show the round trip with Presidio, configured as in the project comparison further down: with the GLiNER recognition model and rules for Swiss formats. We tested two invented examples from the practice: a short doctor’s letter about Hildegard Kaufmann and three rows from the patient list. Because the recognition model does not decide the same way on every run, we ran each example ten times. The graphic shows what the proxy detected and sent to the model.

> **Interactive chart**
> 
> Interactive graphic with real output from Presidio 2.2.364 with the GLiNER recognition model and Swiss rules (ten runs on 12 November 2026, CPU). Doctor's letter about the invented patient Hildegard Kaufmann: name, date of birth, place of residence Maschwanden, the month Oktober, the word Patientin (female patient), AHV number and the practice phone number are replaced by placeholders such as <PERSON\_1> and <AHV\_1>, identically in all ten runs; the diagnosis heart failure goes to the model in clear text; the hand-written answer is restored with the original values. Three patient rows (number; date of birth; sex; municipality; diagnosis): in 8 of 10 runs only the dates of birth are replaced, municipality, sex and diagnosis remain; in 2 runs Maschwanden is additionally replaced twice as a name; questions about age can no longer be answered afterwards.

In the doctor’s letter, Presidio replaced name, date of birth, place of residence, AHV number and phone number. It also replaced the month “Oktober” and the word “Patientin” (female patient), which Presidio classed as a name. The diagnosis went to the model in clear text, because this configuration contains no rule for health information. The answer comes back with the original values. The patient rows show the limit. The proxy judges each value on its own. In 8 of 10 runs Presidio replaced only the dates of birth. Municipality, sex and diagnosis remained in place. In 2 runs Presidio additionally replaced “Maschwanden” twice, classed as a name. Whether a combination is rare and reveals a person is something the proxy cannot judge. For that, the proxy would need to know the whole table and the population of the municipality, for example that according to the Federal Statistical Office exactly one woman born in 1939 lives in Maschwanden. In addition, the model now lacks the date of birth: the model can no longer answer questions about age. Depending on its configuration, a proxy therefore replaces too little in tables, or so much that the analysis suffers. For tables, Presidio Structured, an add-on to Presidio, offers an approach that classifies columns by name and content.[18] Which combinations are rare, however, only a measurement like the one in the first part of this series can tell.

### How reliably the proxy finds personal data

A proxy only protects what its detection finds. A project comparison on 484 synthetic Swiss texts with 2,934 items of personal data such as names, AHV numbers, addresses and IBANs shows how much the configuration matters. Dates of birth are not counted.[19] The comparison is not public.

> **804 → 72** Undetected items of personal data out of 2,934 with Presidio, once in its default configuration and once with the GLiNER recognition model and rules for Swiss formats. Measured on 484 synthetic Swiss texts, excluding dates of birth.
> 
> Source: Project comparison, October 2026, not public

In its default configuration, Presidio missed just over one item in four. With the GLiNER recognition model and rules for Swiss formats such as AHV numbers, case numbers and dates of birth, it missed fewer than 3 in 100. The rules were written with knowledge of the test texts, so the second figure is probably flattering. For your own use, this means a company has to set up the rules for Swiss formats itself. Only a measurement on twenty to fifty of your own examples shows how much the proxy misses, and it belongs before real data pass through the proxy.

## Point 5: the model sees only the structure or runs in-house

Point 5: model run in-house

In the practice

Practice database real values

Kaufmann

Own model runs in-house

Kaufmann

Practice team access rights decide who sees what

Boundary

Outside

No model provider receives patient data.

The in-house model works with real values without patient data leaving the practice. Access rights decide who in the practice team sees what.

One variant: the model sees only the structure of the database, that is, table names, columns and examples with invented values. The model writes the query from this structure, and the query runs in the company’s own system. The values themselves stay in the database; the model sees only their structure. This variant suits analyses and dashboards.

The other variant: a [model run in-house](https://souverana.ch/en/insights/llm-selbst-hosten/) sees the real values. Because the data stay in-house, anonymisation for a model provider is no longer needed. Open models such as the Swiss [Apertus](https://souverana.ch/en/insights/apertus/) can run on the company’s own hardware or at a Swiss hosting provider. Anyone in the practice who accesses the model sees the real values. Access rights therefore determine who may use the model.

## Which point suits which use case

The five points can be combined, and in practice a company often needs two or three. The matrix shows our assessment for four typical use cases. Select a case to read the reasons.

> **Interactive chart**
> 
> Interactive matrix: five points (static masking of a copy, dynamic masking at query time, subset or synthetic data, proxy in front of the language model, metadata only or an in-house model) against four use cases (development and testing, AI coding agents, dashboards and analytics, chat with documents), each rated as fitting, fitting with limits or not fitting, with a reason. Development and testing: masked copy and synthetic data fit, dynamic masking does not. Chat with documents: proxy and in-house model fit.

Tools that assess the risk of re-identification check whether a cleaned copy or an export is anonymous enough. The open-source program ARX supports, among other things, k-anonymity, l-diversity and differential privacy.[20] The R package sdcMicro comes from official statistics and estimates the risk that individual people in a dataset can be recognised.[21] For text, Presidio remains a widely used open choice, with the limits described above.

## How to get started

1.  **List the recipients**: Note who receives data: development team, test system, AI agent, cloud model, dashboard. For each recipient, record whether the recipient can write their own queries.
2.  **Choose the point**: Use the matrix to choose the right point for each recipient. For developers and agents with query rights, choose a cleaned copy.
3.  **Measure on your own examples**: Put together twenty to fifty typical texts and tables with invented values and check what the tool detects. Test Swiss formats such as AHV numbers, case numbers and dates of birth in particular.
4.  **Maintain the rules**: With every new column and every new document type, extend the rules and repeat the measurement.

Do you want to use AI on customer data and need the architecture in which developers, agents and models see only what they need?

[AI architecture & solution selection](https://souverana.ch/en/leistungen/ki-architektur/)

## Sources

[1] Templ, Matthias. «sdcMicro: Statistical Disclosure Control Methods for Anonymization of Data and Risk Estimation». 12 June 2026. [cran.r-project.org/package=sdcMicro](https://cran.r-project.org/package=sdcMicro). Open Source, GPL-2.

The author

Joel Barmettler

AI Architect · Souverana, Zurich

Joel Barmettler guides Swiss companies from AI strategy to integration: sovereign, confidential and production-ready. He built the Swiss AI Hub as its architect and today co-owns its architecture; he personally leads every Souverana mandate. Mandates from one-person firms to Fortune 500 corporations.

[Book an intro call](https://meet.brevo.com/joel-barmettler/30-minute-meeting) [More about Souverana](https://souverana.ch/en/) [LinkedIn](https://www.linkedin.com/in/joel-barmettler-b9ab361b7)

## Frequently asked questions

What is the difference between static and dynamic data masking?

Static masking creates a copy of the database in which the real values are replaced. Dynamic masking leaves the data unchanged and hides values only at query time, for particular users. Microsoft and Oracle write in their documentation that users with their own query rights can infer masked values through targeted queries.

Can I use real production data for testing?

With personal data, only if the processing is permitted for that purpose and the test system is as well protected as production. A masked copy with valid formats or a subset with synthetic values can replace the real data. Tools such as PostgreSQL Anonymizer or Greenmask produce such copies so that the same original value is replaced the same way everywhere. This is an assessment, not legal advice.

Is a pseudonymised test database anonymous?

Usually not. Pseudonymisation replaces names and numbers; attributes such as date of birth, sex and municipality remain. In a Souverana measurement on an invented practice database, 86 per cent of people in the copy sat in groups of fewer than five by sex, birth year and municipality. Anyone who needs anonymity has to coarsen these attributes and measure the result.

Does Presidio detect German and Swiss personal data?

Presidio, a widely used open-source tool for detecting personal data, is designed for English in its default configuration. Users have to set up other languages and Swiss formats such as AHV numbers themselves. In a project comparison on 484 synthetic Swiss texts, Presidio with Swiss rules and the recognition model GLiNER detected around 97 per cent of the personal data, dates of birth not counted.

What does a proxy in front of a language model such as ChatGPT do?

The proxy detects names, numbers and addresses in the text, replaces them with placeholders such as <PERSON\_1> and sends only the cleaned text to the model. In the answer, the proxy puts the original values back. With running text this works well. With table rows, the proxy judges each value on its own. Whether a combination such as date of birth, sex and municipality reveals a person is something the proxy cannot detect.

## Glossary

-   **Masking**: Individual values are hidden or falsified, such as «Ke\*\*\*» instead of «Keller» or an invented phone number. Masking is a technique; whether the result is anonymous or only pseudonymous depends on the remaining columns.
-   **Personal data**: Any information relating to an identified or identifiable person, so customer records, HR files or even an email address. As soon as such data is involved, the revFADP applies.
-   **Open source (AI)**: More than open weights: the training code and details of the training data are disclosed too, under a free licence. The Open Source Initiative published a definition for this in 2024. The Swiss Apertus model meets it; many models marketed as "open" only partially do.
-   **Pseudonymisation**: Names and numbers are replaced by substitute values and the mapping is kept separately. Anyone holding the key, or finding the person through other attributes, can re-link them. Pseudonymised data therefore usually remain personal data.
-   **HMAC**: A check value computed from a value and a secret key. The same value and the same key always give the same result. Without the key, the original cannot be recovered even with a list of possible values.
-   **FDPIC (EDÖB)**: The Federal Data Protection and Information Commissioner, Switzerland's federal supervisory authority. It can conduct investigations and issue rulings; fines are imposed by the cantonal criminal authorities.
-   **Format-preserving encryption**: Encryption that keeps the format: nine digits become nine digits again. Numbers such as the AHV number stay valid for software that checks their format.
-   **Recognition model (NER)**: Named entity recognition: a small AI model that marks which words in a text are names, places, numbers or other personal data. It generates no text and runs without a graphics card.
-   **Processor**: A service provider that processes personal data on behalf of, and under the instructions of, the controller, such as a cloud or AI provider. Art. 9 of the revFADP ties the handover to conditions.
-   **revFADP (revDSG)**: Switzerland's revised Federal Act on Data Protection, in force since 1 September 2023. It governs how companies may process personal data, and applies to AI use exactly as it does to any other processing.
-   **Professional and official secrecy**: The criminally protected duty of confidentiality of authorities (official secrecy, Art. 320 of the Swiss Criminal Code) and a list of professions named in the law (Art. 321), such as lawyers, doctors and pharmacists. It applies independently of data protection law and reaches further. Banking secrecy sits separately in the Banking Act.
-   **Synthetic data**: Artificially generated records that reproduce the statistical properties of real data without containing real people. A generator that learns too precisely can, however, reproduce real records.
-   **Anonymisation**: Changing data so that no person can be identified with reasonable effort any more, not even indirectly. Anonymous data are no longer personal data; the revFADP does not apply to them.
-   **Re-identification**: Finding a person again in data from which name and numbers were removed, usually by linking it to a second source that contains names.
-   **k-anonymity**: A dataset is k-anonymous when every combination of quasi-identifiers occurs at least k times. With k = 5, every person disappears in a group of at least five.
-   **l-diversity**: An extension of k-anonymity: within each group at least l different values of the sensitive attribute must occur, such as different diagnoses. Otherwise the group reveals the attribute even if it does not reveal the person.
-   **Differential privacy**: A mathematical protection measure for analyses: results receive precisely calibrated noise, so they come out almost the same whether or not a given person is in the data.
