Skip to content

Add a per-org configurable retention and purge job for soft-deleted vaults and milestones #726

Description

@1nonlypiece

📌 Description

Vaults and milestones support soft-delete (see the soft-delete migrations), but
soft-deleted rows accumulate forever. There is no retention policy or purge
job to hard-delete rows past a per-org retention window, which bloats tables and
keeps data longer than a tenant's compliance policy allows.

This issue adds a configurable retention window and a safe purge job for
soft-deleted vault and milestone rows.

Goal: hard-purge soft-deleted vaults/milestones past a per-org retention
window, in bounded batches, with an audit record.

🎯 Requirements and Context

  • Retention window must be configurable per org with a safe default.
  • Purge must be batched and bounded, and must cascade correctly to children.
  • Each purge batch must write an audit-log summary (count, org, window).
  • Must never purge rows that are not soft-deleted.

🛠️ Suggested Execution

1. Fork the repo and create a branch

git checkout -b feature/soft-delete-retention-purge

2. Implement changes

  • Add purge logic to src/services/vault.service.ts.
  • Register a job in src/jobs/handlers.ts with a type in src/jobs/types.ts.
  • Document the policy in docs/multi-tenancy.md.

3. Test and commit

  • Add src/tests/vault.retentionPurge.test.ts run with bun test.
  • Cover edge cases: window not yet elapsed, cascade to milestones, non-deleted
    rows untouched, and audit record written.

Example commit message

feat: per-org retention purge job for soft-deleted vaults

✅ Guidelines

  • Minimum 95% test coverage on the new/changed lines.
  • Clear, reviewer-friendly documentation.
  • No regressions on existing soft-delete behaviour.
  • Timeframe: 96 hours.

🏷️ Labels

type-feature · area-backend · type-testing · MAYBE REWARDED · GRANTFOX OSS · OFFICIAL CAMPAIGN

💬 Community & Support

  • Join the Disciplr contributor Discord to coordinate, ask questions, and get
    unblocked fast: https://discord.gg/xvNAvMJf
  • Please introduce yourself in the channel before you start so we can avoid
    duplicate work, pair you with a reviewer, and get your PR merged quickly.
  • Maintainers actively triage this channel and aim for fast, clear, respectful
    reviews — reach out any time you're blocked.

Metadata

Metadata

Assignees

Labels

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions