Problem
The APT repository currently accumulates all historical versions of packages indefinitely. This leads to:
- Repository size bloat over time
- Multiple versions of the same package in metadata files
- Confusion about which version to install
- Unnecessary storage and bandwidth costs
Proposed Solution
Implement automatic package version compaction with intelligent retention policies:
For Semantic Version Packages (e.g., 1.2.3)
Keep a maximum of 4 previous releases:
- One previous major version (e.g., if current is 2.x.x, keep latest 1.x.x)
- One previous minor version (e.g., if current is 1.3.x, keep latest 1.2.x)
- One previous patch version (e.g., if current is 1.2.3, keep 1.2.2)
- One previous build/pre-release version
Example retention for package at v2.3.4:
- Keep: 2.3.4 (current), 2.3.3 (prev patch), 2.2.5 (prev minor), 1.8.2 (prev major)
- Remove: All other versions
For Non-Semantic Version Packages
Keep a maximum of 2 previous versions:
- Current version
- One previous version
Example for package at version 20240115-3:
- Keep: 20240115-3 (current), 20240115-2 (previous)
- Remove: All older versions
Implementation Details
The compaction should run:
- After each package update - When new packages are added
- During scheduled rebuilds - Clean up during daily maintenance
- Via manual trigger - Allow forced cleanup when needed
Algorithm
for each package in pool:
versions = get_all_versions(package)
if is_semver(versions):
retained = select_semver_retention(versions)
else:
retained = select_simple_retention(versions)
for version in versions:
if version not in retained:
remove_package(version)
Benefits
- Controlled repository size - Predictable storage requirements
- Cleaner package listings - Users see relevant versions only
- Faster metadata generation - Fewer packages to scan
- Rollback capability - Still maintains previous versions for recovery
Configuration Options
Consider making retention configurable:
- Environment variables for retention counts
- Per-package override capability
- Different policies for stable vs unstable channels
Edge Cases to Handle
- New packages - Don't remove anything if fewer versions than retention policy
- Rollback protection - Never remove currently installed versions (if trackable)
- Pre-release versions - Special handling for -dev, -beta, -rc versions
- Epoch versions - Handle Debian epoch (1:2.3.4) correctly
Alternative Approaches
- Time-based retention - Keep packages less than X days old
- Size-based retention - Keep total repository under X GB
- Manual cleanup - Require explicit removal commands
- Reference counting - Track which versions are in use
Related Issues
Acceptance Criteria
🔧 Implementation Requirements
MANDATORY: Follow halos-distro/docs/DEVELOPMENT_WORKFLOW.md during implementation.
See the complete workflow at: https://github.com/hatlabs/halos-distro/blob/main/docs/DEVELOPMENT_WORKFLOW.md
✅ Implementation Checklist
Track your progress through the mandatory development workflow:
□ Phase 1: EXPLORE (No Coding!)
□ Phase 2: PLAN
□ Phase 3: TEST (TDD)
□ Phase 4: IMPLEMENT
□ Phase 5: VERIFY
□ Phase 6: COMMIT
Problem
The APT repository currently accumulates all historical versions of packages indefinitely. This leads to:
Proposed Solution
Implement automatic package version compaction with intelligent retention policies:
For Semantic Version Packages (e.g., 1.2.3)
Keep a maximum of 4 previous releases:
Example retention for package at v2.3.4:
For Non-Semantic Version Packages
Keep a maximum of 2 previous versions:
Example for package at version 20240115-3:
Implementation Details
The compaction should run:
Algorithm
Benefits
Configuration Options
Consider making retention configurable:
Edge Cases to Handle
Alternative Approaches
Related Issues
Acceptance Criteria
🔧 Implementation Requirements
MANDATORY: Follow
halos-distro/docs/DEVELOPMENT_WORKFLOW.mdduring implementation.See the complete workflow at: https://github.com/hatlabs/halos-distro/blob/main/docs/DEVELOPMENT_WORKFLOW.md
✅ Implementation Checklist
Track your progress through the mandatory development workflow:
□ Phase 1: EXPLORE (No Coding!)
/docs/SPEC.mdrelevant sections (if applicable)/docs/ARCHITECTURE.mdrelevant sections (if applicable)Task tool with subagent_type=Explorefor complex navigation□ Phase 2: PLAN
think hardto evaluate approaches□ Phase 3: TEST (TDD)
git commit -m "test: add X tests"□ Phase 4: IMPLEMENT
□ Phase 5: VERIFY
□ Phase 6: COMMIT
git commit -m "feat: implement X\n\nFixes #13"