In our engineering work, we saw firsthand how difficult enforcing data retention policies is in practice. While compliance policies are usually documented, actual execution often depends on manual, irregular interventions or fragile scripts. In the projects we worked on, the available tooling covered data governance and cataloging. Any kind of automated execution at the database layer was missing. That’s why we built Doppelt.
Doppelt is an open-source tool designed to enforce data retention policies on relational databases. Operating entirely on-premise, it identifies records reaching the end of their designated retention periods and either deletes them or transforms specific columns. Crucially, Doppelt can train a generative synthetic data model prior to record deletion, preserving the statistical utility of the dataset for downstream analysis while removing the underlying personal identifiers.
Our prior work developing privacy-enhancing technologies (PETs), specifically synthetic data models and de-identification systems, directly shaped Doppelt's design. Synthetic data is produced by a generative model trained on original datasets. The output mimics the statistical properties of the original population without directly corresponding to real individuals. Despite all its benefits, synthetic data is not anonymous by default (see aside "Legal status of synthetic data and training artifacts").
Legal status of synthetic data and training artifacts
Synthetic data cannot be considered anonymous by default, and its re-identification risk must be formally evaluated before it can serve as a substitute for primary data.
Similarly, training a generative model from personal data, like the ones used to produce synthetic data, constitutes a distinct data processing activity. Anonymization processes are considered "compatible further processing", provided the execution reliably yields truly anonymous output1 2.
Furthermore, the generative model artifact itself requires governance: a trained model contains parametric representations of its training data. Unless it is demonstrated that personal data cannot be extracted from the model via reconstruction or membership inference attacks, the model artifact itself must be treated as personal data3. In addition, if many historical models are kept, they remain bound to the retention schedules of their underlying training data. A historical model version trained on records that have since been purged must either pass the privacy gate independently or be decommissioned alongside the primary source records.
To complement synthesis, Doppelt supports column-level masking, hashing and encryption. These techniques reduce data exposure and produce pseudonymized data. Pseudonymized data remains personal data4. For the controller holding the pseudonymized records, the storage limitation principle still applies5.
Open-source components for data synthesis and pseudonymization already exist (Synthetic Data Vault6, Mostly AI, synthpop and synthcity on the synthesis front, and Presidio, GLiNER and OpenAI Privacy Filter on the PII detection and pseudonymization front, to name a few). However, applying them to a compliance task requires substantial engineering effort stitching different components together: policy logic, scheduled execution, and safety checks prior to any irreversible action. Doppelt is designed to handle that operational layer for automated data retention. Released under the MIT license, it offers a lightweight framework for compliance: a way to declare, test and enforce policies, running alongside the database.
The business case for automated retention
In 2025, 32 European data protection authorities conducted a coordinated enforcement action7 on how controllers implement the right to erasure. Their report, based on responses from more than seven hundred controllers, found inconsistent practices in defining retention periods and in deleting data from backup systems. The authorities also noted that some controllers relied on ineffective anonymization techniques as a substitute for deletion.
The core legal obligation behind retention management is the storage limitation principle. Personal data must not be kept in identifiable form longer than necessary for the purpose of the processing5. Controllers must therefore erase personal data without undue delay under specific conditions. The most common are:
- Purpose change: when a controller wants to use existing data for a new purpose, it must assess whether that purpose is compatible with the purpose for which the data was collected1.
- Consent withdrawal: when a data subject withdraws consent, processing based on that consent must stop8. Processing carried out before the withdrawal remains lawful9.
The end of a commercial contract shows how erasure duties and statutory retention obligations interact. Once the contract ends, data collected to perform it is no longer necessary for that purpose. Specific subsets must still be kept to meet legal record-keeping obligations. These obligations exempt the data from erasure10.
For example, German commercial and tax law require organizations to keep financial statements for ten years, accounting vouchers such as invoices for eight years11, and commercial correspondence for six years12. Data kept under these obligations remains subject to the core GDPR principles7, including purpose limitation and storage limitation.
This creates a matrix of overlapping, field-level deadlines. A single customer record may contain attributes to delete when the contract ends, fields to keep for six years, and financial entries to keep for eight or ten years. Each deadline is triggered by a different date.
Industry standards recommend formalizing these rules in a "retention concept"13. Enforcing such granular concepts manually or through ad-hoc queries across production databases is error-prone and does not scale. Doppelt translates retention concepts into policies that are evaluated and enforced automatically at the database layer.
How Doppelt works
Doppelt reads declarative retention policies from a YAML configuration file and applies them to the relevant tables in a relational database. Each policy specification defines the database connection parameters, the target table, a declarative retention rule, and the execution action triggered once a record exceeds its retention boundary.
Consider an employees table containing personal data:
Table: employees
| id | name | last_access |
|---|---|---|
| 1 | Employee A | 2019-03-15 09:12:00 |
| 2 | Employee B | 2026-08-31 17:40:00 |
To enforce a policy requiring complete record erasure three years after the last recorded user interaction, the corresponding YAML declaration is configured as follows:
policies:
- table: "employees"
connection:
url: "sqlite:///employees.db"
retention: "3 years after last_access"
delete_row: true
When evaluated, Doppelt calculates record eligibility based on the
last_access timestamp. In this example, row 1 exceeds the three-year
threshold and is purged, while row 2 remains active. To ensure predictability
and prevent ambiguous policy definitions, the retention directive uses
the following grammar: <number> <unit> after <column_name>.
Column-level de-identification
While deletion represents the simplest action, compliance requirements often demand preserving non-identifying fields while redacting sensitive attributes. Doppelt supports granular column transformations prior to, or instead of, full row erasure, using masking, hashing, and encryption strategies:
policies:
- table: "employees"
connection:
url: "sqlite:///employees.db"
retention: "3 years after last_access"
primary_key: "id"
columns:
name:
strategy: encrypt
encryption_key: "env:DOPPELT_AES_KEY"
last_name:
strategy: hash
hmac_key: "env:DOPPELT_HMAC_KEY"
phone:
strategy: mask
mask: "partial:7:0:*"
In this example, Doppelt encrypts the name attribute, hashes the last_name
column, and keeps only the first seven characters of the phone number,
replacing the rest with asterisks, once the retention period has ended.
These transformations operationalize the data minimization principle5. The resulting output represents pseudonymized data, which remains within the scope of personal data for the controller holding the decryption or keying material144.
The security guarantees of pseudonymization depend heavily on implementation details. Unsalted or simple cryptographic hashes of predictable strings (such as names or phone numbers) are highly vulnerable to pre-computation and dictionary attacks15. Aligning with European Data Protection Board (EDPB) recommendations16, Doppelt mandates keyed hash functions (HMAC) and authenticated encryption algorithms to prevent reverse-engineering of hashed values without authorization.
Retention schedules
This flexibility allows for different retention schedules, for example:
- Contract termination (T+0): non-essential operational fields are pseudonymized or masked to minimize exposure.
- Statutory expiration (T+6 / T+10 years): the underlying record is hard-deleted once tax and commercial retention windows expire.
Operational modes and auditability
The principal execution model of Doppelt is an on-demand CLI. This mode is designed for running with a scheduler like cron, or for manual operation:
doppelt execute --config /path/to/policy.yaml
The user can append the --dry-run flag to evaluate policy impacts and
affected rows without committing mutations to the target database. We're aiming
to release a second operational mode very soon, adding the ability to run as an
automated background service, evaluating active retention policies on schedule.
Doppelt generates audit logs capturing every deletion and column transformation. These logs, when immutable, provide the audit evidence required to satisfy the accountability principle17 of the GDPR.
Using synthetic data
The policies above act on individual rows and columns. Synthetic data works at the level of the whole table. Doppelt can train a generative model on the table and use it to produce new records with the same statistical properties. The original rows are deleted when their retention period ends. The statistical value of the table remains available through the synthetic data. Synthetic data support didn't make the cut for this release. We are aiming to release it soon. This and the next two sections describe its design.
A basic policy looks as follows:
policies:
- table: "employees"
connection:
url: "sqlite:///employees.db"
retention: "3 years after last_access"
synthesize:
schedule: weekly
preprocess:
zip: "partial:3:0:*" # keep only the area
ssn: exclude # never feed to model
delete_row:
conditions:
synthetic_data_exists: true
Under this policy, Doppelt retrains the generative model weekly using the current table state.
Preprocessing and risk mitigation
Prior to model training, direct identifiers undergo explicit preprocessing:
- Exclusion: dropping direct identifiers (e.g., the social security number,
ssn) entirely removes them from the model's training set, preventing the model from learning or generating those values. - Partial masking: keeping only part of a value (e.g., the first three
digits of a US
zipcode, which identify the area served by one mail-processing center) lets the model learn how records spread across areas, and how that relates to other columns, without seeing the full values.
Excluding direct identifiers is the safest default. However, quasi-identifiers, can still create rare feature combinations (such as an unusual job title paired with a specific zip code) that generative models might memorize and reproduce18.
To bound this risk, generative models can be trained with differential privacy (DP)19 guarantees, establishing a mathematically provable upper limit on individual record exposure.
Training a generative model on personal data constitutes a distinct data processing activity, compatible with the original purpose under certain conditions (see aside "Legal status of synthetic data and training artifacts").
Safety gates
To prevent accidental data loss, Doppelt uses an operational gate: primary
records selected by the retention rule (e.g., 3 years after last_access) are
purged only after a validated synthetic model artifact has been generated
and stored.
Beyond verifying model existence, true anonymization requires evaluating residual privacy risk prior to primary record deletion. Doppelt integrates a privacy gate that evaluates synthetic output against empirical metrics, such as the three primary criteria20 defined by the European regulatory framework:
- Singling out: the ability to isolate a specific individual within the dataset.
- Linkability: the ability to link two or more records belonging to the same data subject.
- Inference: the ability to deduce sensitive attribute values with high confidence.
Using attack-based evaluation frameworks21 like Anonymeter, which we developed, Doppelt can measure these risk vectors against the source data prior to record deletion. Because acceptable risk thresholds vary by business context and data sensitivity, risk parameters should be established in coordination with the organization's Data Protection Officer (DPO) or compliance team.
Starting small and scaling up
Automated deletion in a production database carries operational risk. Each organization also has its own systems, data models and retention rules. Doppelt runs entirely on-premise, and no data leaves the organization's infrastructure. It also supports a gradual rollout. Besides the dry-run option described above, a policy can run in notification mode. In this mode, Doppelt neither deletes nor transforms any data.
policies:
- table: "employees"
connection:
url: "sqlite:///employees.db"
retention: "3 years after last_access"
notification:
channel:
type: stdout
Doppelt evaluates the policy as usual and reports every row that falls outside the retention period. Webhook and email channels are also available. This mode lets a team compare the results with its own retention schedule before any data is changed. It can also serve as an ongoing control, for example to report retention findings to the data protection officer.
Looking ahead
Doppelt turns documented retention rules into policies that are checked against the data. Teams that do not use its deletion or de-identification features can still use it to monitor retention periods in one place.
Planned extensions include:
- Data subject requests: individuals can request access to their data or its erasure at any time, independently of retention periods22 23. Controllers must respond within one month, extendable by two further months where necessary24. The EDPB found7 that some controllers lack internal procedures for handling such requests. Handling requests and retention periods in the same tool gives one place to manage both obligations.
- Integration with data catalogs: organizations that maintain a data catalog already document their data categories, owners and processing purposes. This metadata can serve as a starting point for retention policies.
Doppelt will be published at github.com/Modal-Resonance/doppelt (coming soon) under the MIT license. In the meantime, we welcome feedback.
Modal Resonance supports organizations with retention and deletion concepts, privacy engineering, and the evaluation of synthetic data, including the calibration of privacy gates. For questions, contact us.
Footnotes
-
According to the EDPB and legacy Article 29 Working Party guidance. ↩
-
European Data Protection Board, Opinion 28/2024 on certain data protection aspects related to the processing of personal data in the context of AI models, adopted on 17 December 2024. ↩
-
Under Article 4(5) GDPR, pseudonymized data remains personal data for any party that holds the means to re-identify the data subject, including the controller (EDPB Guidelines 01/2025 on Pseudonymisation). In September 2025, the Court of Justice of the EU held that the assessment can differ for a recipient without reasonable means of re-identification. See also the AEPD and EDPS joint paper on 10 misunderstandings related to anonymisation. ↩ ↩2
-
Strictly speaking, Synthetic Data Vault is source-available rather than open source: it is released under the Business Source License 1.1, which forbids offering it as a commercial synthetic data service. ↩
-
European Data Protection Board, 2025 Coordinated Enforcement Action: Implementation of the Right to Erasure by Controllers, adopted on 10 February 2026. ↩ ↩2 ↩3
-
For banks, insurers and investment firms, the ten-year period for accounting vouchers still applies. EY, Längere Aufbewahrungsfristen bei Banken, Versicherungen und Wertpapierinstituten, EY Steuernachrichten. ↩
-
§ 257 HGB and § 147 AO, as amended by the Fourth Bureaucracy Relief Act (BEG IV) of 29 October 2024. ↩
-
DIN 66398:2016 (behind paywall), Leitlinie zur Entwicklung eines Löschkonzepts mit Ableitung von Löschfristen für personenbezogene Daten; ISO/IEC 27555:2021 (behind paywall), Information security, cybersecurity and privacy protection: Guidelines on personally identifiable information deletion. ↩
-
AEPD and EDPS, 10 Misunderstandings Related to Anonymisation, 2021. ↩
-
ENISA, Pseudonymisation Techniques and Best Practices, November 2019. ↩
-
European Data Protection Board, Guidelines 01/2025 on Pseudonymisation, adopted for public consultation on 16 January 2025. ↩
-
T. Stadler, B. Oprisanu and C. Troncoso, Synthetic Data: Anonymisation Groundhog Day, 31st USENIX Security Symposium, 2022. ↩
-
National Institute of Standards and Technology, Guidelines for Evaluating Differential Privacy Guarantees (NIST SP 800-226), March 2025. ↩
-
Article 29 Data Protection Working Party, Opinion 05/2014 on Anonymisation Techniques (WP216), April 2014. ↩
-
M. Giomi, F. Boenisch, C. Wehmeyer and B. Tasnádi, A Unified Framework for Quantifying Privacy Risk in Synthetic Data, Proceedings on Privacy Enhancing Technologies, 2023(2). ↩