maintenance

package
v1.26.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package maintenance provides periodic storage hygiene for the odek home directory (~/.odek): session retention, audit-record retention, log rotation, Telegram plan/media cleanup, and skill skip-list garbage collection.

The janitor is safe to run concurrently with a live agent: every pass is idempotent, individual steps are independent (one failing step does not abort the rest), and deletions are based on file modification times.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(ctx context.Context, home string, cfg Config)

Start runs Sweep on an interval until ctx is cancelled. It launches a background janitor goroutine and returns immediately. The first sweep runs after one interval (not immediately, so process startup isn't slowed). A disabled config or non-positive interval is a no-op / falls back to the default interval respectively.

Types

type Config

type Config struct {
	Enabled              bool
	IntervalMinutes      int   // janitor tick; default 60
	SessionsMaxAgeDays   int   // delete sessions older than this; default 30; 0 = keep forever
	AuditMaxAgeDays      int   // delete audit records older than this; default 14; 0 = keep
	LogMaxMB             int64 // rotate telegram/schedule logs larger than this; default 50; 0 = no rotation
	PlansMaxAgeDays      int   // delete telegram plans older than this; default 30; 0 = keep
	SkillsSkipMaxAgeDays int   // GC skill skip-list entries older than this; default 90; 0 = keep
}

Config controls the storage-maintenance janitor.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the out-of-the-box maintenance policy.

type Report

type Report struct {
	SessionsRemoved int
	AuditRemoved    int
	PlansRemoved    int
	SkipsRemoved    int
	MediaFreedBytes int64
	LogsRotated     []string
}

Report summarises what one Sweep pass removed.

func Sweep

func Sweep(ctx context.Context, home string, cfg Config) (Report, error)

Sweep runs one full maintenance pass over the odek home dir (e.g. ~/.odek). Idempotent, safe to call concurrently with a running agent.

Every step is independent: a failing step records the first error and the remaining steps still run, so one corrupt subtree cannot block the others.

Jump to

Keyboard shortcuts

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