core

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompactHomePath

func CompactHomePath(path, home string) string

CompactHomePath replaces home prefix with "~" when possible.

func FormatBytesIEC

func FormatBytesIEC(size int64) string

FormatBytesIEC formats byte counts using IEC units.

func FormatDisplayTime

func FormatDisplayTime(t time.Time) string

FormatDisplayTime formats timestamps for human-readable table output.

func ShortID

func ShortID(id string) string

ShortID returns a stable short view for long session IDs.

func SortSessionsByRisk

func SortSessionsByRisk(items []session.Session, evaluator RiskEvaluator, checker session.IntegrityChecker)

SortSessionsByRisk applies risk-priority ordering: risk desc, updated_at desc, session_id asc.

Types

type QueryResult

type QueryResult struct {
	Total int
	Items []session.Session
}

func QuerySessions

func QuerySessions(repo SessionRepository, root string, spec QuerySpec) (QueryResult, error)

QuerySessions scans root via repo, applies selector, then performs normalized sorting and pagination.

type QuerySpec

type QuerySpec struct {
	Selector session.Selector
	Offset   int
	Limit    int
	Sort     SortSpec

	// Legacy string fields are accepted for CLI-facing compatibility and
	// normalized into Sort when Sort is not provided.
	SortBy string
	Order  string
	Now    time.Time
}

QuerySpec describes shared session-query constraints used by usecases.

type RiskEvaluator

type RiskEvaluator interface {
	Evaluate(session.Session, session.IntegrityChecker) session.Risk
}

RiskEvaluator evaluates one session and returns the highest-priority risk.

type ScannerRepository

type ScannerRepository struct{}

ScannerRepository is the default repository backed by scanner.ScanSessions.

func (ScannerRepository) ScanSessions

func (ScannerRepository) ScanSessions(root string) ([]session.Session, error)

ScanSessions implements SessionRepository.

type SessionRepository

type SessionRepository interface {
	ScanSessions(root string) ([]session.Session, error)
}

SessionRepository provides access to raw session rows.

type SessionRiskEvaluator

type SessionRiskEvaluator struct{}

SessionRiskEvaluator is the default evaluator backed by session.EvaluateRisk.

func (SessionRiskEvaluator) Evaluate

Evaluate implements RiskEvaluator.

type SortField

type SortField string
const (
	SortFieldUpdatedAt SortField = "updated_at"
	SortFieldCreatedAt SortField = "created_at"
	SortFieldSize      SortField = "size"
	SortFieldHealth    SortField = "health"
	SortFieldID        SortField = "id"
)

type SortOrder

type SortOrder string
const (
	SortOrderAsc  SortOrder = "asc"
	SortOrderDesc SortOrder = "desc"
)

type SortSpec

type SortSpec struct {
	Field SortField
	Order SortOrder
}

SortSpec is the normalized internal sort model for session queries.

func ParseSortSpec

func ParseSortSpec(sortBy, order string) (SortSpec, error)

Jump to

Keyboard shortcuts

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