Documentation
¶
Overview ¶
Package retention implements data-retention pruning for Legant's operational tables. Expired sessions, used/expired email and registration tokens, terminal or expired org invitations, the Fosite OAuth token stores (access/refresh/auth-code/PKCE/OIDC-session), expired agent tokens and API keys, delegation tokens dead past a grace window, and aged-out audit events accumulate indefinitely otherwise. The prune is safe to run repeatedly (idempotent) and is exposed both as the `legant maintenance prune` command and for scheduling as a Kubernetes CronJob.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPolicy = Policy{TokenGrace: 30 * 24 * time.Hour, AuditRetention: 0}
DefaultPolicy keeps dead tokens for 30 days and never auto-deletes audit.
Functions ¶
This section is empty.
Types ¶
type Policy ¶
type Policy struct {
// TokenGrace is how long a delegation token is kept after it expires before
// being purged. A short grace keeps revocation/introspection answers correct
// for recently-expired tokens; the row is dead weight after that.
TokenGrace time.Duration
// AuditRetention is the age beyond which audit_events are deleted. Zero keeps
// audit events forever (the safe default for compliance).
AuditRetention time.Duration
}
Policy controls the time-based windows. Durations of zero disable the corresponding age-based purge (expired-row cleanups always run).
type Result ¶
type Result struct {
ExpiredSessions int64
StaleEmailTokens int64
ExhaustedDCRTokens int64
StaleInvitations int64
DeadExchangedTokens int64
ExpiredOAuthTokens int64 // sum across the Fosite token tables
ExpiredAgentTokens int64
ExpiredAPIKeys int64
AgedAuditEvents int64
}
Result reports how many rows each step removed (or would remove, in dry-run).