codex

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Shared = &Cache{}

Shared is the process-wide cache the collector uses when a caller passes none, so every discovery in the daemon reuses what the others read.

Functions

func FindSessions

func FindSessions(sessionsDir string, roots []string) ([]model.Session, model.ScanReport, error)

FindSessions scans the dated rollout store and returns repository-scoped root sessions with every child and fork source needed to decode each tree.

func FindSessionsCached added in v0.2.0

func FindSessionsCached(sessionsDir string, roots []string, cache *Cache) ([]model.Session, model.ScanReport, error)

FindSessionsCached is FindSessions reading rollout first records through cache, which may be nil to read every one. The sessions found are the same either way.

func ScanStore

func ScanStore(codexHome string) ([]Entry, ScanReport, error)

ScanStore builds the first-line metadata index used by FIND. Rollout bodies are not read here.

func SessionWorkingDir

func SessionWorkingDir(path string) (string, bool, error)

SessionWorkingDir returns the root session working directory from a rollout's first-line metadata. Child and internal rollouts are excluded.

Types

type Cache added in v0.2.0

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

Cache remembers what the first record of each rollout said, keyed on its path, size and modification time, so a scan of an unchanged store does not open the files again. Each scan drops the entries of its store that it did not meet (deleted rollouts). Only what discovery uses is kept: the first line of a rollout is often 20 KB, most of it instructions discovery never reads.

Between BeginPass and EndPass the scan of a store is also done once: later lookups of the same store reuse its index. Use a pass for work that is content with the store as it was when the pass began, such as one analytics refresh over many clones.

A nil *Cache caches nothing. It is safe for concurrent use.

func (*Cache) BeginPass added in v0.2.0

func (c *Cache) BeginPass()

BeginPass starts a pass: until EndPass, the store of a sessions directory is scanned once however many times it is looked up. Passes may nest or overlap.

func (*Cache) EndPass added in v0.2.0

func (c *Cache) EndPass()

EndPass ends a pass begun by BeginPass. When the last one ends the scans it kept are forgotten.

func (*Cache) Len added in v0.2.0

func (c *Cache) Len() int

Len is how many rollouts the cache holds a first record for.

func (*Cache) Reads added in v0.2.0

func (c *Cache) Reads() int

Reads is how many rollout first records were read from disk rather than served from the cache.

type Entry

type Entry struct {
	Path  string
	Meta  *codextranscript.SessionMeta
	Class codextranscript.ThreadClass
}

type Files

type Files = model.Files

func Find

func Find(index []Entry, rootEntry Entry) (Files, error)

Find returns the file list for rootEntry using only the first-line index. Callers that look up several roots build one Tree and call its Find.

func RootFile

func RootFile(path string) Files

RootFile is the root-only file list used when a damaged store index cannot resolve the rest of a tree.

type ScanReport

type ScanReport struct {
	SkippedFiles int      `json:"skipped_files"`
	SkippedPaths []string `json:"skipped_paths,omitempty"`
	// UnreadablePaths are the compressed rollouts (.jsonl.zst) whose zstd data
	// is corrupt or truncated. They are skipped too, and listed here as well.
	UnreadablePaths []string `json:"unreadable_paths,omitempty"`
}

type Tree added in v0.2.0

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

Tree is the lookups Find needs over one scan of the store, built once so that finding each root session does not walk the whole index again.

func NewTree added in v0.2.0

func NewTree(index []Entry) *Tree

NewTree indexes entries by thread id and parent, and validates every parent chain.

func (*Tree) Find added in v0.2.0

func (t *Tree) Find(rootEntry Entry) (Files, error)

Find returns the file list for rootEntry.

Jump to

Keyboard shortcuts

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