Hive Hive
Sign in

fix(server): reduce long-lived artifact retention

GitHub issue · Closed

Metadata
Source
tuist/tuist #11432
Updated
Jun 24, 2026
Domains
Storage
Details

Overview

This reduces long-lived artifact retention without making Enterprise identical to Pro. Pro remains capped at 90 days for the affected artifact classes, while Enterprise moves from 365 days to 180 days for app previews, build archives, run artifacts, and test attachments.

The change also broadens expired run cleanup so every file generated for an expired run is removed together, instead of only deleting the session archive.

What changed

  • Set a central maximum artifact retention window of 180 days.
  • Kept cache artifact retention unchanged at 14 days for Air and Open Source, 30 days for Pro, and 90 days for Enterprise.
  • Kept shard bundle retention unchanged at 7 days for Air and Open Source, 14 days for Pro, and 30 days for Enterprise.
  • Updated Enterprise retention from 365 days to 180 days for app previews, build archives, run artifacts, and test attachments.
  • Changed the run cleanup worker to delete the whole expired run artifact prefix instead of only the session archive.
  • Kept the existing run_session retention cursor for compatibility while making it cover all blobs under an expired run prefix.
  • Updated focused tests and the data export documentation to describe the new retention behavior.

Why

Operational review showed that some artifact categories can outlive a practical retention window. Run artifacts were a notable gap because files stored under the same run prefix were not all covered by the previous cleanup path.

A 365-day Enterprise window is too large for these artifact blobs, but a universal 90-day policy removes the product distinction between Pro and Enterprise. The new policy reduces the longest-lived artifacts to 180 days for Enterprise while keeping Pro at 90 days.

Storage breakdown

The aggregate category-level usage that motivated this change was:

Artifact category Approximate usage Relationship What this change addresses
Run artifacts 44.02 tebibytes Total category The cleanup now removes the whole expired run artifact prefix.
Result bundle archives 27.19 tebibytes Included in run artifacts Previously not covered by the session-only cleanup path.
Session archives 9.16 tebibytes Included in run artifacts Already targeted by the old worker, now removed with the rest of the run.
Result-bundle object files 7.15 tebibytes Included in run artifacts Now covered by prefix deletion for expired runs.
Invocation records 0.53 tebibytes Included in run artifacts Now covered by prefix deletion for expired runs.
Build archives 29.37 tebibytes Separate artifact category Enterprise retention is reduced from 365 days to 180 days.
App preview archives 9.00 tebibytes Separate artifact category Enterprise retention is reduced from 365 days to 180 days.

Root cause

The existing run cleanup path only deleted the session.zip object for expired command events. Other files under the same run artifact prefix, including result bundles, invocation records, and result-bundle objects, were not removed by that worker.

Some Enterprise retention windows also allowed artifact blobs to remain for 365 days.

Approach

The retention policy now applies a central 180-day maximum when resolving plan-specific retention windows. This keeps lower limits unchanged for Air, Open Source, Pro cache artifacts, and shard bundles while preventing the affected Enterprise artifact families from staying at 365 days.

For run artifacts, the existing worker now resolves each expired command event to its run artifact prefix and deletes every object below that prefix. The old delete_run_sessions entry point remains as a compatibility wrapper around the broader delete_run_artifacts behavior.

Impact

Expired run cleanup will remove all blobs stored under {account}/{project}/runs/{run_id}/, including session archives, result bundles, invocation records, and result-bundle objects. Build archives, app previews, run artifacts, and test attachments are now capped at 90 days for Pro and 180 days for Enterprise.

Metadata rows are still retained so analytics, dashboards, and export behavior remain intact.

Validation

  • mix format lib/tuist/storage/expired_artifacts.ex lib/tuist/storage/retention_policy.ex lib/tuist/storage/workers/delete_expired_run_sessions_worker.ex test/tuist/storage/retention_policy_test.exs test/tuist/storage/workers/delete_expired_artifact_workers_test.exs
  • mix test test/tuist/storage/retention_policy_test.exs test/tuist/storage/workers/delete_expired_artifact_workers_test.exs, 20 tests, 0 failures
  • git diff --check
Comments

No GitHub comments yet.