Documentation
¶
Overview ¶
Package learnings persists review findings so future reviews on the same repo/symbol can reference prior outcomes.
Index ¶
- type Embedder
- type Record
- type Store
- func (s *Store) Close()
- func (s *Store) HasEmbedder() bool
- func (s *Store) Nearest(ctx context.Context, repo, symbol string, k int) ([]Record, error)
- func (s *Store) NearestByRepo(ctx context.Context, repo string, k int) ([]Record, error)
- func (s *Store) NearestVector(ctx context.Context, query string, k int) ([]Record, error)
- func (s *Store) Upsert(ctx context.Context, r Record) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Embedder ¶
Embedder abstracts the embedding client; pass nil to disable vector updates and fall back to exact (repo, symbol) lookups.
type Record ¶
type Record struct {
Repo string `json:"repo"`
Symbol string `json:"symbol"`
RiskLevel string `json:"risk_level,omitempty"`
ReviewOutcome string `json:"review_outcome,omitempty"`
Flag string `json:"flag,omitempty"`
Note string `json:"note,omitempty"`
PRURL string `json:"pr_url,omitempty"`
}
Record is a single learning.
RiskLevel and ReviewOutcome are orthogonal:
- RiskLevel is written by the impact-analysis path (review_pr) and uses the vocabulary low|medium|high.
- ReviewOutcome is written by the posted-review path (review_pr with dry_run=false) and uses the vocabulary good|neutral|bad (mapped from the GitHub review event).
Either (or both) may be empty on a given row depending on which writer produced it.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store persists learnings in Postgres (pgvector).
func New ¶
New opens a pool. Caller must call Close.
After migrating the schema it attempts (at most once per DSN per process) to transfer table ownership to CURRENT_USER (best-effort: warns instead of failing if the connected role is not the current table owner — e.g. after a superuser pg_restore left review_learnings owned by the restoring role).
func (*Store) HasEmbedder ¶ added in v1.20.0
HasEmbedder reports whether this store has a configured Embedder for vector similarity search. When false, NearestVector calls will error.
func (*Store) Nearest ¶
Nearest returns up to k prior learnings for the same (repo, symbol). (Vector search is added later; exact match is enough for v1.)
func (*Store) NearestByRepo ¶ added in v1.20.0
NearestByRepo returns up to k prior learnings for the given repo, ordered by creation time descending. It matches any symbol.
func (*Store) NearestVector ¶
NearestVector returns up to k prior learnings closest to the given query string by cosine distance over the embedding column. It requires a configured Embedder; callers should fall back to the exact (repo, symbol) Nearest path when no embedder is available.