feat(revisions): configurable retention policy (keep last N) #175
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
From GAP_ANALYSIS.md Open Questions #3 and #5:
Decision: Archive old revisions according to a server-side "keep last N" policy configured in
config.yaml. Released revisions are exempt from cleanup.Current Behavior
All revisions are kept indefinitely. There is no retention policy, cleanup mechanism, or archival process. The
revisionstable and associated file storage grow without bound.Proposed Behavior
Configuration
Add a
revisionssection toconfig.yaml:Corresponding additions to
internal/config/config.go:Archive Behavior
When the sweeper runs (or when a new revision is created and the count exceeds the threshold):
keep_last_n, identify candidates for archival (oldest first)releasedorobsoleteifprotect_releasedis truearchived_attimestamp column on the revision row (soft delete)GET /api/items/{pn}/revisionsby default but can be included with?include_archived=trueAPI Changes
GET /api/items/{pn}/revisions— addinclude_archivedquery param (default false)GET /api/admin/settings/revisions— expose retention configPUT /api/admin/settings/revisions— update retention configFiles to Modify
internal/config/config.go— addRevisionsConfigstruct and defaultsinternal/db/items.go— addArchiveRevision(),CountRevisions(), update list queries to filter archivedinternal/api/handlers.go— updateHandleListRevisions()to supportinclude_archivedparamarchived_at TIMESTAMPTZcolumn torevisionstableRelated
migrations/001_initial.sql