deploy / plan (push) Successful in 35s
deploy / archied-image (push) Canceled after 0s
deploy / agent-image (push) Canceled after 0s
deploy / dist-zip (push) Canceled after 0s
deploy / gate (push) Canceled after 25s
ci/woodpecker/push/deploy Pipeline was canceled
The retention sweep applied one window to a code-fixed allowlist, and the largest event kind (agent transcripts) was outside it, so the events table grew whatever the instance set. The audit-retention document now takes per-kind overrides, the dashboard offers each prunable kind its own window from the server's list, and a kind without an override follows the default. A security kind is refused where the document is written, and the sweep cuts each kind at its own cutoff in one bounded, locked transaction.
107 lines
3.6 KiB
Go
107 lines
3.6 KiB
Go
package audit
|
|
|
|
import (
|
|
"slices"
|
|
|
|
"github.com/samcharles93/archie-core/internal/events"
|
|
)
|
|
|
|
// The audit retention policy: which runtime event kinds the sweep may delete,
|
|
// and which it must keep no matter what an instance setting says. The lists are
|
|
// code, not settings — a stored document chooses a window for a prunable kind
|
|
// but can never widen this boundary, and a security record is never deleted.
|
|
|
|
// observabilityEventKinds is the high-volume observability trail the sweep may
|
|
// delete. agent_transcript leads because it is the largest payload by far; the
|
|
// task-attempt view shows transcripts while they are kept and still works when
|
|
// they are gone.
|
|
func observabilityEventKinds() []string {
|
|
return []string{
|
|
events.KindAgentTranscript,
|
|
events.KindStageStart,
|
|
events.KindAgentFinish,
|
|
events.KindToolCall,
|
|
events.KindLog,
|
|
events.KindTurnCompleted,
|
|
events.KindConfigCaptured,
|
|
events.KindCuratorRun,
|
|
events.KindCuratorAction,
|
|
events.KindCuratorError,
|
|
events.KindJobRun,
|
|
events.KindJobError,
|
|
}
|
|
}
|
|
|
|
// protectedEventKinds are the kinds the sweep must never delete: security
|
|
// relevant records (approvals and rejections, retries, cancellation and
|
|
// abandonment, pull-request actions, delivery records, binding and mapping
|
|
// changes, alerts, update reports) and the two observability kinds a product
|
|
// read depends on. stage_finish is the only source for StageStats' slowest
|
|
// stages and most failures; changes_captured is what api_tasks_changes rebuilds
|
|
// a task's captured-changes view from. Neither has a fallback, so pruning them
|
|
// would silently change what the product shows. Keeping the list here, rather
|
|
// than in a comment, is what lets the prunable predicate refuse a kind that
|
|
// appears in both lists.
|
|
func protectedEventKinds() []string {
|
|
return []string{
|
|
events.KindStageFinish,
|
|
events.KindChangesCaptured,
|
|
events.KindTaskQueued,
|
|
events.KindDeliveryRecorded,
|
|
events.KindParked,
|
|
events.KindOutcome,
|
|
events.KindChatOutcome,
|
|
events.KindPRMerged,
|
|
events.KindPRRejected,
|
|
events.KindPRClosed,
|
|
events.KindPRMergeRequested,
|
|
events.KindTaskDead,
|
|
events.KindOperatorApproved,
|
|
events.KindOperatorRejected,
|
|
events.KindAgentApproved,
|
|
events.KindAgentRejected,
|
|
events.KindTaskApproved,
|
|
events.KindTaskRejected,
|
|
events.KindOperatorRereviewed,
|
|
events.KindAgentRereviewed,
|
|
events.KindTaskRereviewed,
|
|
events.KindTaskRetried,
|
|
events.KindTaskCancelled,
|
|
events.KindTaskStopped,
|
|
events.KindTaskAbandoned,
|
|
events.KindRemediationRound,
|
|
events.KindReviewApproved,
|
|
events.KindStepRetried,
|
|
events.KindTaskWithdrawn,
|
|
events.KindTaskArchiveRequested,
|
|
events.KindWorkRequestSubmitted,
|
|
events.KindAlert,
|
|
events.KindBindingChanged,
|
|
events.KindMappingChanged,
|
|
events.KindBindingStarted,
|
|
events.KindWorkflowCallStarted,
|
|
events.KindIdentityStarted,
|
|
events.KindWorkflowCallFinished,
|
|
events.KindUpdateReport,
|
|
// Written by the daemon's binding dispatch as a bare literal.
|
|
"binding_dispatch_failure",
|
|
}
|
|
}
|
|
|
|
// PrunableEventKinds returns the event kinds an instance's audit retention
|
|
// setting may give a window to, in display order. The protected set is
|
|
// subtracted, so a kind accidentally listed in both is kept rather than
|
|
// deleted.
|
|
func PrunableEventKinds() []string {
|
|
protected := protectedEventKinds()
|
|
return slices.DeleteFunc(slices.Clone(observabilityEventKinds()), func(kind string) bool {
|
|
return slices.Contains(protected, kind)
|
|
})
|
|
}
|
|
|
|
// PrunableEventKind reports whether kind is one the sweep may delete. Unknown
|
|
// kinds and security records are not prunable.
|
|
func PrunableEventKind(kind string) bool {
|
|
return slices.Contains(PrunableEventKinds(), kind)
|
|
}
|