sessionretention

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sessionretention contains the side-effect-free retention selection policy.

Index

Constants

View Source
const (
	// ReasonAge identifies a candidate selected by its age limit.
	ReasonAge = "age"
	// ReasonCap identifies a candidate selected by its family count limit.
	ReasonCap = "cap"

	// ProtectedUnknown identifies missing or invalid durable taxonomy.
	ProtectedUnknown = "unknown_taxonomy"
	// ProtectedState identifies a running or awaiting durable state.
	ProtectedState = "active_state"
	// ProtectedLive identifies an in-process live session.
	ProtectedLive = "live"
	// ProtectedLeased identifies a session currently leased for mutation.
	ProtectedLeased = "leased"
	// ProtectedForeign identifies a row outside the caller-bound scope.
	ProtectedForeign = "foreign_owner"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Counts

type Counts struct {
	Total    int
	ByKind   map[session.SessionKind]int
	ByState  map[session.State]int
	ByReason map[string]int
}

Counts is a stable aggregate projection.

type Item

type Item struct {
	ID             session.SessionID
	Kind           session.SessionKind
	State          session.State
	ModifiedAt     time.Time
	EstimatedBytes int64
	Reason         string
	OwnerKey       string
	Metadata       port.SessionDiscoveryMeta `json:"-"`
}

Item is content-free retention metadata for one row.

type Policy

type Policy struct {
	Version           string
	MainMaxAge        time.Duration
	MainMaxCount      int
	ChildMaxAge       time.Duration
	ChildMaxCount     int
	ScheduledMaxAge   time.Duration
	ScheduledMaxCount int
}

Policy is the effective retention policy consumed by both sweep and manual paths.

type Result

type Result struct {
	Generation string
	Eligible   []Item
	Protected  Counts
}

Result is a deterministic plan. It contains no transcript or tool content.

func Plan

func Plan(rows []port.SessionDiscoveryMeta, policy Policy, scope Scope, protection RuntimeProtection, now time.Time) Result

Plan selects oldest-first candidates without performing I/O or mutation.

func (Result) ContainsEligible

func (r Result) ContainsEligible(id session.SessionID) bool

ContainsEligible reports whether id is selected for cleanup.

type RuntimeProtection

type RuntimeProtection struct {
	Live   map[session.SessionID]bool
	Leased map[session.SessionID]bool
}

RuntimeProtection is a read-only snapshot of facts outside durable metadata.

type Scope

type Scope struct {
	Owner *session.Principal
}

Scope restricts a plan to one authenticated owner when Owner is non-nil.

Jump to

Keyboard shortcuts

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