Retention and erasure
Retention policies delete rows on a schedule, per table, schema or object type, following lineage to every table built from them. Erasure requests remove one person's records everywhere the platform holds them, after a second officer approves, within a deadline. Both go further than a delete: they cut each changed table's history, so the rows are gone from older versions and the change feed too, and both keep the hash-chained audit log whole
In the platform today
- Retention and erasure run in the platform service with tests, configured under
retention:anderasure:inontology.yaml - A retention pass marks matching rows in
ops.retention_marks, purges them aftergraceDaysin main, in every open data branch and in folders closed branches left, syncs object types and cuts each purged table's history; passes are inops.retention_passesand audited asretention.pass - The timer runs when switched on, a service setting, and
POST /api/v2/retention/policies/{id}:previewand:runwork on demand - Erasure requests are filed at
POST /api/v2/erasure/requests, planned at once, approved by a second officer and kept inops.erasure_requests; audit entries name the person through subject references sealed under per-person keys, which erasure destroys - Both reach the lake, its data branches and exports
- Backups, object storage versions, lakeFS branches, copies people took and systems that received writeback follow their own lifecycle, and every erasure plan lists them
- Administrator, or a group in
retention.managers, to preview and run passes and undo marks - Administrator, or a group in
erasure.officers, to file, approve and read erasure requests; approval needs a second person - The table's owner group, or an administrator, to exempt a table from retention
- Lineage recorded by pipeline builds, so policies and erasure plans can follow it
Retention policies
retention:
managers: [privacy] # besides administrators: preview, run passes and undo marks
graceDays: 7 # marked rows wait this long before they are purged
every: 1d # at most one pass per policy in this time
maxTablesPerPass: 20 # tables purged in one pass; the rest wait for the next
policies:
- id: old-orders
name: Orders after seven years
table: raw.shop_orders
deleteAfter: { days: 2555, column: order_date }
- id: loyalty
objectType: loyalty-member
deleteAfter: { days: 730, column: lastVisit } # column names a property
- { id: history, schema: gold, keepVersions: { days: 30 } }
- id: trial
table: raw.trial_import
deleteOn: { date: 2027-01-31 } # optional where:
followLineage: false
exempt:
gold.daily_totals: Totals with no personal data
A policy names one table, every table of one schema, or one object type: its backing dataset, or its object table when it has none, with column naming a property. Each policy has one rule
| Rule | What it does |
|---|---|
deleteAfter: { days, column } | Deletes rows whose column is older than that many days, at a cutoff fixed on the platform clock when the pass marks them |
deleteOn: { date } | Deletes every row from that date on, or only the rows matching where: |
keepVersions: { days } | Deletes no rows; cuts history so only the last N days of versions and change feed are kept |
What a policy covers
With followLineage, the default, a policy follows the catalogue's lineage downstream, through pipeline steps, recorded builds and backing datasets to object tables, to every derived table and object table. For deleteAfter a derived table must have the column; one that hasn't is listed as not covered. For deleteOn without where, a derived table is emptied only when all its inputs are covered. Upstream tables are never followed, and the preview warns when a target is rebuilt from tables the policy doesn't cover, since a full rebuild would bring the deleted rows back
The audit log, keys, the platform's own bookkeeping and the privacy tables are never covered. A table can be exempt, with a reason, in retention.exempt or through POST /api/v2/retention/exemptions by its owner group or an administrator
Passes, marks and the grace period
- Purge what is due. Marks whose grace period is over are purged: the rows matching the mark's cutoff are deleted in main, in every open data branch's copy and in the folders closed branches left behind. Rows updated past the cutoff meanwhile stay
- Sync and cut. Object types are synced, then each purged table's history is cut
- Mark. For each covered table with no open mark, the rows matching the policy now are counted and recorded in
ops.retention_markswith the time they may be purged. Marking changes no row
During the grace period a manager can undo a mark with POST /api/v2/retention/marks/{id}:undo, and nothing is deleted. A policy runs at most once per every, and Run now at most once a minute. The timer, when switched on, runs due policies every 3,600 seconds by default, a service setting
Cutting history
A Delta delete only writes a new version: older versions keep the rows in their data files, the change feed holds the deleted rows, and the log keeps column statistics of every file. Cutting history vacuums the removed files, writes a checkpoint, removes log entries older than the cut and deletes change feed files no kept entry names. Afterwards the table can't be read at versions before the cut, and a change feed reader whose cursor is older resumes from the oldest version kept
Before main's history is cut, every open branch that reads the table through to main copies it in, and its own copy then gets the same delete and cut
Erasure requests
An erasure request removes one person's records, for a request under PIPEDA or Quebec's Law 25. A subject says what kind of person a request can name and where their identifiers live
erasure:
officers: [privacy] # besides administrators: file, approve and read requests
deadlineDays: 30 # from filing; one extension of the same length, with a reason
subjects:
customer:
name: Customer
identifiers: [email, accountNo] # what a request names the person by
# per object type, the property holding each identifier
types:
customer: { email: email, accountNo: accountNo }
order: { email: customerEmail }
follow: [order-customer] # objects linking to a found object are erased with it
# an identifier inside another record: keep and list it, or clear
references: keep
audit:
fields: [email, customerEmail] # audit detail fields written as subject references
keys: [customer] # object types whose key is written as one
Filing and the plan
An officer or administrator files {subject, identifiers, reason, reference}, such as {"subject": "customer", "identifiers": {"email": "j.doe@example.com"}}. The deadline is deadlineDays later on the platform clock, with one extension of the same length and a reason, and the request is overdue once it passes unfinished. The platform builds the plan at once, and again just before it runs
| Part of the plan | What happens |
|---|---|
| Objects | Every object of the subject's types whose property equals an identifier, sealed ones by their tag; then the other identifiers those objects hold, so an email finds the account number; then objects linking to them through follow |
| Tables | Each found object's row in its object table and backing dataset. Then the person's lineage: rows in the tables their backing datasets are built from, and built into, where a key or identifier column, or any text column, holds one of theirs, are deleted |
| References in other records | A text column elsewhere equal to an identifier, such as who reported a defect, is listed and kept, or set to null with references: clear. No other record's row is deleted for a reference |
| Untraced and exempt | Tables built from the person's raw tables that hold none of their keys, such as an aggregate, are listed for a person to check. Tables exempt from retention are listed and left alone |
| The operational record | Active edits and edit history are deleted. Action log entries, proposals, writeback payloads and undo records are kept with parameters, titles, rationale and payloads cleared. Notifications about them, and history tables that mention an identifier, are deleted; other ops rows are listed as retained for review |
| Copies | Open data branches, folders closed branches left and each export whose tables are touched, with its Delta copy and every dated Parquet file rewritten |
| The audit log | Entries naming the person in plain text are counted and kept; their subject references are shredded |
| Not reached | lakeFS branches, backups and object storage versions, copies people took of exports, downloads or shared tables, and systems that received writeback |
Approval and completion
A second officer, never the filer, approves with POST /api/v2/erasure/requests/{id}:approve. The platform then
- Deletes and clears everywhere the plan lists, and syncs objects
- Cuts the history of every changed table and rewrites export copies
- Shreds the subject references
- Keeps a completion record with counts per table and copy, and what was retained and why, with no identifier in it
The request's identifiers and plan are sealed under its own subject key, shredded at completion, so afterwards the request shows its status, dates, people, counts and the subject reference only. Statuses are open, approved, completed, failed (run again with :run), rejected and withdrawn
The audit log and sealed properties
The audit log is hash-chained, so its rows are never changed. From the moment a subject is configured, the detail fields in audit.fields and the keys of audit.keys types are written as sealed subject references, each sealed with AES-256-GCM under a key of its own. Erasure deletes those keys and their history, so the references can be neither opened nor linked to the person again, and the chain still verifies. Entries written before the subject was configured, and fields or keys it does not list, keep plain text, and the plan counts them
Rows holding a found object's sealed properties are deleted like any other. Each erased object is also recorded by keyed hash, and the platform refuses to open any sealed value bound to it again, so a restored backup or a lakeFS branch reads it as null there. The access label's key is kept, so this is a refusal on the platform, not crypto-shredding of the property
API
| Endpoint | Does |
|---|---|
GET /api/v2/retention | Policies, what each covers, last pass, next run and open marks |
POST /api/v2/retention/policies/{id}:preview, :run | What a pass would mark, purge or cut now, without changing anything; or a pass now |
GET /api/v2/retention/policies/{id}/passes | Recent passes |
GET /api/v2/retention/marks?status=marked, POST …/marks/{id}:undo | Marks, and undoing one during its grace period |
POST /api/v2/retention/exemptions, /exemptions:remove | Exempt a table with {"table", "reason"}, or remove the exemption |
GET /api/v2/erasure/subjects | The subjects a request can name |
GET and POST /api/v2/erasure/requests | Every request, for officers; file one |
GET /api/v2/erasure/requests/{id} | One request, with its plan while it has one |
POST …/requests/{id}:plan, :approve, :reject, :withdraw, :extend, :run | Build the plan again, decide, withdraw (the filer), extend once, or run a failed request again |
| Area | Audit events |
|---|---|
| Retention | retention.pass, retention.preview, retention.mark_undone, retention.exempted, retention.exemption_removed |
| Erasure | erasure.filed, erasure.planned, erasure.extended, erasure.approved, erasure.completed, erasure.failed, erasure.rejected, erasure.withdrawn |
Limitations
- Retention and erasure reach the lake, its data branches and exports. lakeFS branches keep their own commits until lakeFS garbage collection, and backups and object storage versions follow the bucket's lifecycle rules
- A purge cuts a table's whole history, not only the purged rows', so time travel on that table starts again from the cut
- Upstream tables are never followed. A policy on a derived table whose source keeps the rows is undone by a full rebuild, and the preview says so
- Subject references cover audit entries written after the subject is configured. Configure subjects before go-live
- Systems that received writeback keep their own records, outside the platform; every erasure plan names them