search

package
v0.1.0-round1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package search implements grounded semantic search over active document versions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroundedResult

type GroundedResult struct {
	Status GroundingStatus
	Reason GroundingReason
	Hits   []knowledge.SearchHit
}

GroundedResult keeps the legacy hits intact while adding an explicit safety decision.

type GroundingReason

type GroundingReason string

GroundingReason identifies why the retrieval substrate returned no evidence.

const (
	GroundingNoHitsAbovePolicy          GroundingReason = "NO_HITS_ABOVE_POLICY"
	GroundingOnlyInactiveVersionMatched GroundingReason = "ONLY_INACTIVE_VERSION_MATCHED"
	GroundingSourceUnavailable          GroundingReason = "SOURCE_UNAVAILABLE"
)

type GroundingStatus

type GroundingStatus string

GroundingStatus is the deterministic retrieval-safety decision returned to clients.

const (
	// GroundingSupported means at least one active, above-policy evidence hit is available.
	GroundingSupported GroundingStatus = "SUPPORTED"
	// GroundingInsufficientEvidence means callers must not treat the empty result as grounded evidence.
	GroundingInsufficientEvidence GroundingStatus = "INSUFFICIENT_EVIDENCE"
)

type Service

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

Service validates, embeds, and executes grounded document searches.

func New

func New(
	repository repository,
	embedder embedder,
	profile knowledge.Profile,
	publicBaseURL string,
	exactMatch bool,
	sourceVerifiers ...sourceVerifier,
) (*Service, error)

New returns a search service backed by the provided repository and embedder. exactMatch=true enables query-time exact-token refinement: when at least one returned hit's snippet contains the full query as a substring, only those hits are kept; otherwise the full semantic top-N is returned unchanged.

func (*Service) Documents

func (s *Service) Documents(
	ctx context.Context,
	query string,
	limit int,
) ([]knowledge.SearchHit, error)

Documents returns ranked hits from active document versions only. A zero limit uses the default; other limits must be between 1 and 20.

func (*Service) GroundedDocuments

func (s *Service) GroundedDocuments(
	ctx context.Context,
	query string,
	limit int,
) (GroundedResult, error)

GroundedDocuments returns only active, above-policy evidence and classifies every safe empty result. Retryable dependency failures become SOURCE_UNAVAILABLE with an explicit empty slice; invalid input and non-retryable configuration failures remain errors.

func (*Service) Ready

func (s *Service) Ready(ctx context.Context) error

Ready reports whether the query embedder and configured original-source store can accept work.

Jump to

Keyboard shortcuts

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