Skip to content

feat(api): delete a dataset or purge an org, with a grace period, revoked keys and an audit row (#544) - #1389

Merged
athvin merged 1 commit into
mainfrom
feat/544-purge
Nov 29, 2026
Merged

athvin merged 1 commit into
mainfrom
feat/544-purge

Conversation

@athvin

@athvin athvin commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

Closes #544

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Two routes:

  • DELETE /v1/orgs/{org}/datasets/{ds} (admin).
  • DELETE /v1/orgs/{org} (operator).

Each flips the row to purging, after which every tenant route 404s it. Each queues a purge job that may not be claimed before the grace period ends (ER_PURGE_GRACE_HOURS, default 7 days, via not_before). An org purge revokes every key at request time. Both write an audit row and answer 202 with job_id and purge_after.

The dataset_purge and org_purge jobs are control tasks that remove what provisioning created:

  • Local mode: the data dir, catalog file and sidecars, config, and the dataset's directory.
  • Postgres mode: DROP SCHEMA … CASCADE on the DuckLake metadata schema, delete the S3 prefix (an empty prefix is refused), and DROP DATABASE for an org.

Why

#544: customer data deletion and offboarding had no path at all. Decisions: dataset delete is a customer admin action; org purge is operator-only; the grace period is 7 days; the default dataset is refused because it goes with its org; an operator still sees a purging org. A job refuses a row that is no longer purging, so cancelling within the grace period withdraws the request.

Proof

make check exit 0. New pg_purge (real Postgres, real executor, local mode):

  • data exists before the delete, and DELETE 404s the dataset at once and drops it from the listing;
  • the job removes the data and the directory;
  • deleting the default dataset is a 409;
  • the real grace period holds the job not_before for at least 6 days;
  • a tenant admin cannot purge the org (403);
  • after the purge request, keys are revoked at once (401), the operator sees purging, and the job removes the org workspace;
  • both actions are audited.

New statements: job/create/enqueue_deferred and api_key/update/revoke_all_for_org.

Risk & rollback

Additive routes and statements; nothing existing changes behaviour except that purging rows 404. Postgres mode is written but unexercised: on the deployed platform the job refuses because there is no provisioning profile and no S3 delete grant (#1380). Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:24d16c2e-fec6-49d8-9797-060338df4848 on brians-MacBook-Pro · 2026-11-29T05:06:10Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Discoveries

Measurements

Files

The interval cast in enqueue_deferred (make_interval(secs => $x::bigint)) is the same class of bug as #1383. The analyser gap is #1384.

🤖 Generated with Claude Code

…oked keys and an audit row (#544)

DELETE /v1/orgs/{org}/datasets/{ds} (admin) and DELETE /v1/orgs/{org}
(operator) flip the row to purging, after which every tenant route 404s
it, and queue a purge job that may not be claimed before the grace
period ends (ER_PURGE_GRACE_HOURS, default 7 days; the claim already
honours not_before). An org purge revokes every key at request time.
Both write an audit row and answer 202 with the job and purge_after.

The jobs (dataset_purge, org_purge) are control tasks, since they open
no lake. They remove what provisioning created, read from the dataset's
own env. Local mode removes the data dir, catalog file and sidecars,
config and the dataset's directory. Postgres mode drops the DuckLake
metadata schema, deletes the S3 data prefix (refusing an empty
prefix), and for an org drops the catalog database. Each job refuses
a row that is no longer purging, so cancelling within the grace
period withdraws the request. The default dataset is refused (it goes
with its org). An operator still sees a purging org through GET.

New statements: job/create/enqueue_deferred, api_key/update/
revoke_all_for_org. pg_purge proves the local path end to end: data
exists, DELETE 404s it at once, the job removes the data and
directory, the default dataset is refused, the real grace holds a job
for a week, a tenant admin cannot purge the org, keys stop working at
once, the workspace is removed, and both actions are audited.
Deployed-platform purge (profile + S3 grant) is #1380.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

@athvin
athvin merged commit 7c43aea into main Nov 29, 2026
49 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 29, 2026 04:37 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — ccf475e2 Deployed Nov 29, 2026 by athvin via remove closed PR previews #141
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Purge a dataset or tenant through the API: drop its lake and data, revoke its keys

2 participants