maintenance

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package maintenance provides scheduled maintenance tasks for engram.

Package maintenance provides scheduled maintenance tasks for engram.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service handles scheduled maintenance tasks.

func NewService

func NewService(
	store *gorm.Store,
	observationStore *gorm.ObservationStore,
	summaryStore *gorm.SummaryStore,
	promptStore *gorm.PromptStore,
	vectorCleanupFn func(ctx context.Context, deletedIDs []int64),
	cfg *config.Config,
	similarityTelemetry *telemetry.SimilarityTelemetry,
	smartGC *SmartGC,
	log zerolog.Logger,
) *Service

NewService creates a new maintenance service.

func (*Service) RunNow

func (s *Service) RunNow(ctx context.Context)

RunNow triggers an immediate maintenance run.

func (*Service) Start

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

Start begins the maintenance loop.

func (*Service) Stats

func (s *Service) Stats() map[string]any

Stats returns maintenance statistics.

func (*Service) Stop

func (s *Service) Stop()

Stop signals the maintenance service to stop.

func (*Service) Wait

func (s *Service) Wait()

Wait waits for the maintenance service to finish.

type SmartGC

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

SmartGC archives low-value observations using multi-signal scoring. Unlike blunt age-based cleanup, it considers ImportanceScore, RetrievalCount, UtilityScore, SourceType, and observation age before archiving.

func NewSmartGC

func NewSmartGC(
	store *gorm.Store,
	observationStore *gorm.ObservationStore,
	vectorCleanupFn func(ctx context.Context, deletedIDs []int64),
	calculator *scoring.Calculator,
	cfg *config.Config,
	log zerolog.Logger,
) *SmartGC

NewSmartGC creates a new SmartGC instance.

func (*SmartGC) Run

func (gc *SmartGC) Run(ctx context.Context) SmartGCStats

Run executes the Smart GC pass across all projects.

func (*SmartGC) Stats

func (gc *SmartGC) Stats() SmartGCStats

Stats returns the results of the last Smart GC run.

type SmartGCStats

type SmartGCStats struct {
	Evaluated int64 `json:"evaluated"`
	Archived  int64 `json:"archived"`
	Protected int64 `json:"protected"`
	Skipped   int64 `json:"skipped"`
}

SmartGCStats holds the results of a Smart GC run.

Jump to

Keyboard shortcuts

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