store

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package store is the host's local SQLite for session metadata and the primary-agent cache. Owned by clank-host (the per-user host process), opened at the path specified by --data-dir.

Compared to internal/store (provisioner-side, hosts table) this store lives on a different machine in the cloud topology — the host runs inside a sprite/sandbox, the provisioner runs in the gateway/clankd process. Same Go pattern, different file, different owner.

schema.sql is the declarative source of truth (read by sqlc); the goose migrations in migrations/ are what actually run at Open(). See the `make migration` target for evolving the schema.

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session not found")

ErrSessionNotFound is returned by GetSession when no session matches.

Functions

This section is empty.

Types

type SearchParams

type SearchParams struct {
	Q          string
	Visibility agent.SessionVisibility
	Since      time.Time
	Until      time.Time
	Limit      int
}

SearchParams mirrors the hub-side SearchParams (kept on agent.). Empty Q / Visibility means no filter for that field. Zero Since or Until means unbounded. Limit ≤ 0 means a default cap.

type Store

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

Store wraps the host's SQLite database. The high-level methods in sessions.go delegate to the sqlc-generated Queries.

func Open

func Open(dbPath string) (*Store, error)

Open opens (or creates) the host's SQLite database at dbPath and applies any pending schema migrations.

func (*Store) Close

func (s *Store) Close() error

Close releases the underlying database connection.

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, id string) error

DeleteSession removes a session by ID. No-op if it doesn't exist.

func (*Store) DeleteSessionsByWorktree

func (s *Store) DeleteSessionsByWorktree(ctx context.Context, worktreeID string) error

DeleteSessionsByWorktree removes every session belonging to a worktree. No-op when the worktree has none. Used by full-cleanup worktree delete (alongside removing the materialized ~/work/<id> directory).

func (*Store) FindSessionByExternalID

func (s *Store) FindSessionByExternalID(ctx context.Context, externalID string) (agent.SessionInfo, error)

FindSessionByExternalID returns the session whose backend ID matches externalID, or ErrSessionNotFound. Used by the discovery flow to dedupe historical sessions.

func (*Store) GetSession

func (s *Store) GetSession(ctx context.Context, id string) (agent.SessionInfo, error)

GetSession returns the persisted session by its daemon ID, or ErrSessionNotFound.

func (*Store) ListSessions

func (s *Store) ListSessions(ctx context.Context) ([]agent.SessionInfo, error)

ListSessions returns every persisted session, newest-updated first.

func (*Store) ListSessionsByWorktree

func (s *Store) ListSessionsByWorktree(ctx context.Context, worktreeID string) ([]agent.SessionInfo, error)

ListSessionsByWorktree returns every persisted session for the given worktree ID, newest-updated first. Empty worktreeID returns an empty slice (rather than every session in the DB) — callers operating without a worktree context should use ListSessions instead.

func (*Store) LoadPrimaryAgents

func (s *Store) LoadPrimaryAgents(ctx context.Context, backend agent.BackendType, ref agent.GitRef) ([]agent.AgentInfo, error)

LoadPrimaryAgents returns the cached agent list for (backend, ref), or nil + nil if no entry exists.

func (*Store) SearchSessions

func (s *Store) SearchSessions(ctx context.Context, p SearchParams) ([]agent.SessionInfo, error)

SearchSessions returns sessions matching the filters.

func (*Store) UpsertPrimaryAgents

func (s *Store) UpsertPrimaryAgents(ctx context.Context, backend agent.BackendType, ref agent.GitRef, agents []agent.AgentInfo) error

UpsertPrimaryAgents stores the agent list for (backend, ref).

func (*Store) UpsertSession

func (s *Store) UpsertSession(ctx context.Context, info agent.SessionInfo) error

UpsertSession inserts or replaces the session row by ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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