Documentation
¶
Overview ¶
Package store handles all SQLite persistence for spec. No other package opens the database or writes raw SQL.
Index ¶
- func DefaultDBPath() string
- type ActivityEntry
- type CacheEntry
- type DB
- func (db *DB) ActivityCountByType(since time.Time) (map[string]int, error)
- func (db *DB) ActivityForSpec(specID string, limit int) ([]ActivityEntry, error)
- func (db *DB) ActivityForType(eventType string, since time.Time) ([]ActivityEntry, error)
- func (db *DB) ActivityLog(specID, eventType, summary, metadata, userName string) error
- func (db *DB) ActivityPrune(olderThan time.Duration) (int64, error)
- func (db *DB) ActivitySince(since time.Time) ([]ActivityEntry, error)
- func (db *DB) CacheClear() error
- func (db *DB) CacheDelete(key string) error
- func (db *DB) CacheGet(key string) (value string, fresh bool, err error)
- func (db *DB) CacheGetEntry(key string) (CacheEntry, error)
- func (db *DB) CacheSet(key, value string, ttlSeconds int) error
- func (db *DB) Close() error
- func (db *DB) Conn() *sql.DB
- func (db *DB) EmbeddingDeleteSpec(specID string) error
- func (db *DB) EmbeddingSearch(queryVector []float32, limit int) ([]EmbeddingEntry, error)
- func (db *DB) EmbeddingUpsert(specID, section, content string, vector []float32, model string) error
- func (db *DB) FocusedSpecClear() error
- func (db *DB) FocusedSpecGet() (string, error)
- func (db *DB) FocusedSpecSet(specID string) error
- func (db *DB) SessionDelete(specID string) error
- func (db *DB) SessionGet(specID string) (string, error)
- func (db *DB) SessionList() ([]string, error)
- func (db *DB) SessionMostRecent() (string, error)
- func (db *DB) SessionSet(specID, state string) error
- func (db *DB) SyncStateForSpec(specID string) (map[string]map[string]SyncStateEntry, error)
- func (db *DB) SyncStateGet(specID, section, direction string) (*SyncStateEntry, error)
- func (db *DB) SyncStateSet(specID, section, direction, hash string) error
- type EmbeddingEntry
- type SyncStateEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ActivityEntry ¶
type ActivityEntry struct {
ID int64
SpecID string
EventType string
Summary string
Metadata string
UserName string
CreatedAt time.Time
}
ActivityEntry represents a single event in the activity log.
type CacheEntry ¶
CacheEntry holds a cached value along with its metadata.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite database connection.
func OpenMemory ¶
OpenMemory opens an in-memory SQLite database for testing.
func (*DB) ActivityCountByType ¶
ActivityCountByType returns event counts grouped by event_type since the given time.
func (*DB) ActivityForSpec ¶
func (db *DB) ActivityForSpec(specID string, limit int) ([]ActivityEntry, error)
ActivityForSpec returns activity entries for a specific spec.
func (*DB) ActivityForType ¶
ActivityForType returns all entries of a specific event type since the given time.
func (*DB) ActivityLog ¶
ActivityLog appends an event to the activity log.
func (*DB) ActivityPrune ¶
ActivityPrune removes activity older than the given duration.
func (*DB) ActivitySince ¶
func (db *DB) ActivitySince(since time.Time) ([]ActivityEntry, error)
ActivitySince returns activity entries since the given time.
func (*DB) CacheDelete ¶
CacheDelete removes a cache entry.
func (*DB) CacheGet ¶
CacheGet retrieves a cached value by key. Returns the value and whether the cache entry is still fresh (within TTL). Returns "", false if not found.
func (*DB) CacheGetEntry ¶
func (db *DB) CacheGetEntry(key string) (CacheEntry, error)
CacheGetEntry retrieves a cache entry with full metadata including fetch time.
func (*DB) EmbeddingDeleteSpec ¶
EmbeddingDeleteSpec removes all embeddings for a spec.
func (*DB) EmbeddingSearch ¶
func (db *DB) EmbeddingSearch(queryVector []float32, limit int) ([]EmbeddingEntry, error)
EmbeddingSearch finds the most similar embeddings to the query vector. Uses brute-force cosine similarity (sufficient for hundreds of specs).
func (*DB) EmbeddingUpsert ¶
func (db *DB) EmbeddingUpsert(specID, section, content string, vector []float32, model string) error
EmbeddingUpsert inserts or updates an embedding for a spec section.
func (*DB) FocusedSpecClear ¶
FocusedSpecClear clears the globally focused spec ID.
func (*DB) FocusedSpecGet ¶
FocusedSpecGet returns the globally focused spec ID, if one is set.
func (*DB) FocusedSpecSet ¶
FocusedSpecSet stores the globally focused spec ID.
func (*DB) SessionDelete ¶
SessionDelete removes a session.
func (*DB) SessionGet ¶
SessionGet retrieves the session state JSON for a spec.
func (*DB) SessionList ¶
SessionList returns all active sessions.
func (*DB) SessionMostRecent ¶
SessionMostRecent returns the spec ID of the most recently updated session.
func (*DB) SessionSet ¶
SessionSet stores session state for a spec.
func (*DB) SyncStateForSpec ¶
SyncStateForSpec returns all sync state entries for a spec keyed by section and direction.
func (*DB) SyncStateGet ¶
func (db *DB) SyncStateGet(specID, section, direction string) (*SyncStateEntry, error)
SyncStateGet returns the last synced hash for a spec section and direction.
func (*DB) SyncStateSet ¶
SyncStateSet upserts the last synced hash for a spec section and direction.