cleanup

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cleanup runs the server-side near-duplicate scanner and its webhook notifier: on the configured interval, walk every tenant, upsert pending entries. Merging happens client-side in a scheduled agent — this package calls no LLMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GlobalConfig added in v1.1.1

type GlobalConfig interface {
	CleanupEnabled() bool
	CleanupIntervalHours() int
	HistoryRetentionDays() int
	RetentionSweepEnabled() bool
	RetentionGraceDays() int
	MetricsRetentionDays() int
	WebhookURL() string
}

GlobalConfig is the live global-config slice the cleanup pipeline reads each cycle; *globalconfig.Accessor satisfies it.

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier POSTs a cleanup-scan JSON summary to the webhook URL from the live config. An empty URL disables it: no request is made.

func NewNotifier

func NewNotifier(gc GlobalConfig) *Notifier

NewNotifier returns a Notifier that reads its target webhook URL live from gc.

func (*Notifier) SendScanSummary

func (n *Notifier) SendScanSummary(ctx context.Context, stats ScanStats) error

SendScanSummary POSTs a JSON summary of one sweep; a no-op when no URL is set.

type PolicySource added in v1.2.0

type PolicySource interface {
	DocTypesWhere(func(models.EffectivePolicy) bool) []string
	All() map[string]models.EffectivePolicy
}

PolicySource supplies the doc_types the scanner skips (cleanup_scan=false) and the full effective set for retention windows; *staleness.PolicyStore satisfies it.

type ScanStats

type ScanStats struct {
	TenantsScanned int
	PairsFound     int
	PairsInserted  int
	PairsSkipped   int // already enqueued
	Errors         int
	HistoryPruned  int
	MetricsPruned  int // metric_events rows past metrics_retention_days
	DocsEvicted    int // retention-sweep hard deletes
}

ScanStats summarises one sweep across all tenants.

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

Scanner runs the near-duplicate scan and keeps cleanup_queue populated.

func NewScanner

NewScanner constructs the scanner. gc supplies the live windows, interval, and enabled flags; a nil notifier means silent scans.

func (*Scanner) RunOnce

func (s *Scanner) RunOnce(ctx context.Context) (ScanStats, error)

RunOnce performs a single sweep. Returns stats even on partial failure; per-tenant errors are counted, not fatal.

func (*Scanner) Start

func (s *Scanner) Start(ctx context.Context)

Start launches the scan loop until ctx is cancelled. Each cycle reads cleanup_enabled and cleanup_interval_hours live from the accessor, so a change applies at the next fire (next-cycle, not instant). The first sweep fires now.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL