feat(purge): erase the tenant's Prüfwerk data before deleting it #154

Merged
sharang merged 1 commits from feat/purge-pruefwerk-data into main 2026-11-30 20:23:47 +00:00
Owner

Purging a tenant left its Prüfwerk database and files behind (found in the entry-offer fulfilment research: needed before the first 90-day deletion).

What changes

  • DELETE /v1/admin/tenants/{id} first calls Prüfwerk DELETE /api/v1/platform/tenants/{id}/data with the registry's service token and {"confirm": "<tenant id>"}.
  • Any failure → 502 pruefwerk_error, nothing removed; staff retry (the Prüfwerk call is idempotent).
  • No Prüfwerk in the environment's catalog (on-prem without it) → step skipped, audit says not_configured.
  • tenant.purged audit metadata: pruefwerk_data and pruefwerk_files_not_removed (only when > 0).

Checked with the Prüfwerk session (code v0.4.19)

  • A tenant Prüfwerk never provisioned answers 200 {"status":"deleted",…} (DB created then dropped, no files).
  • tenant-registry-svc-stage / -prod are in PLATFORM_ALLOWED_CLIENTS for stage and prod; it is the same client the registry already uses for /targets.

Tests: TestPurgeErasesPruefwerkData (failure keeps everything, request shape, audit, no-catalog skip); full suite green locally. Nothing was purged on stage to try it.

🤖 Generated with Claude Code

Purging a tenant left its Prüfwerk database and files behind (found in the entry-offer fulfilment research: needed before the first 90-day deletion). **What changes** - `DELETE /v1/admin/tenants/{id}` first calls Prüfwerk `DELETE /api/v1/platform/tenants/{id}/data` with the registry's service token and `{"confirm": "<tenant id>"}`. - Any failure → 502 `pruefwerk_error`, nothing removed; staff retry (the Prüfwerk call is idempotent). - No Prüfwerk in the environment's catalog (on-prem without it) → step skipped, audit says `not_configured`. - `tenant.purged` audit metadata: `pruefwerk_data` and `pruefwerk_files_not_removed` (only when > 0). **Checked with the Prüfwerk session (code v0.4.19)** - A tenant Prüfwerk never provisioned answers 200 `{"status":"deleted",…}` (DB created then dropped, no files). - `tenant-registry-svc-stage` / `-prod` are in `PLATFORM_ALLOWED_CLIENTS` for stage and prod; it is the same client the registry already uses for `/targets`. **Tests**: `TestPurgeErasesPruefwerkData` (failure keeps everything, request shape, audit, no-catalog skip); full suite green locally. Nothing was purged on stage to try it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
sharang added 1 commit 2026-11-30 20:14:29 +00:00
feat(purge): erase the tenant's Prüfwerk data before deleting it
ci / shared (pull_request) Successful in 12s
ci / test (pull_request) Successful in 7m39s
ci / image (pull_request) Skipped
933d9d950b
Purging a tenant left its Prüfwerk database and files behind. The purge
now first calls Prüfwerk's DELETE /api/v1/platform/tenants/{id}/data with
the registry's service token (the client is already allowed on the
platform routes in stage and prod). Any failure answers 502
pruefwerk_error and removes nothing, so staff can retry; the call is
idempotent. Without Prüfwerk in the environment's catalog (on-prem
without it) the step is skipped. The tenant.purged audit event records
pruefwerk_data (deleted / not_configured) and files Prüfwerk could not
remove.

Needed before the first 90-day deletion of an entry-offer workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sharang merged commit cc12c6c810 into main 2026-11-30 20:23:47 +00:00
sharang deleted branch feat/purge-pruefwerk-data 2026-11-30 20:23:47 +00:00
Sign in to join this conversation.