session

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package session provides an explicit local archive of completed library conversations. It does not run a model or resume an interrupted operation.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig         = errors.New("session: invalid archive configuration")
	ErrStorage        = errors.New("session: archive operation failed")
	ErrIncompatible   = errors.New("session: incompatible archive or context")
	ErrNotFound       = errors.New("session: record not found")
	ErrConflict       = errors.New("session: record revision conflict")
	ErrIncomplete     = errors.New("session: only successful completed results may be saved")
	ErrCorrupt        = errors.New("session: invalid stored record")
	ErrLimit          = errors.New("session: record or result limit exceeded")
	ErrBusy           = errors.New("session: archive is busy")
	ErrSearchDisabled = errors.New("session: archive search is disabled")
)

Functions

This section is empty.

Types

type Archive

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

Archive owns its database/sql handle. Open and schema upgrades must be serialized by the caller. Already-open handles may compete for a revision.

func Open

func Open(ctx context.Context, path string, cfg Config) (*Archive, error)

Open opens a dedicated local SQLite archive. The parent directory and its contents must be trusted. It is not a filesystem sandbox or encrypted store.

func (*Archive) Close

func (a *Archive) Close() error

func (*Archive) Delete

func (a *Archive) Delete(ctx context.Context, id string, expected Revision) error

Delete removes a record only if its revision matches. This is logical deletion, not secure erasure of old database pages, journals or backups.

func (*Archive) List

func (a *Archive) List(ctx context.Context, after string, limit int) (Page, error)

List returns a bounded lexically ordered page of record identifiers. Multiple pages are not a transactionally frozen snapshot.

func (*Archive) Load

func (a *Archive) Load(ctx context.Context, id string) (Record, error)

func (*Archive) SaveCompleted

func (a *Archive) SaveCompleted(ctx context.Context, id string, expected Revision, r agent.Result, runErr error) (Revision, error)

SaveCompleted stores only a result explicitly supplied with its Run error. Empty expected creates; a nonempty expected conditionally replaces. If an operation returns an error, inspect the record before retrying: an interrupted caller cannot infer that a commit did not occur.

func (*Archive) Search

func (a *Archive) Search(ctx context.Context, query string, limit int) (SearchResult, error)

Search uses Unicode61 literal word/phrase matching in this opted-in archive. Query is not raw FTS syntax. It returns at most 100 message hits and does not load or run any conversation. A caller should compare Revision with the loaded record before relying on MessageIndex.

type Config

type Config struct {
	Context      string
	NativeFormat string
	// EnableSearch opts into a persistent index of visible user/assistant text.
	// Once enabled, every open must use this option. No downgrade is provided.
	EnableSearch bool
}

Config binds an archive to a caller-selected, non-secret application context. NativeFormat is empty by default, which rejects native data. These labels are not an authentication or isolation mechanism.

type Entry

type Entry struct {
	ID       string
	Revision Revision
}

type Page

type Page struct {
	Entries []Entry
	Next    string // Pass as after to List; empty means no further page observed.
}

type Record

type Record struct {
	ID           string
	Revision     Revision
	Messages     []agent.Message
	Verification *agent.VerificationReport
}

Record contains a completed history. Loading it never executes tools.

type Revision

type Revision string

Revision is an opaque record-version string, not an access token.

type SearchHit

type SearchHit struct {
	ID           string
	Revision     Revision
	MessageIndex int
	Snippet      string
}

SearchHit identifies a visible message in an observed record revision. Snippet is display text, not an executable instruction or whole history.

type SearchResult

type SearchResult struct {
	Hits []SearchHit
	More bool
}

Directories

Path Synopsis
internal
recordcodec
Package recordcodec owns the private version-one persisted record format.
Package recordcodec owns the private version-one persisted record format.
sqlitefile
Package sqlitefile owns the archive's private SQLite file and connection policy.
Package sqlitefile owns the archive's private SQLite file and connection policy.

Jump to

Keyboard shortcuts

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