Help us shape the future of Go! Take the 2026 Go Developer Survey

sqlite

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package sqlite supplies explicitly opened native persistence. Importing it does not create files, open a database, or start a service.

Index

Constants

View Source
const ForeignPreviewBytes = 32 << 10
View Source
const ForeignRetention = 7 * 24 * time.Hour

Variables

View Source
var ErrForeignSuperseded = errors.New("foreign refresh superseded or revoked")
View Source
var ErrImportConflict = errors.New("conflicting session import")

Import upgrades legacy Pi trees without modifying their source files. ErrImportConflict reports a journal whose session ID is stored with other content.

Functions

func MigrationStatus

func MigrationStatus(ctx context.Context, path, name string) (bool, error)

MigrationStatus inspects an existing root without upgrading its schema.

Types

type CatalogEntry

type CatalogEntry struct {
	ParentID     string `json:"parent_id,omitempty"`
	Preview      string `json:"preview,omitempty"`
	MessageCount int    `json:"message_count"`
	ID           string `json:"id"`
	CWD          string `json:"cwd"`
	Name         string `json:"name"`
	Created      string `json:"created"`
	Modified     string `json:"modified"`
}

type CatalogPage

type CatalogPage struct {
	Sessions []CatalogEntry `json:"sessions"`
	Next     string         `json:"next,omitempty"`
}

type CatalogQuery

type CatalogQuery struct {
	CWD, Search, Cursor string
	Limit               int
	Archived            bool
}

type Chat

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

func (*Chat) Ack

func (store *Chat) Ack(ctx context.Context, id string) error

func (*Chat) Pending

func (store *Chat) Pending(ctx context.Context) ([]chat.Message, error)

func (*Chat) Put

func (store *Chat) Put(ctx context.Context, message chat.Message) error

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB is an open database. Writes made through the embedded *sql.DB bypass the cross-process writer queue; this package routes every write through begin.

func Open

func Open(ctx context.Context, path string) (_ *DB, err error)

func (*DB) Backup

func (db *DB) Backup(ctx context.Context, path string) (err error)

Backup creates a consistent standalone snapshot without copying a live WAL.

func (*DB) Chat

func (db *DB) Chat(namespace string) *Chat

func (*DB) Document

func (db *DB) Document(namespace, key string) *Document

func (*DB) Foreign

func (db *DB) Foreign(profile string) *Foreign

func (*DB) Memory

func (db *DB) Memory(namespace string) *Memory

func (*DB) Migrate

func (db *DB) Migrate(ctx context.Context, name string, sources []MigrationSource, verify ...func() error) error

Migrate checkpoints each source independently, then verifies the complete inventory before publishing cutover. Retrying never overwrites native writes.

func (*DB) Migrated

func (db *DB) Migrated(ctx context.Context, name string) (bool, error)

func (*DB) RestoreSessions

func (db *DB) RestoreSessions(ctx context.Context, path, namespace string) (int, error)

RestoreSessions recovers missing conversations without rolling back authority, credentials, operation receipts, or chat delivery state. Conflicts fail closed; rerunning after interruption accepts only identical already-restored journals.

func (*DB) Sessions

func (db *DB) Sessions(namespace string) *Sessions

type Document

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

func (*Document) Read

func (d *Document) Read(ctx context.Context) ([]byte, error)

func (*Document) Update

func (d *Document) Update(ctx context.Context, change func([]byte) ([]byte, error)) error

Update serializes read-modify-write across processes; nil deletes the document.

type Foreign

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

func (*Foreign) Begin

func (c *Foreign) Begin(ctx context.Context, peer string) (int64, error)

Begin allocates an ordering token before network I/O. Forget advances the floor, so an in-flight response can never resurrect purged content.

func (*Foreign) Forget

func (c *Foreign) Forget(ctx context.Context, peer string) error

func (*Foreign) List

func (c *Foreign) List(ctx context.Context, peer string) ([]ForeignSession, error)

func (*Foreign) Put

func (c *Foreign) Put(ctx context.Context, ticket int64, s ForeignSession) error

type ForeignSession

type ForeignSession struct {
	Peer, Namespace, ID, Instance, Name, CWD string
	RefreshedAt                              time.Time
	Messages                                 []PreviewMessage
}

func (*ForeignSession) AddMessage

func (s *ForeignSession) AddMessage(raw json.RawMessage)

AddMessage retains only visible, completed conversation text. Callers must not feed streaming deltas, which would duplicate messages in offline previews.

type Memory

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

func (*Memory) Append

func (store *Memory) Append(ctx context.Context, item memory.Item) (string, error)

func (*Memory) Delete

func (store *Memory) Delete(ctx context.Context, id string) error

func (*Memory) Get

func (store *Memory) Get(ctx context.Context, id string) (memory.Item, error)

func (*Memory) Query

func (store *Memory) Query(ctx context.Context, filter memory.Filter) ([]memory.Item, error)

func (*Memory) Transact

func (store *Memory) Transact(ctx context.Context, fn func(memory.Store) error) error

type MigrationSource

type MigrationSource struct {
	Path, Namespace, Key, Kind string
}

MigrationSource names an explicit offline source. Originals are never changed. The caller must quiesce legacy writers and hold its native-root migration lock.

type PreviewMessage

type PreviewMessage struct {
	Role string `json:"role"`
	Text string `json:"text"`
}

type Sessions

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

func (*Sessions) Catalog

func (r *Sessions) Catalog(ctx context.Context, q CatalogQuery) (CatalogPage, error)

Catalog pages on immutable creation order so streaming cannot move a row across page boundaries. Views can sort received summaries by live activity.

func (*Sessions) Create

func (*Sessions) Delete

func (r *Sessions) Delete(ctx context.Context, metadata harness.SessionMetadata) error

func (*Sessions) Fork

func (*Sessions) Import

func (r *Sessions) Import(ctx context.Context, content []byte) (harness.SessionMetadata, error)

func (*Sessions) List

func (*Sessions) ListInfo

func (*Sessions) Open

func (r *Sessions) Open(ctx context.Context, metadata harness.SessionMetadata) (*harness.Session, error)

func (*Sessions) OpenPath

func (r *Sessions) OpenPath(ctx context.Context, reference string) (*harness.Session, error)

OpenPath accepts a true JSONL import path or a native session ID.

Jump to

Keyboard shortcuts

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