feat(retention): deleting a target or erasing a tenant removes its files (#289) #355

Merged
sharang merged 1 commits from feat/retention into main 2026-09-23 16:12:09 +00:00
Owner

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.ai/code/session_01EYKjxacrr6K88DruUmP48p

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
sharang changed target branch from feat/compliance-view to main 2026-09-23 16:03:31 +00:00
sharang added 1 commit 2026-09-23 16:03:31 +00:00
feat(retention): deleting a target or erasing a tenant removes its files (#289)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 8m24s
7c447f0447
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
sharang force-pushed feat/retention from 475e8a8736 to 7c447f0447 2026-09-23 16:03:32 +00:00 Compare
sharang merged commit 6752f54036 into main 2026-09-23 16:12:09 +00:00
Sign in to join this conversation.