codexscan

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package codexscan discovers Codex rollout transcripts from Codex's local state databases. The databases are opened read-only and query-only: Culi never migrates, locks for writing, or otherwise owns Codex state.

Index

Constants

This section is empty.

Variables

View Source
var ErrScanLocked = errors.New("codexscan: scan already running")

ErrScanLocked means another process is already discovering Codex rollouts. The automatic path treats it as a benign skip; an explicit manual scan surfaces it so two operators never race telemetry or queue writes.

Functions

func SaveHealth

func SaveHealth(stateDir string, h Health) error

SaveHealth atomically replaces the scanner breadcrumb.

Types

type Health

type Health struct {
	LastAttempt time.Time `json:"last_attempt"`
	LastSuccess time.Time `json:"last_success,omitempty"`
	Mode        string    `json:"mode,omitempty"`
	Discovered  int       `json:"discovered"`
	Queued      int       `json:"queued"`
	Skipped     int       `json:"skipped"`
	DurationMS  int64     `json:"duration_ms"`
	Error       string    `json:"error,omitempty"`
}

Health is the durable, content-free scanner breadcrumb consumed by doctor. It deliberately records counts and timing only—never rollout paths, prompts, repository names, or session IDs.

func LoadHealth

func LoadHealth(stateDir string) (Health, error)

LoadHealth reads the latest scanner breadcrumb. Missing state means the scanner has not run yet; malformed state is reported to doctor rather than silently presented as "never".

type Lease

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

Lease serializes discovery across Stop/SessionEnd workers. Release is idempotent so callers can defer it immediately after acquisition.

func Acquire

func Acquire(stateDir string, now time.Time, minInterval time.Duration) (*Lease, bool, error)

Acquire obtains the scanner lease and applies minInterval to the last attempted scan. A zero interval is an unthrottled manual scan. due=false is a clean throttle result; ErrScanLocked means another scan owns the lease.

func (*Lease) Release

func (l *Lease) Release() error

Release relinquishes the scanner lease.

type Session

type Session struct {
	SessionID   string
	RolloutPath string
	CWD         string
	UpdatedAt   time.Time
}

Session is one rollout-backed Codex thread ready for the neutral learning queue. SessionID is raw here; the queue boundary adds the harness prefix.

func Discover

func Discover(ctx context.Context, codexHome string) (sessions []Session, skipped int, err error)

Discover reads every state_*.sqlite database newest-schema-first. Results are de-duplicated by rollout path because an upgrade may copy threads into a newer state database while retaining the older file. skipped counts rollouts dropped by the containment guard (safeRollout) so the caller can surface an otherwise-silent drop — e.g. a Codex build that relocates rollouts outside $CODEX_HOME would return sessions=0, skipped>0 instead of a mute empty scan.

Jump to

Keyboard shortcuts

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