feat(server): data-subject delete + export endpoints (ADR-0004)#64
Merged
Conversation
- DELETE /v1/identity/:id (GDPR Art. 17): erases the identity; snapshots, drifts, risk assessments, cluster merges, and account links cascade (ON DELETE CASCADE). Strictly key-gated — requireProjectRead 401s a non-GET without a key, so an admin session can never erase. 404 on unknown id, 204 on success. - GET /v1/identity/:id/export (GDPR Art. 20): the full bundle — identity + snapshots (with consent provenance + host()-stripped IP) + drifts + risk assessments + linked accounts. Readable by key or admin session like the other reads. - Integration tests: export shape, delete cascade (snapshots gone, GET 404), key-gating (401 without key), 404 on unknown id.
This was referenced Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Third PR of the Consent & Data-Lifecycle workstream (ADR-0004).
What
DELETE /v1/identity/:id(GDPR Art. 17 — erasure): deletes the identity; snapshots, drifts, risk assessments, cluster merges, and account links all cascade (ON DELETE CASCADEonidentity_id, verified across migrations 001–004). Project-scoped.204on success,404on unknown id.GET /v1/identity/:id/export(GDPR Art. 20 — portability): one JSON bundle — identity + snapshots (incl. consent provenance,host()-stripped IP) + drifts + risk assessments + linked accounts.Security
requireProjectReadreturns401for any non-GET without an API key, so erasure is strictly key-gated — an admin session can never reach the delete path. Export is a read, so it's reachable by key or admin session like the other read routes.Tests
204→ subsequent GET404→ snapshots cascaded to 0;DELETEwithout a key401; unknown id404. Full events integration suite: 19 passing locally.