Documentation
¶
Overview ¶
Package session implements the SQLite session store for Cortex.
It provides lifecycle management for coding sessions, including creation, retrieval, ending, and querying sessions and their associated observations. The store implements the domain.SessionRepository interface with additional methods for session stats and observations by session queries.
Index ¶
- type SessionStats
- type Stats
- type Store
- func (s *Store) Create(ctx context.Context, session *domain.Session) error
- func (s *Store) End(ctx context.Context, id string, summary string) error
- func (s *Store) GetByID(ctx context.Context, id string) (*domain.Session, error)
- func (s *Store) GetCurrent(ctx context.Context, project string) (*domain.Session, error)
- func (s *Store) GetStats(ctx context.Context) (*Stats, error)
- func (s *Store) GetWithStats(ctx context.Context, id string) (*SessionStats, error)
- func (s *Store) List(ctx context.Context, project string) ([]*domain.Session, error)
- func (s *Store) Recent(ctx context.Context, project string, limit int) ([]*domain.Session, error)
- func (s *Store) RecentWithStats(ctx context.Context, project string, limit int) ([]*SessionStats, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessionStats ¶
SessionStats represents statistics about a session.
type Stats ¶
type Stats struct {
TotalSessions int
ActiveSessions int
EndedSessions int
TotalObservations int
Projects []string
}
Stats represents overall session statistics.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the SQLite session store. It provides CRUD operations for sessions and related queries.
func (*Store) Create ¶
Create inserts a new session into the database. It sets the StartedAt timestamp if not already set. Returns an error if a session with the same ID already exists.
func (*Store) End ¶
End marks a session as completed with an optional summary. It sets the ended_at timestamp to the current time and updates the summary. Returns ErrNotFound if the session does not exist. Returns ErrSessionEnded if the session has already ended.
func (*Store) GetByID ¶
GetByID retrieves a session by its ID. Returns ErrNotFound if the session does not exist.
func (*Store) GetCurrent ¶
GetCurrent retrieves the most recent active session for a project. An active session is one where ended_at is NULL. Returns ErrNotFound if no active session exists for the project.
func (*Store) GetWithStats ¶
GetWithStats retrieves a session with its observation count. Returns ErrNotFound if the session does not exist.
func (*Store) List ¶
List retrieves sessions for a project, ordered by most recent first. If project is empty, returns all sessions. Sessions are ordered by started_at descending.
func (*Store) Recent ¶
Recent retrieves the most recent sessions with optional project filter. Sessions are ordered by started_at descending with a limit. If limit is <= 0, a default limit of 5 is used.
func (*Store) RecentWithStats ¶
func (s *Store) RecentWithStats(ctx context.Context, project string, limit int) ([]*SessionStats, error)
RecentWithStats retrieves recent sessions with their observation counts. Sessions are ordered by most recent activity first. If limit is <= 0, a default limit of 5 is used.