Documentation
¶
Overview ¶
Package session implements scanning, filtering, and deletion for Codex sessions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRisky ¶ added in v0.2.2
func IsRisky(s Session, checker IntegrityChecker) bool
IsRisky reports whether EvaluateRisk returns a non-none level for s.
Types ¶
type DeleteOptions ¶
type DeleteOptions struct {
DryRun bool
Confirm bool
Yes bool
Hard bool
MaxBatch int
TrashRoot string
SessionsRoot string
}
DeleteOptions controls delete mode and safety gates.
type DeleteResult ¶
type DeleteResult struct {
SessionID string `json:"session_id"`
Path string `json:"path"`
Destination string `json:"destination,omitempty"`
Status string `json:"status"`
Error string `json:"error,omitempty"`
}
DeleteResult is a per-session execution result entry.
type DeleteSummary ¶
type DeleteSummary struct {
Action string `json:"action"`
Simulation bool `json:"simulation"`
MatchedCount int `json:"matched_count"`
Succeeded int `json:"succeeded"`
Failed int `json:"failed"`
Skipped int `json:"skipped"`
AffectedBytes int64 `json:"affected_bytes"`
Results []DeleteResult `json:"results"`
ErrorSummary string `json:"error_summary,omitempty"`
}
DeleteSummary aggregates delete execution status and accounting.
func DeleteSessions ¶
func DeleteSessions(candidates []Session, sel Selector, opts DeleteOptions) (DeleteSummary, error)
DeleteSessions executes dry-run, soft-delete, or hard-delete over matched sessions.
type Health ¶
type Health string
Health describes scanner quality classification for a session file.
const ( // HealthOK means the session file is readable and has a valid session_meta line. HealthOK Health = "ok" // HealthCorrupted means the session file cannot be parsed as expected. HealthCorrupted Health = "corrupted" // HealthMissingMeta means the file is readable but does not contain valid session metadata. HealthMissingMeta Health = "missing-meta" )
type IntegrityCheckResult ¶ added in v0.2.2
type IntegrityCheckResult struct {
// Verified reports whether a sidecar check was attempted.
Verified bool
// Match reports whether the verified content matched the sidecar digest.
Match bool
// Err reports why verification failed when the check could not complete.
Err error
// Detail carries additional mismatch or verification context.
Detail string
}
IntegrityCheckResult records the outcome of verifying a session sidecar.
func SHA256SidecarChecker ¶ added in v0.2.2
func SHA256SidecarChecker(s Session) IntegrityCheckResult
SHA256SidecarChecker verifies session integrity via "<session>.sha256" sidecar file. Sidecar formats accepted:
- "<hexhash>"
- "<hexhash> <filename>"
type IntegrityChecker ¶ added in v0.2.2
type IntegrityChecker func(Session) IntegrityCheckResult
IntegrityChecker verifies a session and returns an integrity result.
type Risk ¶ added in v0.2.2
type Risk struct {
// Level is the severity assigned by the current risk policy.
Level RiskLevel `json:"level"`
// Reason identifies which policy produced Level.
Reason RiskReason `json:"reason"`
// Detail carries human-readable context for the detected issue.
Detail string `json:"detail,omitempty"`
}
Risk describes the highest-priority issue detected for a session.
func EvaluateRisk ¶ added in v0.2.2
func EvaluateRisk(s Session, checker IntegrityChecker) Risk
EvaluateRisk returns the highest-priority risk detected for s.
Health-based risks are evaluated first. If checker is nil or s is already unhealthy, integrity verification is skipped.
type RiskLevel ¶ added in v0.2.2
type RiskLevel string
RiskLevel classifies how severe a session issue is.
type RiskReason ¶ added in v0.2.2
type RiskReason string
RiskReason identifies the specific policy that made a session risky.
const ( // RiskReasonNone means no risk policy matched. RiskReasonNone RiskReason = "none" // RiskReasonCorrupted marks unreadable or malformed session files. RiskReasonCorrupted RiskReason = "corrupted-session" // RiskReasonMissingMeta marks files without usable session metadata. RiskReasonMissingMeta RiskReason = "missing-meta" // RiskReasonIntegrityCheckError marks sidecar verification failures. RiskReasonIntegrityCheckError RiskReason = "integrity-check-error" // RiskReasonIntegrityMismatch marks hash mismatches against a sidecar. RiskReasonIntegrityMismatch RiskReason = "integrity-mismatch" )
type Selector ¶
type Selector struct {
ID string `json:"id,omitempty"`
IDPrefix string `json:"id_prefix,omitempty"`
HostContains string `json:"host_contains,omitempty"`
PathContains string `json:"path_contains,omitempty"`
HeadContains string `json:"head_contains,omitempty"`
OlderThan time.Duration `json:"older_than,omitempty"`
HasOlderThan bool `json:"has_older_than,omitempty"`
Health Health `json:"health,omitempty"`
HasHealth bool `json:"has_health,omitempty"`
}
Selector defines user-provided filters used by list and delete operations.
func (Selector) HasAnyFilter ¶
HasAnyFilter reports whether at least one filter is set.
type Session ¶
type Session struct {
SessionID string `json:"session_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
SizeBytes int64 `json:"size_bytes"`
Path string `json:"path"`
HostDir string `json:"host_dir,omitempty"`
Health Health `json:"health"`
Head string `json:"head,omitempty"`
}
Session is the normalized metadata row returned by scanner and list commands.
func FilterSessions ¶
FilterSessions applies selector constraints and returns results ordered by UpdatedAt desc.
func ScanSessions ¶
ScanSessions walks the sessions root and parses each .jsonl file into Session metadata.