store

package
v0.67.8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package store is the durable backend for transcriptions, quick notes, voice-agent session summaries, persona catalog (M5b), and wake-word activation audio. SQLite is the default for the Wails desktop bundle; PostgreSQL is used by the Linux Server-Target behind the Render private network. Same Store interface; the backend is picked from StoreConfig.Backend.

Audit 2026-05-24 maintainability sweep.

Index

Constants

View Source
const (
	WakewordLabelCorrect       = "correct"
	WakewordLabelFalsePositive = "false_positive"
	WakewordLabelUnknown       = ""
)

Valid wake-word activation label values. Empty string means "unlabeled" — the user has not yet reviewed the clip. Any other value is rejected by UpdateWakewordActivationLabel.

View Source
const (
	RecordingSegmentSpeakerMe     = "me"
	RecordingSegmentSpeakerOthers = "them"
)

Meeting capture records who a segment came from without acoustic diarization: the microphone channel is the local user, the system loopback channel is everyone else on the call. Acoustic diarization refines the loopback side into individual speakers later.

Variables

View Source
var ErrInvalidWakewordActivation = errors.New("store: wakeword activation missing required fields (id, owner_user_id, owner_org_id, audio_path)")

ErrInvalidWakewordActivation signals that a SaveWakewordActivation call was passed a row missing one of the required fields (id, owner_user_id, owner_org_id, audio_path). Returned before any database touch so the REST handler can surface a clear 400.

Functions

func RegisterBackend

func RegisterBackend(name string, factory BackendFactory)

RegisterBackend allows external modules (e.g. kombify) to register custom backends. Called from init() in private modules -- SpeechKit itself never knows about kombify.

func ValidWakewordLabel added in v0.37.8

func ValidWakewordLabel(s string) bool

ValidWakewordLabel reports whether s is one of the three canonical label values. Exported so the REST handler can reject bad PATCH payloads with a clear 400 before reaching the store.

func WithRecordOwner added in v0.30.0

func WithRecordOwner(ctx context.Context, owner RecordOwner) context.Context

Types

type AudioAsset

type AudioAsset struct {
	StorageKind AudioStorageKind `json:"storageKind"`
	Path        string           `json:"-"`
	MimeType    string           `json:"mimeType"`
	SizeBytes   int64            `json:"sizeBytes"`
	DurationMs  int64            `json:"durationMs"`
}

type AudioAssetInput added in v0.30.0

type AudioAssetInput struct {
	Data       []byte
	MimeType   string
	Extension  string
	DurationMs int64
}

type AudioAssetStore added in v0.31.0

type AudioAssetStore interface {
	GetAudioAsset(ctx context.Context, ownerKind string, ownerID int64) (*AudioAsset, error)
}

AudioAssetStore is an optional extension for backends that persist first-class audio asset metadata alongside legacy audio_path columns.

type AudioStorageKind

type AudioStorageKind string
const (
	AudioStorageLocalFile AudioStorageKind = "local-file"
)

type BackendFactory

type BackendFactory func(cfg StoreConfig) (Store, error)

BackendFactory creates a Store from config.

type CustomizationListOpts added in v0.45.0

type CustomizationListOpts = speechcustomize.ListOptions

type CustomizationReplaceOpts added in v0.45.0

type CustomizationReplaceOpts = speechcustomize.ReplaceOptions

type CustomizationSourceStore added in v0.45.0

type CustomizationSourceStore interface {
	ReplaceWordsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word) error
	ReplaceReplacementsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, replacements []speechcustomize.Replacement) error
	ReplaceLexiconsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, lexicons []speechcustomize.Lexicon) error
	ReplaceRulesetsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, rulesets []speechcustomize.Ruleset) error
}

type CustomizationStore added in v0.45.0

type CustomizationStore interface {
	WordStore
	ReplacementStore
	LexiconStore
	RulesetStore
}

type CustomizationVocabularyStore added in v0.61.10

type CustomizationVocabularyStore interface {
	ReplaceVocabularyWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word, extras []speechcustomize.Replacement) error
}

type DeleteResult added in v0.35.0

type DeleteResult struct {
	RowsDeleted    int      `json:"rows_deleted"`
	AudioFilePaths []string `json:"audio_file_paths"`
}

DeleteResult is returned by DeleteScope. The caller is responsible for unlinking AudioFilePaths from disk; the store only removes DB rows.

type LexiconStore added in v0.45.0

type LexiconStore interface {
	ReplaceLexicons(ctx context.Context, language string, lexicons []speechcustomize.Lexicon) error
	ListLexicons(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Lexicon, error)
}

type ListOpts

type ListOpts struct {
	Limit            int
	Offset           int
	Language         string
	After            time.Time
	OwnerUserID      string
	OwnerOrgID       string
	IncludeOwnerless bool
	IncludeAllOwners bool
	// Kind filters recording sessions by normalized kind ("meeting",
	// "dictation"); empty means all kinds. Only list queries over recording
	// sessions honor it.
	Kind string
}

ListOpts controls pagination and filtering for list queries.

type MeetingSummaryBatch added in v0.67.0

type MeetingSummaryBatch struct {
	ID                int64                     `json:"id"`
	SessionID         int64                     `json:"sessionId"`
	BatchKey          string                    `json:"batchKey"`
	Level             int                       `json:"level"`
	StartSegmentID    int64                     `json:"startSegmentId"`
	EndSegmentID      int64                     `json:"endSegmentId"`
	SourceFingerprint string                    `json:"sourceFingerprint"`
	Status            MeetingSummaryBatchStatus `json:"status"`
	DigestJSON        string                    `json:"digestJson,omitempty"`
	Provider          string                    `json:"provider,omitempty"`
	Model             string                    `json:"model,omitempty"`
	ErrorKind         string                    `json:"errorKind,omitempty"`
	CreatedAt         time.Time                 `json:"createdAt"`
	UpdatedAt         time.Time                 `json:"updatedAt"`
}

MeetingSummaryBatch is transcript-derived and follows its meeting's deletion and retention lifecycle through the database foreign key.

type MeetingSummaryBatchStatus added in v0.67.0

type MeetingSummaryBatchStatus string
const (
	MeetingSummaryBatchSealed      MeetingSummaryBatchStatus = "sealed"
	MeetingSummaryBatchQueued      MeetingSummaryBatchStatus = "queued"
	MeetingSummaryBatchSummarizing MeetingSummaryBatchStatus = "summarizing"
	MeetingSummaryBatchReady       MeetingSummaryBatchStatus = "ready"
	MeetingSummaryBatchDelayed     MeetingSummaryBatchStatus = "delayed"
	MeetingSummaryBatchFailed      MeetingSummaryBatchStatus = "failed"
	MeetingSummaryBatchSuperseded  MeetingSummaryBatchStatus = "superseded"
)

type MeetingSummaryBatchStore added in v0.67.0

type MeetingSummaryBatchStore interface {
	UpsertMeetingSummaryBatch(ctx context.Context, batch MeetingSummaryBatch) (MeetingSummaryBatch, error)
	ListMeetingSummaryBatches(ctx context.Context, sessionID int64) ([]MeetingSummaryBatch, error)
}

type PostgresStore

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

PostgresStore implements Store using PostgreSQL for metadata and the local filesystem for optional raw WAV persistence. All query logic lives in the embedded *sqlStore; this type only owns connection setup and migrations.

func NewPostgresStore

func NewPostgresStore(cfg StoreConfig) (*PostgresStore, error)

NewPostgresStore creates a PostgreSQL-backed store.

func (PostgresStore) AppendRecordingSessionSegment added in v0.48.0

func (s PostgresStore) AppendRecordingSessionSegment(ctx context.Context, sessionID int64, segment RecordingSessionSegment) (int64, error)

func (PostgresStore) Close

func (s PostgresStore) Close() error

func (PostgresStore) CountWakewordActivationsForUser added in v0.37.8

func (s PostgresStore) CountWakewordActivationsForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)

func (PostgresStore) CreateRecordingSessionEnhancement added in v0.59.0

func (s PostgresStore) CreateRecordingSessionEnhancement(ctx context.Context, sessionID int64, enhancement RecordingSessionEnhancement) (int64, error)

CreateRecordingSessionEnhancement opens a write-up run. It starts as running because it is created by the job that is about to do the work.

func (PostgresStore) DB added in v0.29.0

func (s PostgresStore) DB() *sql.DB

DB exposes the underlying *sql.DB so adjacent packages can build their own table-scoped persisters without the base Store interface enumerating every optional capability. Callers must treat the handle as read-mostly: it is owned by the Store and must not be closed.

func (PostgresStore) DeleteQuickNote

func (s PostgresStore) DeleteQuickNote(ctx context.Context, id int64) error

func (PostgresStore) DeleteRecordingSession added in v0.48.0

func (s PostgresStore) DeleteRecordingSession(ctx context.Context, id int64) error

func (PostgresStore) DeleteRecordingSessionSnapshot added in v0.67.7

func (s PostgresStore) DeleteRecordingSessionSnapshot(ctx context.Context, id int64) error

DeleteRecordingSessionSnapshot removes the row and its image file.

func (PostgresStore) DeleteScope added in v0.35.0

func (s PostgresStore) DeleteScope(ctx context.Context, scope speechstorage.Scope) (DeleteResult, error)

DeleteScope removes all user-owned DB rows for the given scope across every scoped table and returns a DeleteResult with the total count of deleted rows and the distinct audio file paths that were stored under that scope (GDPR Art. 17).

Deletion order respects foreign-key constraints:

  1. Collect audio file paths (before rows are gone)
  2. Link tables (transcription_audio_assets, quick_note_audio_assets)
  3. audio_assets
  4. voice_agent_session_turns, voice_agent_session_summary_items
  5. recording_session_segments, recording_session_notes, recording_sessions
  6. voice_agent_sessions
  7. transcriptions
  8. quick_notes
  9. user_dictionary_entries
  10. store_stats row (reset to zero counts)

NOTE: Audio files on disk are NOT deleted here; only DB rows are removed. The caller receives AudioFilePaths in the returned DeleteResult and is responsible for unlinking them.

func (PostgresStore) DeleteWakewordActivation added in v0.37.8

func (s PostgresStore) DeleteWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (string, error)

DeleteWakewordActivation removes the row and returns its audio_path via a single DELETE ... RETURNING — supported by PostgreSQL and SQLite 3.35+ (modernc.org/sqlite), so both backends share one statement.

func (PostgresStore) ExportScope added in v0.35.0

func (s PostgresStore) ExportScope(ctx context.Context, scope speechstorage.Scope) (*ScopeExport, error)

ExportScope returns all user-owned records for the given scope (GDPR Art. 15).

Implementation notes:

  • Fetches all rows for the scope without pagination (no LIMIT imposed).
  • Audio file paths are collected from audio_assets so the caller can stream raw bytes alongside the exported JSON if needed.
  • Read-only; never modifies data.

func (PostgresStore) FinishRecordingSession added in v0.48.0

func (s PostgresStore) FinishRecordingSession(ctx context.Context, id int64, summary string, endedAt time.Time) error

func (*PostgresStore) GetAudioAsset added in v0.31.0

func (s *PostgresStore) GetAudioAsset(ctx context.Context, ownerKind string, ownerID int64) (*AudioAsset, error)

func (PostgresStore) GetQuickNote

func (s PostgresStore) GetQuickNote(ctx context.Context, id int64) (*QuickNote, error)

func (PostgresStore) GetRecordingSession added in v0.48.0

func (s PostgresStore) GetRecordingSession(ctx context.Context, id int64) (*RecordingSession, error)

func (PostgresStore) GetRecordingSessionNotes added in v0.59.0

func (s PostgresStore) GetRecordingSessionNotes(ctx context.Context, sessionID int64) (*RecordingSessionNotes, error)

GetRecordingSessionNotes returns the meeting's notes. A meeting nobody typed into has empty notes rather than none, so callers do not need to distinguish "not written yet" from "written and cleared".

func (PostgresStore) GetRecordingSessionSnapshot added in v0.67.7

func (s PostgresStore) GetRecordingSessionSnapshot(ctx context.Context, id int64) (*RecordingSessionSnapshot, error)

GetRecordingSessionSnapshot returns one snapshot, path included, so callers can serve the image file. Missing snapshots return sql.ErrNoRows.

func (PostgresStore) GetTranscription

func (s PostgresStore) GetTranscription(ctx context.Context, id int64) (*Transcription, error)

func (PostgresStore) GetVoiceAgentSession added in v0.30.0

func (s PostgresStore) GetVoiceAgentSession(ctx context.Context, id int64) (*VoiceAgentSession, error)

func (PostgresStore) GetWakewordActivation added in v0.37.8

func (s PostgresStore) GetWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (*WakewordActivation, error)

func (PostgresStore) ListLexicons added in v0.45.0

func (s PostgresStore) ListLexicons(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Lexicon, error)

func (PostgresStore) ListMeetingSummaryBatches added in v0.67.0

func (s PostgresStore) ListMeetingSummaryBatches(ctx context.Context, sessionID int64) ([]MeetingSummaryBatch, error)

func (PostgresStore) ListQuickNotes

func (s PostgresStore) ListQuickNotes(ctx context.Context, opts ListOpts) ([]QuickNote, error)

func (PostgresStore) ListRecordingSessionEnhancements added in v0.59.0

func (s PostgresStore) ListRecordingSessionEnhancements(ctx context.Context, sessionID int64) ([]RecordingSessionEnhancement, error)

ListRecordingSessionEnhancements returns the write-ups of one meeting, newest first, so a caller can show the current one and offer the earlier takes without a second query.

func (PostgresStore) ListRecordingSessionSnapshots added in v0.67.7

func (s PostgresStore) ListRecordingSessionSnapshots(ctx context.Context, sessionID int64) ([]RecordingSessionSnapshot, error)

ListRecordingSessionSnapshots returns the session's snapshots in timeline order.

func (PostgresStore) ListRecordingSessions added in v0.48.0

func (s PostgresStore) ListRecordingSessions(ctx context.Context, opts ListOpts) ([]RecordingSession, error)

func (PostgresStore) ListReplacements added in v0.45.0

func (s PostgresStore) ListReplacements(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Replacement, error)

func (PostgresStore) ListRulesets added in v0.45.0

func (s PostgresStore) ListRulesets(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Ruleset, error)

func (PostgresStore) ListTranscriptions

func (s PostgresStore) ListTranscriptions(ctx context.Context, opts ListOpts) ([]Transcription, error)

func (PostgresStore) ListUserDictionaryEntries added in v0.22.4

func (s PostgresStore) ListUserDictionaryEntries(ctx context.Context, language string) ([]UserDictionaryEntry, error)

func (PostgresStore) ListVoiceAgentSessions added in v0.24.0

func (s PostgresStore) ListVoiceAgentSessions(ctx context.Context, opts ListOpts) ([]VoiceAgentSession, error)

func (PostgresStore) ListWakewordActivations added in v0.37.8

func (s PostgresStore) ListWakewordActivations(ctx context.Context, ownerUserID, ownerOrgID string, opts ListOpts) ([]WakewordActivation, error)

func (PostgresStore) ListWords added in v0.45.0

func (s PostgresStore) ListWords(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Word, error)

func (PostgresStore) PinQuickNote

func (s PostgresStore) PinQuickNote(ctx context.Context, id int64, pinned bool) error

func (PostgresStore) QuickNoteCount

func (s PostgresStore) QuickNoteCount(ctx context.Context) (int, error)

func (PostgresStore) RecordReplacementUsage added in v0.45.0

func (s PostgresStore) RecordReplacementUsage(ctx context.Context, id string) error

func (PostgresStore) RecordUserDictionaryUsage added in v0.22.4

func (s PostgresStore) RecordUserDictionaryUsage(ctx context.Context, canonical, language string) error

func (PostgresStore) RecordWordUsage added in v0.45.0

func (s PostgresStore) RecordWordUsage(ctx context.Context, term, language string) error

func (PostgresStore) ReplaceLexicons added in v0.45.0

func (s PostgresStore) ReplaceLexicons(ctx context.Context, language string, lexicons []speechcustomize.Lexicon) error

func (PostgresStore) ReplaceLexiconsWithOptions added in v0.45.0

func (s PostgresStore) ReplaceLexiconsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, lexicons []speechcustomize.Lexicon) error

func (PostgresStore) ReplaceReplacements added in v0.45.0

func (s PostgresStore) ReplaceReplacements(ctx context.Context, language string, replacements []speechcustomize.Replacement) error

func (PostgresStore) ReplaceReplacementsWithOptions added in v0.45.0

func (s PostgresStore) ReplaceReplacementsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, replacements []speechcustomize.Replacement) error

func (PostgresStore) ReplaceRulesets added in v0.45.0

func (s PostgresStore) ReplaceRulesets(ctx context.Context, language string, rulesets []speechcustomize.Ruleset) error

func (PostgresStore) ReplaceRulesetsWithOptions added in v0.45.0

func (s PostgresStore) ReplaceRulesetsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, rulesets []speechcustomize.Ruleset) error

func (PostgresStore) ReplaceUserDictionaryEntries added in v0.22.4

func (s PostgresStore) ReplaceUserDictionaryEntries(ctx context.Context, language string, entries []UserDictionaryEntry) error

func (PostgresStore) ReplaceVocabularyWithOptions added in v0.61.10

func (s PostgresStore) ReplaceVocabularyWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word, extras []speechcustomize.Replacement) error

func (PostgresStore) ReplaceWords added in v0.45.0

func (s PostgresStore) ReplaceWords(ctx context.Context, language string, words []speechcustomize.Word) error

func (PostgresStore) ReplaceWordsWithOptions added in v0.45.0

func (s PostgresStore) ReplaceWordsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word) error

func (PostgresStore) SaveQuickNote

func (s PostgresStore) SaveQuickNote(ctx context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)

func (PostgresStore) SaveRecordingSession added in v0.48.0

func (s PostgresStore) SaveRecordingSession(ctx context.Context, session RecordingSession) (int64, error)

func (PostgresStore) SaveRecordingSessionNotes added in v0.59.0

func (s PostgresStore) SaveRecordingSessionNotes(ctx context.Context, sessionID int64, notes RecordingSessionNotes) error

SaveRecordingSessionNotes replaces the notes of one meeting. The note pane is autosaved as the user types, so this is an upsert on the session rather than an append.

func (PostgresStore) SaveRecordingSessionSnapshot added in v0.67.7

func (s PostgresStore) SaveRecordingSessionSnapshot(ctx context.Context, sessionID int64, input RecordingSessionSnapshotInput) (*RecordingSessionSnapshot, error)

SaveRecordingSessionSnapshot writes the image to the snapshot directory and records it against the session. Snapshots are captured locally and stay local: the file never leaves the machine through this package.

func (PostgresStore) SaveTranscription

func (s PostgresStore) SaveTranscription(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error

func (PostgresStore) SaveTranscriptionWithAudio added in v0.30.0

func (s PostgresStore) SaveTranscriptionWithAudio(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput) error

func (PostgresStore) SaveTranscriptionWithAudioAndSpeakers added in v0.42.0

func (s PostgresStore) SaveTranscriptionWithAudioAndSpeakers(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput, speakers *speaker.DiarizationResult) error

func (PostgresStore) SaveVoiceAgentSession added in v0.24.0

func (s PostgresStore) SaveVoiceAgentSession(ctx context.Context, session VoiceAgentSession) (int64, error)

func (PostgresStore) SaveWakewordActivation added in v0.37.8

func (s PostgresStore) SaveWakewordActivation(ctx context.Context, a WakewordActivation) (*WakewordActivation, error)

func (PostgresStore) SemanticCapabilities

func (s PostgresStore) SemanticCapabilities(context.Context) SemanticCapabilities

func (PostgresStore) SetRecordingSessionPinned added in v0.59.0

func (s PostgresStore) SetRecordingSessionPinned(ctx context.Context, id int64, pinned bool) error

SetRecordingSessionPinned keeps one meeting out of the retention sweep.

func (PostgresStore) Stats

func (s PostgresStore) Stats(ctx context.Context) (Stats, error)

func (PostgresStore) SumWakewordActivationBytesForUser added in v0.37.8

func (s PostgresStore) SumWakewordActivationBytesForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)

func (PostgresStore) TranscriptionCount

func (s PostgresStore) TranscriptionCount(ctx context.Context) (int, error)

func (PostgresStore) UpdateQuickNote

func (s PostgresStore) UpdateQuickNote(ctx context.Context, id int64, text string) error

func (PostgresStore) UpdateQuickNoteCapture

func (s PostgresStore) UpdateQuickNoteCapture(ctx context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error

func (PostgresStore) UpdateRecordingSessionCaptureStatus added in v0.48.0

func (s PostgresStore) UpdateRecordingSessionCaptureStatus(ctx context.Context, id int64, status RecordingSessionCaptureStatus, at time.Time) error

func (PostgresStore) UpdateRecordingSessionEnhancement added in v0.59.0

func (s PostgresStore) UpdateRecordingSessionEnhancement(ctx context.Context, id int64, enhancement RecordingSessionEnhancement) error

UpdateRecordingSessionEnhancement records the outcome of a write-up run.

func (PostgresStore) UpdateRecordingSessionSummary added in v0.48.0

func (s PostgresStore) UpdateRecordingSessionSummary(ctx context.Context, id int64, summary string) error

func (PostgresStore) UpdateRecordingSessionSummaryStatus added in v0.48.0

func (s PostgresStore) UpdateRecordingSessionSummaryStatus(ctx context.Context, id int64, status RecordingSessionSummaryStatus, message string, at time.Time) error

func (PostgresStore) UpdateWakewordActivationLabel added in v0.37.8

func (s PostgresStore) UpdateWakewordActivationLabel(ctx context.Context, id, ownerUserID, ownerOrgID, label string) error

func (PostgresStore) UpsertMeetingSummaryBatch added in v0.67.0

func (s PostgresStore) UpsertMeetingSummaryBatch(ctx context.Context, batch MeetingSummaryBatch) (MeetingSummaryBatch, error)

type QuickNote

type QuickNote struct {
	ID         int64
	Text       string
	Language   string
	Provider   string
	DurationMs int64
	LatencyMs  int64
	AudioPath  string
	Audio      *AudioAsset
	Pinned     bool
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

QuickNote represents a user-created dictation note.

type RecordOwner added in v0.30.0

type RecordOwner struct {
	UserID string
	OrgID  string
	Source string
}

RecordOwner captures the caller identity persisted with server-owned records. Store does not import server middleware, so HTTP handlers translate auth identity into this small value.

func RecordOwnerFromContext added in v0.30.0

func RecordOwnerFromContext(ctx context.Context) (RecordOwner, bool)

type RecordingSession added in v0.48.0

type RecordingSession struct {
	ID               int64                         `json:"id"`
	ExternalID       string                        `json:"externalId,omitempty"`
	Kind             RecordingSessionKind          `json:"kind"`
	Status           RecordingSessionStatus        `json:"status"`
	CaptureStatus    RecordingSessionCaptureStatus `json:"captureStatus"`
	SummaryStatus    RecordingSessionSummaryStatus `json:"summaryStatus"`
	SummaryError     string                        `json:"summaryError,omitempty"`
	Title            string                        `json:"title,omitempty"`
	Language         string                        `json:"language"`
	Provider         string                        `json:"provider,omitempty"`
	Model            string                        `json:"model,omitempty"`
	InputSource      string                        `json:"inputSource,omitempty"`
	ProcessingMode   string                        `json:"processingMode,omitempty"`
	Summary          string                        `json:"summary,omitempty"`
	StartedAt        time.Time                     `json:"startedAt"`
	EndedAt          time.Time                     `json:"endedAt,omitempty"`
	CaptureStartedAt time.Time                     `json:"captureStartedAt,omitempty"`
	CapturePausedAt  time.Time                     `json:"capturePausedAt,omitempty"`
	CaptureStoppedAt time.Time                     `json:"captureStoppedAt,omitempty"`
	SummaryUpdatedAt time.Time                     `json:"summaryUpdatedAt,omitempty"`
	CreatedAt        time.Time                     `json:"createdAt"`
	UpdatedAt        time.Time                     `json:"updatedAt"`
	OwnerUserID      string                        `json:"ownerUserId,omitempty"`
	OwnerOrgID       string                        `json:"ownerOrgId,omitempty"`
	OwnerSource      string                        `json:"ownerSource,omitempty"`
	Segments         []RecordingSessionSegment     `json:"segments,omitempty"`
	// Notes are the user's own notes for this meeting. Only loaded where they
	// matter — the session detail and subject exports — not in list responses.
	Notes *RecordingSessionNotes `json:"notes,omitempty"`
	// Snapshots are the screen captures taken during this meeting. Loaded like
	// Notes only on the session detail, not in list responses.
	Snapshots []RecordingSessionSnapshot `json:"snapshots,omitempty"`
	// RetentionPinned keeps this meeting even once it is past the retention
	// window.
	RetentionPinned bool `json:"retentionPinned,omitempty"`
}

type RecordingSessionCaptureStatus added in v0.48.0

type RecordingSessionCaptureStatus string
const (
	RecordingSessionCaptureIdle      RecordingSessionCaptureStatus = "idle"
	RecordingSessionCaptureRecording RecordingSessionCaptureStatus = "recording"
	RecordingSessionCapturePaused    RecordingSessionCaptureStatus = "paused"
	RecordingSessionCaptureStopped   RecordingSessionCaptureStatus = "stopped"
)

type RecordingSessionEnhancement added in v0.59.0

type RecordingSessionEnhancement struct {
	ID           int64  `json:"id"`
	SessionID    int64  `json:"sessionId"`
	TemplateSlug string `json:"templateSlug"`
	// TemplateSnapshot is the template as it was when this write-up ran, so an
	// old result stays explicable after the template's wording changes.
	TemplateSnapshot string                            `json:"templateSnapshot,omitempty"`
	Status           RecordingSessionEnhancementStatus `json:"status"`
	Error            string                            `json:"error,omitempty"`
	Provider         string                            `json:"provider,omitempty"`
	Model            string                            `json:"model,omitempty"`
	Stage            string                            `json:"stage,omitempty"`
	Progress         int                               `json:"progress"`
	Attempt          int                               `json:"attempt"`
	InputFingerprint string                            `json:"inputFingerprint,omitempty"`
	ErrorKind        string                            `json:"errorKind,omitempty"`
	Retryable        bool                              `json:"retryable"`
	ConsentVersion   int                               `json:"consentVersion,omitempty"`
	// Structured is false when the model could not produce citable structure
	// and the notes are prose. Callers surface that rather than implying the
	// bullets can be traced back to the transcript.
	Structured bool `json:"structured"`
	// ContentJSON is the structured document; ContentMD is it rendered for
	// reading, copying and export.
	ContentJSON string    `json:"contentJson,omitempty"`
	ContentMD   string    `json:"contentMd,omitempty"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
}

RecordingSessionEnhancement is one written-up version of a meeting.

type RecordingSessionEnhancementStatus added in v0.59.0

type RecordingSessionEnhancementStatus string
const (
	RecordingSessionEnhancementIdle      RecordingSessionEnhancementStatus = "idle"
	RecordingSessionEnhancementPending   RecordingSessionEnhancementStatus = "pending"
	RecordingSessionEnhancementRunning   RecordingSessionEnhancementStatus = "running"
	RecordingSessionEnhancementPartial   RecordingSessionEnhancementStatus = "partial"
	RecordingSessionEnhancementReady     RecordingSessionEnhancementStatus = "ready"
	RecordingSessionEnhancementFailed    RecordingSessionEnhancementStatus = "failed"
	RecordingSessionEnhancementCancelled RecordingSessionEnhancementStatus = "cancelled"
)

type RecordingSessionEnhancementStore added in v0.59.0

type RecordingSessionEnhancementStore interface {
	CreateRecordingSessionEnhancement(ctx context.Context, sessionID int64, enhancement RecordingSessionEnhancement) (int64, error)
	UpdateRecordingSessionEnhancement(ctx context.Context, id int64, enhancement RecordingSessionEnhancement) error
	ListRecordingSessionEnhancements(ctx context.Context, sessionID int64) ([]RecordingSessionEnhancement, error)
}

RecordingSessionEnhancementStore is an optional extension for backends that persist written-up meeting notes. A meeting can have several: writing it up again with a different template produces a new one rather than replacing the one the user may still prefer.

type RecordingSessionKind added in v0.48.0

type RecordingSessionKind string
const (
	RecordingSessionKindDictation RecordingSessionKind = "dictation"
	RecordingSessionKindMeeting   RecordingSessionKind = "meeting"
)

type RecordingSessionNoteBlock added in v0.59.0

type RecordingSessionNoteBlock struct {
	// ID is stable for the lifetime of the note so an enhanced bullet can
	// point back at the note it came from.
	ID   string `json:"id"`
	Text string `json:"text"`
	// TsMs is when the note was written, relative to the meeting's start.
	TsMs int64 `json:"tsMs"`
}

RecordingSessionNoteBlock is a single note the user typed.

type RecordingSessionNotes added in v0.59.0

type RecordingSessionNotes struct {
	SessionID int64 `json:"sessionId"`
	// ContentMD is the note pane as the user last left it.
	ContentMD string `json:"contentMd"`
	// Blocks splits that text into the individual notes, each stamped with the
	// point in the meeting it was written at. The enhancement uses those
	// timestamps to find the part of the conversation a note was about.
	Blocks    []RecordingSessionNoteBlock `json:"blocks"`
	CreatedAt time.Time                   `json:"createdAt,omitempty"`
	UpdatedAt time.Time                   `json:"updatedAt,omitempty"`
}

RecordingSessionNotes is one meeting's hand-written notes.

type RecordingSessionNotesStore added in v0.59.0

type RecordingSessionNotesStore interface {
	SaveRecordingSessionNotes(ctx context.Context, sessionID int64, notes RecordingSessionNotes) error
	GetRecordingSessionNotes(ctx context.Context, sessionID int64) (*RecordingSessionNotes, error)
}

RecordingSessionNotesStore is an optional extension for backends that persist the notes a user writes during a meeting. They are kept apart from the transcript and from anything a model generates, because the enhancement treats them as anchors and reproduces them verbatim.

type RecordingSessionSegment added in v0.48.0

type RecordingSessionSegment struct {
	ID        int64 `json:"id"`
	SessionID int64 `json:"sessionId"`
	// SegmentIndex orders segments within one session. Pass a negative value
	// to AppendRecordingSessionSegment to have the store allocate the next
	// free index, which is what concurrent capture channels need; an explicit
	// index upserts the row at that position (the segment-edit path).
	SegmentIndex    int    `json:"segmentIndex"`
	TranscriptionID int64  `json:"transcriptionId,omitempty"`
	ProviderItemID  string `json:"providerItemId,omitempty"`
	Text            string `json:"text"`
	IsFinal         bool   `json:"isFinal"`
	// Channel names the capture source this segment was transcribed from
	// (see speechkit.CaptureChannel*). Empty for single-source sessions.
	Channel string `json:"channel,omitempty"`
	// Speaker labels who spoke, derived from Channel today.
	Speaker   string    `json:"speaker,omitempty"`
	StartedMs int64     `json:"startedMs"`
	EndedMs   int64     `json:"endedMs"`
	CreatedAt time.Time `json:"createdAt"`
}

type RecordingSessionSnapshot added in v0.67.7

type RecordingSessionSnapshot struct {
	ID         int64 `json:"id"`
	SessionID  int64 `json:"sessionId"`
	CapturedMs int64 `json:"capturedMs"`
	// Path is the absolute local file path; images are served by ID, so the
	// path stays out of API payloads.
	Path      string `json:"-"`
	MimeType  string `json:"mimeType"`
	SizeBytes int64  `json:"sizeBytes"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
	Monitor   string `json:"monitor,omitempty"`
	Note      string `json:"note,omitempty"`
	// Description is filled by the optional vision enrichment (V2).
	Description string    `json:"description,omitempty"`
	CreatedAt   time.Time `json:"createdAt"`
}

RecordingSessionSnapshot is one stored screen capture of a meeting.

type RecordingSessionSnapshotInput added in v0.67.7

type RecordingSessionSnapshotInput struct {
	// CapturedMs is the offset on the meeting's transcript timeline:
	// wall-clock milliseconds since the capture epoch, the same time base
	// segment StartedMs/EndedMs are stamped with (see Runtime.ElapsedMs).
	CapturedMs int64
	// Data is the encoded image; MimeType defaults to image/png.
	Data     []byte
	MimeType string
	Width    int
	Height   int
	Monitor  string
	Note     string
}

RecordingSessionSnapshotInput carries a freshly captured screenshot into the store.

type RecordingSessionSnapshotStore added in v0.67.7

type RecordingSessionSnapshotStore interface {
	SaveRecordingSessionSnapshot(ctx context.Context, sessionID int64, input RecordingSessionSnapshotInput) (*RecordingSessionSnapshot, error)
	GetRecordingSessionSnapshot(ctx context.Context, id int64) (*RecordingSessionSnapshot, error)
	ListRecordingSessionSnapshots(ctx context.Context, sessionID int64) ([]RecordingSessionSnapshot, error)
	DeleteRecordingSessionSnapshot(ctx context.Context, id int64) error
}

RecordingSessionSnapshotStore is an optional extension for backends that persist ad-hoc screen captures taken during a meeting. The store owns the image files: saving writes the bytes under its snapshot directory, deleting a snapshot or its session removes them again.

type RecordingSessionStatus added in v0.48.0

type RecordingSessionStatus string
const (
	RecordingSessionStatusActive   RecordingSessionStatus = "active"
	RecordingSessionStatusFinished RecordingSessionStatus = "finished"
	RecordingSessionStatusFailed   RecordingSessionStatus = "failed"
)

type RecordingSessionStore added in v0.48.0

type RecordingSessionStore interface {
	SaveRecordingSession(ctx context.Context, session RecordingSession) (int64, error)
	ListRecordingSessions(ctx context.Context, opts ListOpts) ([]RecordingSession, error)
	AppendRecordingSessionSegment(ctx context.Context, sessionID int64, segment RecordingSessionSegment) (int64, error)
	UpdateRecordingSessionSummary(ctx context.Context, id int64, summary string) error
	UpdateRecordingSessionCaptureStatus(ctx context.Context, id int64, status RecordingSessionCaptureStatus, at time.Time) error
	UpdateRecordingSessionSummaryStatus(ctx context.Context, id int64, status RecordingSessionSummaryStatus, message string, at time.Time) error
	FinishRecordingSession(ctx context.Context, id int64, summary string, endedAt time.Time) error
	GetRecordingSession(ctx context.Context, id int64) (*RecordingSession, error)
	DeleteRecordingSession(ctx context.Context, id int64) error
	// SetRecordingSessionPinned keeps one meeting out of the retention sweep.
	SetRecordingSessionPinned(ctx context.Context, id int64, pinned bool) error
}

RecordingSessionStore is an optional extension for long-running dictation and meeting capture sessions. Segment rows can link to ordinary transcriptions, so the existing dashboard/library records stay reusable.

type RecordingSessionSummaryStatus added in v0.48.0

type RecordingSessionSummaryStatus string
const (
	RecordingSessionSummaryIdle    RecordingSessionSummaryStatus = "idle"
	RecordingSessionSummaryRunning RecordingSessionSummaryStatus = "running"
	RecordingSessionSummaryReady   RecordingSessionSummaryStatus = "ready"
	RecordingSessionSummaryFailed  RecordingSessionSummaryStatus = "failed"
)

type ReplacementStore added in v0.45.0

type ReplacementStore interface {
	ReplaceReplacements(ctx context.Context, language string, replacements []speechcustomize.Replacement) error
	ListReplacements(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Replacement, error)
	RecordReplacementUsage(ctx context.Context, id string) error
}

type RulesetStore added in v0.45.0

type RulesetStore interface {
	ReplaceRulesets(ctx context.Context, language string, rulesets []speechcustomize.Ruleset) error
	ListRulesets(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Ruleset, error)
}

type SQLiteStore

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

SQLiteStore implements Store using a local SQLite database via modernc.org/sqlite (pure Go, no CGo required). All query logic lives in the embedded *sqlStore; this type only owns connection setup and migrations.

func NewSQLiteStore

func NewSQLiteStore(cfg StoreConfig) (*SQLiteStore, error)

NewSQLiteStore opens or creates a SQLite feedback database.

func (SQLiteStore) AppendRecordingSessionSegment added in v0.48.0

func (s SQLiteStore) AppendRecordingSessionSegment(ctx context.Context, sessionID int64, segment RecordingSessionSegment) (int64, error)

func (SQLiteStore) Close

func (s SQLiteStore) Close() error

func (SQLiteStore) CountWakewordActivationsForUser added in v0.37.8

func (s SQLiteStore) CountWakewordActivationsForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)

func (SQLiteStore) CreateRecordingSessionEnhancement added in v0.59.0

func (s SQLiteStore) CreateRecordingSessionEnhancement(ctx context.Context, sessionID int64, enhancement RecordingSessionEnhancement) (int64, error)

CreateRecordingSessionEnhancement opens a write-up run. It starts as running because it is created by the job that is about to do the work.

func (SQLiteStore) DB added in v0.26.0

func (s SQLiteStore) DB() *sql.DB

DB exposes the underlying *sql.DB so adjacent packages can build their own table-scoped persisters without the base Store interface enumerating every optional capability. Callers must treat the handle as read-mostly: it is owned by the Store and must not be closed.

func (SQLiteStore) DeleteQuickNote

func (s SQLiteStore) DeleteQuickNote(ctx context.Context, id int64) error

func (SQLiteStore) DeleteRecordingSession added in v0.48.0

func (s SQLiteStore) DeleteRecordingSession(ctx context.Context, id int64) error

func (SQLiteStore) DeleteRecordingSessionSnapshot added in v0.67.7

func (s SQLiteStore) DeleteRecordingSessionSnapshot(ctx context.Context, id int64) error

DeleteRecordingSessionSnapshot removes the row and its image file.

func (SQLiteStore) DeleteScope added in v0.35.0

func (s SQLiteStore) DeleteScope(ctx context.Context, scope speechstorage.Scope) (DeleteResult, error)

DeleteScope removes all user-owned DB rows for the given scope across every scoped table and returns a DeleteResult with the total count of deleted rows and the distinct audio file paths that were stored under that scope (GDPR Art. 17).

Deletion order respects foreign-key constraints:

  1. Collect audio file paths (before rows are gone)
  2. Link tables (transcription_audio_assets, quick_note_audio_assets)
  3. audio_assets
  4. voice_agent_session_turns, voice_agent_session_summary_items
  5. recording_session_segments, recording_session_notes, recording_sessions
  6. voice_agent_sessions
  7. transcriptions
  8. quick_notes
  9. user_dictionary_entries
  10. store_stats row (reset to zero counts)

NOTE: Audio files on disk are NOT deleted here; only DB rows are removed. The caller receives AudioFilePaths in the returned DeleteResult and is responsible for unlinking them.

func (SQLiteStore) DeleteWakewordActivation added in v0.37.8

func (s SQLiteStore) DeleteWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (string, error)

DeleteWakewordActivation removes the row and returns its audio_path via a single DELETE ... RETURNING — supported by PostgreSQL and SQLite 3.35+ (modernc.org/sqlite), so both backends share one statement.

func (SQLiteStore) ExportScope added in v0.35.0

func (s SQLiteStore) ExportScope(ctx context.Context, scope speechstorage.Scope) (*ScopeExport, error)

ExportScope returns all user-owned records for the given scope (GDPR Art. 15).

Implementation notes:

  • Fetches all rows for the scope without pagination (no LIMIT imposed).
  • Audio file paths are collected from audio_assets so the caller can stream raw bytes alongside the exported JSON if needed.
  • Read-only; never modifies data.

func (SQLiteStore) FinishRecordingSession added in v0.48.0

func (s SQLiteStore) FinishRecordingSession(ctx context.Context, id int64, summary string, endedAt time.Time) error

func (*SQLiteStore) GetAudioAsset added in v0.31.0

func (s *SQLiteStore) GetAudioAsset(ctx context.Context, ownerKind string, ownerID int64) (*AudioAsset, error)

func (SQLiteStore) GetQuickNote

func (s SQLiteStore) GetQuickNote(ctx context.Context, id int64) (*QuickNote, error)

func (SQLiteStore) GetRecordingSession added in v0.48.0

func (s SQLiteStore) GetRecordingSession(ctx context.Context, id int64) (*RecordingSession, error)

func (SQLiteStore) GetRecordingSessionNotes added in v0.59.0

func (s SQLiteStore) GetRecordingSessionNotes(ctx context.Context, sessionID int64) (*RecordingSessionNotes, error)

GetRecordingSessionNotes returns the meeting's notes. A meeting nobody typed into has empty notes rather than none, so callers do not need to distinguish "not written yet" from "written and cleared".

func (SQLiteStore) GetRecordingSessionSnapshot added in v0.67.7

func (s SQLiteStore) GetRecordingSessionSnapshot(ctx context.Context, id int64) (*RecordingSessionSnapshot, error)

GetRecordingSessionSnapshot returns one snapshot, path included, so callers can serve the image file. Missing snapshots return sql.ErrNoRows.

func (SQLiteStore) GetTranscription

func (s SQLiteStore) GetTranscription(ctx context.Context, id int64) (*Transcription, error)

func (SQLiteStore) GetVoiceAgentSession added in v0.30.0

func (s SQLiteStore) GetVoiceAgentSession(ctx context.Context, id int64) (*VoiceAgentSession, error)

func (SQLiteStore) GetWakewordActivation added in v0.37.8

func (s SQLiteStore) GetWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (*WakewordActivation, error)

func (SQLiteStore) ListLexicons added in v0.45.0

func (s SQLiteStore) ListLexicons(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Lexicon, error)

func (SQLiteStore) ListMeetingSummaryBatches added in v0.67.0

func (s SQLiteStore) ListMeetingSummaryBatches(ctx context.Context, sessionID int64) ([]MeetingSummaryBatch, error)

func (SQLiteStore) ListQuickNotes

func (s SQLiteStore) ListQuickNotes(ctx context.Context, opts ListOpts) ([]QuickNote, error)

func (SQLiteStore) ListRecordingSessionEnhancements added in v0.59.0

func (s SQLiteStore) ListRecordingSessionEnhancements(ctx context.Context, sessionID int64) ([]RecordingSessionEnhancement, error)

ListRecordingSessionEnhancements returns the write-ups of one meeting, newest first, so a caller can show the current one and offer the earlier takes without a second query.

func (SQLiteStore) ListRecordingSessionSnapshots added in v0.67.7

func (s SQLiteStore) ListRecordingSessionSnapshots(ctx context.Context, sessionID int64) ([]RecordingSessionSnapshot, error)

ListRecordingSessionSnapshots returns the session's snapshots in timeline order.

func (SQLiteStore) ListRecordingSessions added in v0.48.0

func (s SQLiteStore) ListRecordingSessions(ctx context.Context, opts ListOpts) ([]RecordingSession, error)

func (SQLiteStore) ListReplacements added in v0.45.0

func (s SQLiteStore) ListReplacements(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Replacement, error)

func (SQLiteStore) ListRulesets added in v0.45.0

func (s SQLiteStore) ListRulesets(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Ruleset, error)

func (SQLiteStore) ListTranscriptions

func (s SQLiteStore) ListTranscriptions(ctx context.Context, opts ListOpts) ([]Transcription, error)

func (SQLiteStore) ListUserDictionaryEntries added in v0.22.4

func (s SQLiteStore) ListUserDictionaryEntries(ctx context.Context, language string) ([]UserDictionaryEntry, error)

func (SQLiteStore) ListVoiceAgentSessions added in v0.24.0

func (s SQLiteStore) ListVoiceAgentSessions(ctx context.Context, opts ListOpts) ([]VoiceAgentSession, error)

func (SQLiteStore) ListWakewordActivations added in v0.37.8

func (s SQLiteStore) ListWakewordActivations(ctx context.Context, ownerUserID, ownerOrgID string, opts ListOpts) ([]WakewordActivation, error)

func (SQLiteStore) ListWords added in v0.45.0

func (s SQLiteStore) ListWords(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Word, error)

func (SQLiteStore) PinQuickNote

func (s SQLiteStore) PinQuickNote(ctx context.Context, id int64, pinned bool) error

func (SQLiteStore) QuickNoteCount

func (s SQLiteStore) QuickNoteCount(ctx context.Context) (int, error)

func (SQLiteStore) RecordReplacementUsage added in v0.45.0

func (s SQLiteStore) RecordReplacementUsage(ctx context.Context, id string) error

func (SQLiteStore) RecordUserDictionaryUsage added in v0.22.4

func (s SQLiteStore) RecordUserDictionaryUsage(ctx context.Context, canonical, language string) error

func (SQLiteStore) RecordWordUsage added in v0.45.0

func (s SQLiteStore) RecordWordUsage(ctx context.Context, term, language string) error

func (SQLiteStore) ReplaceLexicons added in v0.45.0

func (s SQLiteStore) ReplaceLexicons(ctx context.Context, language string, lexicons []speechcustomize.Lexicon) error

func (SQLiteStore) ReplaceLexiconsWithOptions added in v0.45.0

func (s SQLiteStore) ReplaceLexiconsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, lexicons []speechcustomize.Lexicon) error

func (SQLiteStore) ReplaceReplacements added in v0.45.0

func (s SQLiteStore) ReplaceReplacements(ctx context.Context, language string, replacements []speechcustomize.Replacement) error

func (SQLiteStore) ReplaceReplacementsWithOptions added in v0.45.0

func (s SQLiteStore) ReplaceReplacementsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, replacements []speechcustomize.Replacement) error

func (SQLiteStore) ReplaceRulesets added in v0.45.0

func (s SQLiteStore) ReplaceRulesets(ctx context.Context, language string, rulesets []speechcustomize.Ruleset) error

func (SQLiteStore) ReplaceRulesetsWithOptions added in v0.45.0

func (s SQLiteStore) ReplaceRulesetsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, rulesets []speechcustomize.Ruleset) error

func (SQLiteStore) ReplaceUserDictionaryEntries added in v0.22.4

func (s SQLiteStore) ReplaceUserDictionaryEntries(ctx context.Context, language string, entries []UserDictionaryEntry) error

func (SQLiteStore) ReplaceVocabularyWithOptions added in v0.61.10

func (s SQLiteStore) ReplaceVocabularyWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word, extras []speechcustomize.Replacement) error

func (SQLiteStore) ReplaceWords added in v0.45.0

func (s SQLiteStore) ReplaceWords(ctx context.Context, language string, words []speechcustomize.Word) error

func (SQLiteStore) ReplaceWordsWithOptions added in v0.45.0

func (s SQLiteStore) ReplaceWordsWithOptions(ctx context.Context, opts CustomizationReplaceOpts, words []speechcustomize.Word) error

func (SQLiteStore) SaveQuickNote

func (s SQLiteStore) SaveQuickNote(ctx context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)

func (SQLiteStore) SaveRecordingSession added in v0.48.0

func (s SQLiteStore) SaveRecordingSession(ctx context.Context, session RecordingSession) (int64, error)

func (SQLiteStore) SaveRecordingSessionNotes added in v0.59.0

func (s SQLiteStore) SaveRecordingSessionNotes(ctx context.Context, sessionID int64, notes RecordingSessionNotes) error

SaveRecordingSessionNotes replaces the notes of one meeting. The note pane is autosaved as the user types, so this is an upsert on the session rather than an append.

func (SQLiteStore) SaveRecordingSessionSnapshot added in v0.67.7

func (s SQLiteStore) SaveRecordingSessionSnapshot(ctx context.Context, sessionID int64, input RecordingSessionSnapshotInput) (*RecordingSessionSnapshot, error)

SaveRecordingSessionSnapshot writes the image to the snapshot directory and records it against the session. Snapshots are captured locally and stay local: the file never leaves the machine through this package.

func (SQLiteStore) SaveTranscription

func (s SQLiteStore) SaveTranscription(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error

func (SQLiteStore) SaveTranscriptionWithAudio added in v0.30.0

func (s SQLiteStore) SaveTranscriptionWithAudio(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput) error

func (SQLiteStore) SaveTranscriptionWithAudioAndSpeakers added in v0.42.0

func (s SQLiteStore) SaveTranscriptionWithAudioAndSpeakers(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput, speakers *speaker.DiarizationResult) error

func (SQLiteStore) SaveVoiceAgentSession added in v0.24.0

func (s SQLiteStore) SaveVoiceAgentSession(ctx context.Context, session VoiceAgentSession) (int64, error)

func (SQLiteStore) SaveWakewordActivation added in v0.37.8

func (s SQLiteStore) SaveWakewordActivation(ctx context.Context, a WakewordActivation) (*WakewordActivation, error)

func (SQLiteStore) SemanticCapabilities

func (s SQLiteStore) SemanticCapabilities(context.Context) SemanticCapabilities

func (SQLiteStore) SetRecordingSessionPinned added in v0.59.0

func (s SQLiteStore) SetRecordingSessionPinned(ctx context.Context, id int64, pinned bool) error

SetRecordingSessionPinned keeps one meeting out of the retention sweep.

func (SQLiteStore) Stats

func (s SQLiteStore) Stats(ctx context.Context) (Stats, error)

func (SQLiteStore) SumWakewordActivationBytesForUser added in v0.37.8

func (s SQLiteStore) SumWakewordActivationBytesForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)

func (SQLiteStore) TranscriptionCount

func (s SQLiteStore) TranscriptionCount(ctx context.Context) (int, error)

func (SQLiteStore) UpdateQuickNote

func (s SQLiteStore) UpdateQuickNote(ctx context.Context, id int64, text string) error

func (SQLiteStore) UpdateQuickNoteCapture

func (s SQLiteStore) UpdateQuickNoteCapture(ctx context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error

func (SQLiteStore) UpdateRecordingSessionCaptureStatus added in v0.48.0

func (s SQLiteStore) UpdateRecordingSessionCaptureStatus(ctx context.Context, id int64, status RecordingSessionCaptureStatus, at time.Time) error

func (SQLiteStore) UpdateRecordingSessionEnhancement added in v0.59.0

func (s SQLiteStore) UpdateRecordingSessionEnhancement(ctx context.Context, id int64, enhancement RecordingSessionEnhancement) error

UpdateRecordingSessionEnhancement records the outcome of a write-up run.

func (SQLiteStore) UpdateRecordingSessionSummary added in v0.48.0

func (s SQLiteStore) UpdateRecordingSessionSummary(ctx context.Context, id int64, summary string) error

func (SQLiteStore) UpdateRecordingSessionSummaryStatus added in v0.48.0

func (s SQLiteStore) UpdateRecordingSessionSummaryStatus(ctx context.Context, id int64, status RecordingSessionSummaryStatus, message string, at time.Time) error

func (SQLiteStore) UpdateWakewordActivationLabel added in v0.37.8

func (s SQLiteStore) UpdateWakewordActivationLabel(ctx context.Context, id, ownerUserID, ownerOrgID, label string) error

func (SQLiteStore) UpsertMeetingSummaryBatch added in v0.67.0

func (s SQLiteStore) UpsertMeetingSummaryBatch(ctx context.Context, batch MeetingSummaryBatch) (MeetingSummaryBatch, error)

type Scope added in v0.35.0

type Scope = speechstorage.Scope

Scope is an alias for the public speechkit storage Scope, re-exported so callers within this package (and callers that only import store) do not need to reference the pkg/speechkit/storage sub-package directly.

type ScopeExport added in v0.35.0

type ScopeExport struct {
	Scope              Scope                 `json:"scope"`
	Transcriptions     []Transcription       `json:"transcriptions"`
	QuickNotes         []QuickNote           `json:"quick_notes"`
	VoiceAgentSessions []VoiceAgentSession   `json:"voice_agent_sessions"`
	RecordingSessions  []RecordingSession    `json:"recording_sessions,omitempty"`
	DictionaryEntries  []UserDictionaryEntry `json:"dictionary_entries,omitempty"`
	AudioAssetPaths    []string              `json:"audio_asset_paths"`
}

ScopeExport is the structured payload returned by ExportScope (GDPR Art. 15).

type ScopePrivacyStore added in v0.35.0

type ScopePrivacyStore interface {
	// ExportScope returns all user-owned records for the given scope. The
	// returned ScopeExport includes audio asset paths; the caller is
	// responsible for streaming the raw audio bytes if needed.
	ExportScope(ctx context.Context, scope Scope) (*ScopeExport, error)

	// DeleteScope removes all user-owned DB rows for the given scope across
	// every scoped table. Returns a DeleteResult with the total row count and
	// the distinct audio file paths that were associated with those rows.
	// The caller must unlink AudioFilePaths from disk; the store does not.
	DeleteScope(ctx context.Context, scope Scope) (DeleteResult, error)
}

ScopePrivacyStore is an optional extension for backends that implement GDPR Subject-Rights operations scoped to a Storage-3.0 scope.

Both methods operate entirely within the scope boundaries — no cross-scope data is ever returned or deleted. Audio files on disk are NOT removed by DeleteScope (only the database rows are deleted). The caller receives the paths in DeleteResult and is responsible for unlinking them. Disk cleanup for ExportScope is the caller's responsibility (stream the paths returned in AudioAssetPaths alongside the JSON).

type SemanticCapabilities

type SemanticCapabilities struct {
	Provider     SemanticProvider `json:"provider"`
	FullText     bool             `json:"fullText"`
	Embeddings   bool             `json:"embeddings"`
	VectorSearch bool             `json:"vectorSearch"`
}

type SemanticCapabilityProvider

type SemanticCapabilityProvider interface {
	SemanticCapabilities(ctx context.Context) SemanticCapabilities
}

SemanticCapabilityProvider is an optional extension for stores that can advertise indexing/vector capabilities without forcing every backend to implement semantic features immediately.

type SemanticProvider

type SemanticProvider string
const (
	SemanticProviderNone SemanticProvider = "none"
)

type Stats

type Stats struct {
	Transcriptions        int
	QuickNotes            int
	TotalWords            int
	TotalAudioDurationMs  int64
	AverageWordsPerMinute float64
	AverageLatencyMs      int64
}

type Store

type Store interface {
	// Transcriptions
	SaveTranscription(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audioData []byte) error
	GetTranscription(ctx context.Context, id int64) (*Transcription, error)
	ListTranscriptions(ctx context.Context, opts ListOpts) ([]Transcription, error)
	TranscriptionCount(ctx context.Context) (int, error)

	// Quick Notes
	SaveQuickNote(ctx context.Context, text, language, provider string, durationMs, latencyMs int64, audioData []byte) (int64, error)
	GetQuickNote(ctx context.Context, id int64) (*QuickNote, error)
	ListQuickNotes(ctx context.Context, opts ListOpts) ([]QuickNote, error)
	UpdateQuickNote(ctx context.Context, id int64, text string) error
	UpdateQuickNoteCapture(ctx context.Context, id int64, text, provider string, durationMs, latencyMs int64, audioData []byte) error
	PinQuickNote(ctx context.Context, id int64, pinned bool) error
	DeleteQuickNote(ctx context.Context, id int64) error
	QuickNoteCount(ctx context.Context) (int, error)
	Stats(ctx context.Context) (Stats, error)

	// Lifecycle
	Close() error
}

Store is the central storage abstraction. Each backend (SQLite, PostgreSQL, kombify Cloud) implements this interface.

func New

func New(cfg StoreConfig) (Store, error)

New creates a Store backend based on the config.

type StoreConfig

type StoreConfig struct {
	Backend            string `toml:"backend"` // "sqlite" | "postgres" | registered name
	SQLitePath         string `toml:"sqlite_path"`
	PostgresDSN        string `toml:"postgres_dsn"`
	SaveAudio          bool   `toml:"save_audio"`
	AudioRetentionDays int    `toml:"audio_retention_days"`
	// MeetingRetentionDays discards finished meetings older than this. Zero
	// keeps them forever, which is the default: a meeting is work, not a
	// by-product, so nothing is thrown away unless the user asks for it.
	MeetingRetentionDays    int `toml:"meeting_retention_days"`
	MaxAudioStorageMB       int `toml:"max_audio_storage_mb"`
	TranscriptionModelHints map[string]string
	DefaultScope            speechstorage.Scope
	ScopePolicy             speechstorage.ScopePolicy
}

StoreConfig holds configuration for store backend selection.

type Transcription

type Transcription struct {
	ID          int64                      `json:"id"`
	Text        string                     `json:"text"`
	Language    string                     `json:"language"`
	Provider    string                     `json:"provider"`
	Model       string                     `json:"model"`
	DurationMs  int64                      `json:"durationMs"`
	LatencyMs   int64                      `json:"latencyMs"`
	AudioPath   string                     `json:"audioPath,omitempty"`
	Audio       *AudioAsset                `json:"audio,omitempty"`
	CreatedAt   time.Time                  `json:"createdAt"`
	OwnerUserID string                     `json:"ownerUserId,omitempty"`
	OwnerOrgID  string                     `json:"ownerOrgId,omitempty"`
	OwnerSource string                     `json:"ownerSource,omitempty"`
	Speakers    *speaker.DiarizationResult `json:"speakers,omitempty"`
}

Transcription represents a saved transcription record.

type TranscriptionAudioStore added in v0.30.0

type TranscriptionAudioStore interface {
	SaveTranscriptionWithAudio(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput) error
}

TranscriptionAudioStore is implemented by stores that can persist transcription audio with accurate source metadata.

type TranscriptionSpeakerStore added in v0.42.0

type TranscriptionSpeakerStore interface {
	SaveTranscriptionWithAudioAndSpeakers(ctx context.Context, text, language, provider, model string, durationMs, latencyMs int64, audio AudioAssetInput, speakers *speaker.DiarizationResult) error
}

TranscriptionSpeakerStore is implemented by stores that can persist normalized speaker diarization metadata alongside a transcription.

type UserDictionaryEntry added in v0.22.4

type UserDictionaryEntry struct {
	ID         int64
	Spoken     string
	Canonical  string
	Language   string
	Source     string
	Enabled    bool
	UsageCount int
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

type UserDictionaryStore added in v0.22.4

type UserDictionaryStore interface {
	ReplaceUserDictionaryEntries(ctx context.Context, language string, entries []UserDictionaryEntry) error
	ListUserDictionaryEntries(ctx context.Context, language string) ([]UserDictionaryEntry, error)
	RecordUserDictionaryUsage(ctx context.Context, canonical, language string) error
}

UserDictionaryStore is an optional extension for stores that persist user-specific dictation terms outside config.toml.

type VoiceAgentSession added in v0.24.0

type VoiceAgentSession struct {
	ID                int64                    `json:"id"`
	StartedAt         time.Time                `json:"startedAt"`
	EndedAt           time.Time                `json:"endedAt"`
	Language          string                   `json:"language"`
	ProviderProfileID string                   `json:"providerProfileId,omitempty"`
	RuntimeKind       string                   `json:"runtimeKind,omitempty"`
	Transcript        string                   `json:"transcript,omitempty"`
	Turns             []VoiceAgentTurn         `json:"turns,omitempty"`
	Summary           VoiceAgentSessionSummary `json:"summary"`
	CreatedAt         time.Time                `json:"createdAt"`
	OwnerUserID       string                   `json:"ownerUserId,omitempty"`
	OwnerOrgID        string                   `json:"ownerOrgId,omitempty"`
	OwnerSource       string                   `json:"ownerSource,omitempty"`
}

type VoiceAgentSessionStore added in v0.24.0

type VoiceAgentSessionStore interface {
	SaveVoiceAgentSession(ctx context.Context, session VoiceAgentSession) (int64, error)
	GetVoiceAgentSession(ctx context.Context, id int64) (*VoiceAgentSession, error)
	ListVoiceAgentSessions(ctx context.Context, opts ListOpts) ([]VoiceAgentSession, error)
}

VoiceAgentSessionStore is an optional extension for backends that persist Voice Agent dialogue summaries.

type VoiceAgentSessionSummary added in v0.24.0

type VoiceAgentSessionSummary struct {
	Title         string   `json:"title,omitempty"`
	Summary       string   `json:"summary"`
	Ideas         []string `json:"ideas,omitempty"`
	Decisions     []string `json:"decisions,omitempty"`
	OpenQuestions []string `json:"openQuestions,omitempty"`
	NextSteps     []string `json:"nextSteps,omitempty"`
	RawText       string   `json:"rawText,omitempty"`
}

type VoiceAgentTurn added in v0.24.0

type VoiceAgentTurn struct {
	Role      string    `json:"role"`
	Text      string    `json:"text"`
	CreatedAt time.Time `json:"createdAt,omitempty"`
}

type WakewordActivation added in v0.37.8

type WakewordActivation struct {
	ID           string    `json:"id"`
	OwnerUserID  string    `json:"owner_user_id"`
	OwnerOrgID   string    `json:"owner_org_id"`
	PhraseID     string    `json:"phrase_id"`
	Phrase       string    `json:"phrase"`
	Backend      string    `json:"backend"`
	Score        float64   `json:"score"`
	CapturedAt   time.Time `json:"captured_at"`
	UploadedAt   time.Time `json:"uploaded_at"`
	Label        string    `json:"label,omitempty"`
	AudioPath    string    `json:"audio_path"`
	AudioBytes   int64     `json:"audio_bytes"`
	SampleRate   int       `json:"sample_rate"`
	PreRollMs    int       `json:"pre_roll_ms"`
	PostRollMs   int       `json:"post_roll_ms"`
	MetadataJSON string    `json:"metadata_json,omitempty"`
}

WakewordActivation is the metadata row for one captured + uploaded wake-word activation. Audio bytes live on the filesystem under AudioPath (relative to <server.training_data.audio_dir>).

type WakewordActivationStore added in v0.37.8

type WakewordActivationStore interface {
	// SaveWakewordActivation inserts a new activation row. Returns
	// the activation as stored (with uploaded_at populated by the
	// store). The ID field must be set by the caller (client-
	// generated ULIDs / sortable timestamps); empty ID is rejected.
	SaveWakewordActivation(ctx context.Context, a WakewordActivation) (*WakewordActivation, error)

	// GetWakewordActivation returns one activation by ID, scoped to
	// the supplied owner. Returns sql.ErrNoRows when the ID belongs
	// to a different scope so callers cannot leak existence info
	// across tenants.
	GetWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (*WakewordActivation, error)

	// ListWakewordActivations returns the caller's activations
	// (paginated newest-first). Use ListOpts.Limit + .Cursor for
	// pagination — the cursor is the captured_at timestamp of the
	// last item from the previous page.
	ListWakewordActivations(ctx context.Context, ownerUserID, ownerOrgID string, opts ListOpts) ([]WakewordActivation, error)

	// UpdateWakewordActivationLabel sets the label field (empty
	// string clears the label). Scoped to owner — returns
	// sql.ErrNoRows when the ID is in a different scope.
	UpdateWakewordActivationLabel(ctx context.Context, id, ownerUserID, ownerOrgID, label string) error

	// DeleteWakewordActivation removes the row + returns the
	// audio_path so the caller can unlink the file from disk. The
	// store itself does not touch the filesystem.
	DeleteWakewordActivation(ctx context.Context, id, ownerUserID, ownerOrgID string) (audioPath string, err error)

	// CountWakewordActivationsForUser returns the row count for one
	// owner. Used by quota enforcement (per_user_quota_bytes) and
	// the admin dashboard.
	CountWakewordActivationsForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)

	// SumWakewordActivationBytesForUser returns the total audio_bytes
	// of all activations one owner has stored. Used by the quota
	// gate in the upload endpoint.
	SumWakewordActivationBytesForUser(ctx context.Context, ownerUserID, ownerOrgID string) (int64, error)
}

WakewordActivationStore is the v0.37.5+ extension for backends that persist wake-word activation training-data uploads. Audio bytes live on the filesystem; this interface manages only metadata + relative paths. Every method is scoped to an Identity{User,Org} so multi-tenant installs cannot cross-share recordings.

SaveWakewordActivation expects the caller to have already written the audio file to disk under audio_path. Implementations refuse inserts where audio_path is empty.

type WordStore added in v0.45.0

type WordStore interface {
	ReplaceWords(ctx context.Context, language string, words []speechcustomize.Word) error
	ListWords(ctx context.Context, opts CustomizationListOpts) ([]speechcustomize.Word, error)
	RecordWordUsage(ctx context.Context, term, language string) error
}

Jump to

Keyboard shortcuts

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