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 ¶
- Variables
- type SearchParams
- type Store
- func (s *Store) Close() error
- func (s *Store) DeleteSession(ctx context.Context, id string) error
- func (s *Store) DeleteSessionsByWorktree(ctx context.Context, worktreeID string) error
- func (s *Store) FindSessionByExternalID(ctx context.Context, externalID string) (agent.SessionInfo, error)
- func (s *Store) GetSession(ctx context.Context, id string) (agent.SessionInfo, error)
- func (s *Store) ListSessions(ctx context.Context) ([]agent.SessionInfo, error)
- func (s *Store) ListSessionsByWorktree(ctx context.Context, worktreeID string) ([]agent.SessionInfo, error)
- func (s *Store) LoadPrimaryAgents(ctx context.Context, backend agent.BackendType, ref agent.GitRef) ([]agent.AgentInfo, error)
- func (s *Store) SearchSessions(ctx context.Context, p SearchParams) ([]agent.SessionInfo, error)
- func (s *Store) UpsertPrimaryAgents(ctx context.Context, backend agent.BackendType, ref agent.GitRef, ...) error
- func (s *Store) UpsertSession(ctx context.Context, info agent.SessionInfo) error
Constants ¶
This section is empty.
Variables ¶
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 ¶
Open opens (or creates) the host's SQLite database at dbPath and applies any pending schema migrations.
func (*Store) DeleteSession ¶
DeleteSession removes a session by ID. No-op if it doesn't exist.
func (*Store) DeleteSessionsByWorktree ¶
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 ¶
GetSession returns the persisted session by its daemon ID, or ErrSessionNotFound.
func (*Store) ListSessions ¶
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 ¶
UpsertSession inserts or replaces the session row by ID.