Add `archived` status to Ci::Partition model
## Problem Currently, the `Ci::Partition` model has 4 status values (`preparing`, `ready`, `current`, `active`), but there's no status to represent partitions where all pipelines have been archived and processing data can be safely deleted. As we work on truncating archived partitions (related to [#552078](https://gitlab.com/gitlab-org/gitlab/-/work_items/552078)), we need a way to track which partitions contain only archived pipelines so that processing data (like `p_ci_job_definitions`) can be safely truncated to reclaim space. ## Proposal Add a new `archived` status (value: 4) to the `Ci::Partition` state machine in `app/models/ci/partition.rb`. The status transition flow would be: - `preparing` → `ready` → `current` → `active` → **`archived`** This new status would: - Mark partitions where all pipelines have been archived (likely determined by checking if the last pipeline created in that partition is archived) - Identify partitions where processing data can be safely deleted - Enable automated cleanup processes to reclaim space from old partitions ## Implementation considerations 1. Add the new `archived` state to the state machine (lines 12-16 in `app/models/ci/partition.rb`) 2. Define the transition event from `active` to `archived` 3. Update `app/workers/ci/partitioning_worker.rb` to check if all pipelines in a partition are archived (by checking the last pipeline created in that partition) and transition the partition to `archived` status. - [UPDATE 2026-04-22] We can't get the last pipeline by `id` because of imported pipelines which preserve `created_at`. And we can't get it by ordering `p_ci_pipelines.created_at` because there isn't an index for it (and we shouldn't add a new one due to table size). We decided to instead check if the partition's `current_until` is older than `Gitlab::CurrentSettings.current_application_settings.archive_builds_older_than`. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/232501#note_3276854075. ## Related - [#552078](https://gitlab.com/gitlab-org/gitlab/-/work_items/552078) - Truncate `p_ci_job_definitions` for archived partitions - [&19547](https://gitlab.com/groups/gitlab-org/-/work_items/19547) - Enable pipeline archival on Gitlab.com
issue