gc

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package gc provides garbage collection for log files in the .tick directory. It cleans up old log files to prevent unbounded growth of:

  • .tick/activity/activity.jsonl (trims old entries)
  • .tick/logs/records/*.json (deletes old run records)
  • .tick/logs/runs/*.jsonl (deletes old run logs)
  • .tick/logs/checkpoints/*.json (deletes old checkpoints)
  • .tick/logs/context/*.md (deletes old context files)

Files with .live.json suffix are always skipped as they represent in-progress operations.

Index

Constants

View Source
const DefaultMaxAge = 30 * 24 * time.Hour // 30 days

DefaultMaxAge is the default age threshold for deleting old files.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cleaner

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

Cleaner handles garbage collection for log files.

func NewCleaner

func NewCleaner(tickRoot string) *Cleaner

NewCleaner creates a new garbage collector.

func (*Cleaner) Cleanup

func (c *Cleaner) Cleanup() (*Result, error)

Cleanup runs garbage collection on all target directories.

func (*Cleaner) WithDryRun

func (c *Cleaner) WithDryRun(dryRun bool) *Cleaner

WithDryRun sets dry-run mode (report only, don't delete).

func (*Cleaner) WithMaxAge

func (c *Cleaner) WithMaxAge(d time.Duration) *Cleaner

WithMaxAge sets the maximum age for files to keep.

func (*Cleaner) WithNow

func (c *Cleaner) WithNow(t time.Time) *Cleaner

WithNow sets the current time (for testing).

type Result

type Result struct {
	// FilesDeleted is the total number of files deleted.
	FilesDeleted int
	// BytesFreed is the total bytes freed from deleted files.
	BytesFreed int64
	// EntriesTrimmed is the number of entries trimmed from activity.jsonl.
	EntriesTrimmed int
	// Errors contains any non-fatal errors encountered during cleanup.
	Errors []error
}

Result contains statistics from a cleanup run.

func Cleanup

func Cleanup(tickRoot string, maxAge time.Duration) (*Result, error)

Cleanup is a convenience function that runs cleanup with default settings.

Jump to

Keyboard shortcuts

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