maintenance

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package maintenance keeps the store healthy: a background sweeper purges expired memories and bounds short-term capacity, and fsck additionally audits live memories for duplicate (poisoning) clusters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnforceShortTermCap

func EnforceShortTermCap(ctx context.Context, st store.Store, cap int, now time.Time) (int, error)

EnforceShortTermCap evicts the lowest-retention short-term memories in each namespace that holds more than cap of them. cap <= 0 disables it. Returns the number evicted.

func PurgeExpired

func PurgeExpired(ctx context.Context, st store.Store, now time.Time) (int, error)

PurgeExpired deletes memories whose TTL has passed as of now, in batches, and returns the number removed.

Types

type Report

type Report struct {
	ExpiredPurged    int        `json:"expired_purged"`
	ShortTermEvicted int        `json:"short_term_evicted"`
	Namespaces       int        `json:"namespaces"`
	DuplicateGroups  [][]string `json:"duplicate_groups,omitempty"`
}

Report summarizes a consistency sweep.

func Fsck

func Fsck(ctx context.Context, st store.Store, cap int, now time.Time) (Report, error)

Fsck purges expired memories, enforces the short-term cap, and audits live memories for duplicate clusters (same normalized content) as a poisoning backstop. Duplicates are reported, not auto-deleted.

type Sweeper

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

Sweeper periodically purges expired memories and enforces the short-term cap.

func NewSweeper

func NewSweeper(st store.Store, log *slog.Logger, interval time.Duration, shortTermCap int) *Sweeper

NewSweeper builds a sweeper that runs every interval, bounding short-term memory to shortTermCap per namespace (0 disables the cap).

func (*Sweeper) Run

func (s *Sweeper) Run(ctx context.Context)

Run sweeps on a ticker until ctx is cancelled. It runs one sweep immediately.

Jump to

Keyboard shortcuts

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