searchsystem

package
v1.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package searchsystem implements the capability layer of the research stack. It discovers public sources and retrieves bounded page content, but it does not decide whether evidence is sufficient or compose a user-facing answer.

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderCircuitOpen = errors.New("provider circuit is open")

Functions

This section is empty.

Types

type DefaultExtractor

type DefaultExtractor struct{ MaxContentChars int }

func (DefaultExtractor) Extract

func (e DefaultExtractor) Extract(document Document) Document

type Document

type Document struct {
	Hit
	CanonicalURL string
	Content      string
	ContentHash  string
	FetchedAt    time.Time
}

Document is normalized content returned by the fetch and extraction stages.

type Extractor

type Extractor interface {
	Extract(Document) Document
}

Extractor bounds and normalizes fetched content before it leaves the capability layer.

type Fetcher

type Fetcher interface {
	Fetch(context.Context, Hit) (Document, error)
}

Fetcher retrieves one selected public page.

type Hit

type Hit struct {
	QueryID      string
	Provider     string
	Kind         SourceKind
	Title        string
	URL          string
	Snippet      string
	Priority     int
	Seed         bool
	SearchRank   int
	ProviderRank int
	PublishedAt  time.Time
}

Hit is a lightweight search result. Page content is fetched only after the complete result set has been deduplicated and prioritized.

type Observation

type Observation struct {
	Operation string
	Target    string
	Provider  string
	Status    string
	ErrorCode string
	Summary   string
	ElapsedMS int64
}

Observation records one bounded capability operation without retaining raw provider payloads.

type Provider

type Provider interface {
	Name() string
	Kind() SourceKind
	Search(context.Context, Query, int) ([]Hit, error)
}

Provider is an independently replaceable search backend.

func NewArxivProvider

func NewArxivProvider(client *http.Client, baseURL string) Provider

func NewGDELTProvider

func NewGDELTProvider(client *http.Client, baseURL string) Provider

func NewGitHubProvider

func NewGitHubProvider(client *http.Client, baseURL, token string) Provider

func NewWikipediaProvider

func NewWikipediaProvider(client *http.Client, baseURL string) Provider

func WithResilience

func WithResilience(provider Provider, config ResilienceConfig) Provider

type ProviderConfig

type ProviderConfig struct {
	Enabled     []string
	GitHubToken string
	Resilience  ResilienceConfig
}

func DefaultProviderConfig

func DefaultProviderConfig() ProviderConfig

type ProviderError

type ProviderError struct {
	Provider   string
	StatusCode int
	Code       string
	Message    string
}

func (*ProviderError) Error

func (e *ProviderError) Error() string

type Query

type Query struct {
	ID              string
	Text            string
	Purpose         string
	Priority        int
	PreferredSource []SourceKind
}

Query is a provider-independent search request produced by the decision layer.

type ResilienceConfig

type ResilienceConfig struct {
	Timeout          time.Duration
	FailureThreshold int
	OpenDuration     time.Duration
}

func DefaultResilienceConfig

func DefaultResilienceConfig() ResilienceConfig

type RoundResult

type RoundResult struct {
	Hits         []Hit
	Documents    []Document
	Observations []Observation
	Failures     []string
}

RoundResult contains only capability-layer facts; evidence quality is added by the evidence layer.

type Router

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

func NewRouter

func NewRouter(providers ...Provider) *Router

func (*Router) Route

func (r *Router) Route(query Query) []Provider

type SourceKind

type SourceKind string

SourceKind describes the type of source a query should prioritize.

const (
	SourceGeneral  SourceKind = "general"
	SourceOfficial SourceKind = "official"
	SourceGitHub   SourceKind = "github"
	SourceAcademic SourceKind = "academic"
	SourceNews     SourceKind = "news"
	SourceVideo    SourceKind = "video"
)

type SourceRouter

type SourceRouter interface {
	Route(Query) []Provider
}

SourceRouter chooses providers from explicit source preferences.

type System

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

func New

func New(router SourceRouter, fetcher Fetcher, extractor Extractor) *System

func NewDefault

func NewDefault() *System

func NewDefaultWithConfig

func NewDefaultWithConfig(config ProviderConfig) *System

NewDefaultWithConfig builds a registry of genuinely independent source providers plus scoped public-web fallbacks.

func (*System) ExecuteRound

func (s *System) ExecuteRound(ctx context.Context, queries []Query, seedURLs []string, maxSearches, resultsPerSearch, maxPages int) (RoundResult, error)

ExecuteRound searches first, then fetches only the highest-value unique URLs.

Jump to

Keyboard shortcuts

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