retention

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package retention bounds Mooring's own audit/events table so it can never become the disk-wedge that kills the write plane (plan §16.1). It is read-plane (it only prunes its own rows) and runs precisely when the box is small.

The cardinal invariant: a level=security audit row is NEVER silently dropped. Every security row that is about to be pruned is first appended to a rotated NDJSON archive; if that append fails, the whole pass aborts WITHOUT deleting anything (fail-closed) — losing audit evidence is never acceptable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Interval        time.Duration
	EventsMaxAge    time.Duration
	EventsMaxRows   int
	ArchiveMaxBytes int64
}

Config is the live, SIGHUP-reloadable retention policy (plan §16.1 Tier-1).

type Runner

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

Runner prunes the events table on a ticker. Construct with New; drive with Run.

func New

func New(db *store.DB, log *slog.Logger, archiveDir string, cfg Config) *Runner

New builds a Runner. archiveDir is where the security-row NDJSON archive lives (Mooring's own data dir); cfg is the initial (reloadable) policy.

func (*Runner) Pass

func (r *Runner) Pass(ctx context.Context) (int, error)

Pass runs one full retention pass over the events table and returns the number of rows pruned. Exported for tests + on-demand invocation.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context)

Run executes one pass shortly after start, then every Interval, until ctx is cancelled. A pass error is logged and paged (security level) but never panics.

func (*Runner) SetConfig

func (r *Runner) SetConfig(cfg Config)

SetConfig hot-swaps the policy (called from the SIGHUP path). Cheap + atomic.

Jump to

Keyboard shortcuts

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