Closes#289. Part of #265 (erasure). Pilot P2, item M. Stacked on the compliance PR.
Why
Customer code stayed on disk forever. Deleting a target removed its records, and tenant erasure dropped its database, but the clones, uploads, unpacked trees and blobs remained.
What
retention module:
every path of a target: uploads/<id>, work/<id>, the scan clone (by name), the ingest clones (by artifact id), and its blobs;
every path of a tenant: its clone directory and its runner-artifact directory;
removal refuses anything outside the two configured base directories (or the bases themselves), and an already-missing path counts as done.
DELETE /api/v1/targets/{id} reads the target first and removes its files after its records.
DELETE /api/v1/platform/tenants/{id}/data collects every target's paths before dropping the database, then removes them. The response gives files_removed and files_not_removed.
Guide:docs/guide/data-retention.md, the retention table.
Not in this PR
The time-based sweep for files left by an interrupted deletion.
Closes #289. Part of #265 (erasure). Pilot P2, item M. **Stacked on the compliance PR.**
## Why
Customer code stayed on disk forever. Deleting a target removed its records, and tenant erasure dropped its database, but the clones, uploads, unpacked trees and blobs remained.
## What
- **`retention` module:**
- every path of a target: `uploads/<id>`, `work/<id>`, the scan clone (by name), the ingest clones (by artifact id), and its blobs;
- every path of a tenant: its clone directory and its runner-artifact directory;
- removal **refuses anything outside the two configured base directories** (or the bases themselves), and an already-missing path counts as done.
- **`DELETE /api/v1/targets/{id}`** reads the target first and removes its files after its records.
- **`DELETE /api/v1/platform/tenants/{id}/data`** collects every target's paths before dropping the database, then removes them. The response gives `files_removed` and `files_not_removed`.
- **Guide:** `docs/guide/data-retention.md`, the retention table.
## Not in this PR
- The time-based sweep for files left by an interrupted deletion.
- The slug-equality check on tenant erasure (#265).
## Verification
- Unit tests:
- a target's five kinds of path go and another target's upload stays;
- removing twice is a no-op;
- a path outside the data directories, a base directory and `/etc/passwd` are all refused;
- tenant paths.
- Integration test (MongoDB), `tests/retention.rs`: upload a file → it is on disk → delete the target → it is gone.
- clippy with the CI flags; fmt; tests.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Customer code stayed on disk forever: deleting a target removed its
records, and tenant erasure dropped its database, but clones, uploads,
unpacked trees and blobs remained. On a small node that is disk; for
customer code it is an incomplete GDPR erasure.
- retention: every path of a target (uploads, work trees, the scan and
ingest clones, its blobs) and of a tenant (its clone and runner-artifact
directories). Removal refuses anything outside the two configured base
directories and treats an already-missing path as done.
- DELETE /api/v1/targets/{id} reads the target first and removes its
files after its records.
- DELETE /api/v1/platform/tenants/{id}/data collects every target's paths
before dropping the database, then removes them; the response counts
removed and unremovable paths.
- Guide: docs/guide/data-retention.md, the retention table.
Not yet: a time-based sweep for files left by an interrupted deletion, and
the slug check on tenant erasure (#265).
Tests: a target's files go and another target's stay; nothing outside the
data directories is touched; tenant paths; and an integration test
(MongoDB) that uploads a file, deletes the target and finds it gone.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #289. Part of #265 (erasure). Pilot P2, item M. Stacked on the compliance PR.
Why
Customer code stayed on disk forever. Deleting a target removed its records, and tenant erasure dropped its database, but the clones, uploads, unpacked trees and blobs remained.
What
retentionmodule:uploads/<id>,work/<id>, the scan clone (by name), the ingest clones (by artifact id), and its blobs;DELETE /api/v1/targets/{id}reads the target first and removes its files after its records.DELETE /api/v1/platform/tenants/{id}/datacollects every target's paths before dropping the database, then removes them. The response givesfiles_removedandfiles_not_removed.docs/guide/data-retention.md, the retention table.Not in this PR
Verification
/etc/passwdare all refused;tests/retention.rs: upload a file → it is on disk → delete the target → it is gone.🤖 Generated with Claude Code
https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
Customer code stayed on disk forever: deleting a target removed its records, and tenant erasure dropped its database, but clones, uploads, unpacked trees and blobs remained. On a small node that is disk; for customer code it is an incomplete GDPR erasure. - retention: every path of a target (uploads, work trees, the scan and ingest clones, its blobs) and of a tenant (its clone and runner-artifact directories). Removal refuses anything outside the two configured base directories and treats an already-missing path as done. - DELETE /api/v1/targets/{id} reads the target first and removes its files after its records. - DELETE /api/v1/platform/tenants/{id}/data collects every target's paths before dropping the database, then removes them; the response counts removed and unremovable paths. - Guide: docs/guide/data-retention.md, the retention table. Not yet: a time-based sweep for files left by an interrupted deletion, and the slug check on tenant erasure (#265). Tests: a target's files go and another target's stay; nothing outside the data directories is touched; tenant paths; and an integration test (MongoDB) that uploads a file, deletes the target and finds it gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p475e8a8736to7c447f0447