Skip to main content

internal/infra/pg/embeddingsearch.go

internal/infra/pg · 133 lines · 5 declarations · source

Declarations​

type MessageSearchOptions​

type MessageSearchOptions struct {
Limit int
Candidates int // Zero is the exact baseline; a positive bounded count opts into ANN candidates.
Subject string
Role string
// Application reads use the transport's credential audit policy; operator reads audit here.
applicationRead bool
}

source

type MessageMatch​

type MessageMatch struct {
ChunkID string `json:"chunk_id"`
SourceID string `json:"source_id"`
Ordinal int `json:"ordinal"`
Role string `json:"role"`
Preview string `json:"preview"`
Similarity float64 `json:"similarity"`
OccurredAt time.Time `json:"occurred_at"`
MessageBytes int `json:"message_bytes"`
PreviewComplete bool `json:"preview_complete"`
PreviewByteEnd int `json:"preview_byte_end"`
ContentDigest string `json:"content_digest"`
}

source

type MessageSearchResult​

type MessageSearchResult struct {
Generation EmbeddingGeneration `json:"generation"`
Approximate bool `json:"approximate"`
Matches []MessageMatch `json:"matches"`
}

source

method MessageEmbeddingStore.Search​

func (s *MessageEmbeddingStore) Search(ctx context.Context, scope, actor string, model EmbeddingModel, vector []float32, options MessageSearchOptions) (MessageSearchResult, error)

Search returns message evidence, not asserted facts. The exact baseline materializes eligible rows before ordering, preventing PostgreSQL from substituting an approximate index traversal. ANN candidates are opt-in and reranked against full-precision values and current source hashes.

source

method MessageEmbeddingStore.SearchEvidence​

func (s *MessageEmbeddingStore) SearchEvidence(ctx context.Context, scope string, model EmbeddingModel, vector []float32, options MessageSearchOptions) (MessageSearchResult, error)

SearchEvidence is a source read for an already-authorized application. Like the record and citation stores, it leaves credential audit policy to the transport; operator Search remains audited.

source