Documentation
¶
Overview ¶
Package postgres provides PostgreSQL storage for prompts.
Index ¶
- type Store
- func (s *Store) ApproveVersion(ctx context.Context, promptID string, version int, approver string) (*prompt.Prompt, error)
- func (s *Store) Count(ctx context.Context, filter prompt.ListFilter) (int, error)
- func (s *Store) Create(ctx context.Context, p *prompt.Prompt) error
- func (s *Store) CreateDraftVersion(ctx context.Context, promptID string, proposed *prompt.Prompt, author string) (int, error)
- func (s *Store) Delete(ctx context.Context, name string) error
- func (s *Store) DeleteByID(ctx context.Context, id string) error
- func (s *Store) Get(ctx context.Context, name string) (*prompt.Prompt, error)
- func (s *Store) GetByID(ctx context.Context, id string) (*prompt.Prompt, error)
- func (s *Store) GetPersonal(ctx context.Context, ownerEmail, name string) (*prompt.Prompt, error)
- func (s *Store) GetVersion(ctx context.Context, promptID string, version int) (*prompt.Version, error)
- func (s *Store) List(ctx context.Context, filter prompt.ListFilter) ([]prompt.Prompt, error)
- func (s *Store) ListVersions(ctx context.Context, promptID string) ([]prompt.Version, error)
- func (s *Store) RejectVersion(ctx context.Context, promptID string, version int) error
- func (s *Store) Search(ctx context.Context, q prompt.SearchQuery) ([]prompt.ScoredPrompt, error)
- func (s *Store) Update(ctx context.Context, p *prompt.Prompt) error
- func (s *Store) UpdateWithVersion(ctx context.Context, p *prompt.Prompt, author string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements prompt.Store using PostgreSQL.
func (*Store) ApproveVersion ¶ added in v1.108.0
func (s *Store) ApproveVersion(ctx context.Context, promptID string, version int, approver string) (*prompt.Prompt, error)
ApproveVersion applies draft version's snapshot to the live prompt row, marks the prompt approved with approver's stamp, binds the same stamp to the version row, and supersedes any other pending drafts. Returns the updated prompt.
func (*Store) Create ¶
Create persists a new prompt. If p.ID is empty the database generates one. Every non-system prompt is created with version 1 and a matching applied snapshot in prompt_versions, in one transaction; system rows (read-only config mirrors re-ingested at startup) are never versioned.
func (*Store) CreateDraftVersion ¶ added in v1.108.0
func (s *Store) CreateDraftVersion(ctx context.Context, promptID string, proposed *prompt.Prompt, author string) (int, error)
CreateDraftVersion snapshots proposed's versioned fields as a new draft version of the prompt without touching the live row, returning the new version number. System rows are read-only config mirrors and refuse drafts.
func (*Store) DeleteByID ¶
DeleteByID removes a prompt by ID.
func (*Store) Get ¶
Get retrieves a non-personal (global or persona) prompt by name. Personal prompts are per-owner; use GetPersonal. Returns nil, nil if not found.
func (*Store) GetPersonal ¶ added in v1.81.0
GetPersonal retrieves a personal prompt by its owner and name. Returns nil, nil if not found.
func (*Store) GetVersion ¶ added in v1.108.0
func (s *Store) GetVersion(ctx context.Context, promptID string, version int) (*prompt.Version, error)
GetVersion returns one version with its full content, or nil, nil when the prompt has no such version.
func (*Store) ListVersions ¶ added in v1.108.0
ListVersions returns every version of the prompt, newest first.
func (*Store) RejectVersion ¶ added in v1.108.0
RejectVersion marks a pending draft version rejected, leaving the live prompt row untouched.
func (*Store) Search ¶ added in v1.81.0
func (s *Store) Search(ctx context.Context, q prompt.SearchQuery) ([]prompt.ScoredPrompt, error)
Search ranks approved prompts by relevance to the query within the caller's visibility. A non-nil q.Embedding selects hybrid (semantic + lexical) ranking; a nil embedding selects the lexical-only fallback used when no embedding provider is configured. Visibility is applied in SQL before ranking, so a prompt the caller cannot read is never returned.
func (*Store) Update ¶
Update modifies an existing prompt identified by ID. It does not create a version snapshot (use UpdateWithVersion for versioned edits), but it does bind a first approval to the current version: when the update carries the draft-to-approved transition, the approval stamp is copied onto the current prompt_versions row in the same transaction, so "approved" always names a specific snapshot regardless of which path performed the approval. Like UpdateWithVersion, it re-validates the review gate under the row lock, so a write racing an approval cannot slip unreviewed content past it.
func (*Store) UpdateWithVersion ¶ added in v1.108.0
UpdateWithVersion persists p like Update and, when any versioned snapshot field changed against the stored row, records a new applied version authored by author and advances p.Version to it. System rows are written without versioning (config mirrors). The review gate is re-validated under the row lock (see requireUngated).