decision

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: 8 Imported by: 0

Documentation

Overview

Package decision implements the research decision layer. It owns intent, query planning, gap detection, follow-up planning, and the bounded research loop while delegating retrieval and evidence processing to lower layers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvisedQuery

type AdvisedQuery struct {
	Text     string `json:"text"`
	Purpose  string `json:"purpose"`
	Source   string `json:"source"`
	Priority int    `json:"priority"`
}

type Advisor

type Advisor interface {
	RefinePlan(context.Context, PlanAdviceRequest) (PlanAdvice, error)
	VerifyClaims(context.Context, ClaimVerificationRequest) (ClaimVerification, error)
}

Advisor adds model-assisted planning and verification to the deterministic research loop. Its output is always validated against runtime budgets and collected source IDs before it can affect execution.

type AdvisorUsage

type AdvisorUsage struct {
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
}

type Agent

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

func NewAgent

func NewAgent(search SearchSystem, pipeline EvidencePipeline, cache ResearchCache) *Agent

func (*Agent) Run

func (a *Agent) Run(ctx context.Context, task Task, budget Budget) (Outcome, error)

Run executes an adaptive search loop. Runtime limits, rather than an LLM, are authoritative for cancellation, timeouts, and maximum work.

func (*Agent) RunWithOptions

func (a *Agent) RunWithOptions(ctx context.Context, task Task, budget Budget, options RunOptions) (Outcome, error)

RunWithOptions executes V3 model-assisted research while keeping the deterministic planner, evidence pipeline, and runtime budget authoritative.

type Budget

type Budget struct {
	MaxQueries      int
	MaxPages        int
	MaxRounds       int
	ResultsPerQuery int
	MaxContextChars int
	MaxDuration     time.Duration
	CacheTTL        time.Duration
	NewsCacheTTL    time.Duration
}

func DefaultBudget

func DefaultBudget() Budget

type Claim

type Claim struct {
	Text         string
	SourceIDs    []string
	Verification string
	Confidence   float64
}

type ClaimReview

type ClaimReview struct {
	ClaimID    string   `json:"claim_id"`
	Verdict    string   `json:"verdict"`
	SourceIDs  []string `json:"source_ids"`
	Confidence float64  `json:"confidence"`
	Reason     string   `json:"reason"`
}

type ClaimVerification

type ClaimVerification struct {
	Reviews []ClaimReview `json:"reviews"`
	Usage   AdvisorUsage  `json:"-"`
}

type ClaimVerificationRequest

type ClaimVerificationRequest struct {
	Task      Task
	Report    evidence.Report
	MaxClaims int
}

type DefaultFollowUpPlanner

type DefaultFollowUpPlanner struct{}

func (DefaultFollowUpPlanner) Next

func (DefaultFollowUpPlanner) Next(task Task, plan Plan, gaps []Gap, attempted map[string]bool, limit int) []searchsystem.Query

type DefaultGapDetector

type DefaultGapDetector struct{}

func (DefaultGapDetector) Detect

func (DefaultGapDetector) Detect(task Task, plan Plan, report evidence.Report) []Gap

type DefaultIntentAnalyzer

type DefaultIntentAnalyzer struct{}

func (DefaultIntentAnalyzer) Analyze

func (DefaultIntentAnalyzer) Analyze(task Task) Intent

type DefaultKnowledgeSynthesizer

type DefaultKnowledgeSynthesizer struct{}

func (DefaultKnowledgeSynthesizer) Synthesize

func (DefaultKnowledgeSynthesizer) Synthesize(report evidence.Report, gaps []Gap, usage Usage, stopReason string) StructuredResult

type DefaultQueryPlanner

type DefaultQueryPlanner struct{}

func (DefaultQueryPlanner) Plan

func (DefaultQueryPlanner) Plan(task Task, intent Intent, budget Budget) Plan

type EvidencePipeline

type EvidencePipeline interface {
	Merge(evidence.Request, evidence.Report, searchsystem.RoundResult, int) evidence.Report
}

type FollowUpPlanner

type FollowUpPlanner interface {
	Next(Task, Plan, []Gap, map[string]bool, int) []searchsystem.Query
}

type Gap

type Gap struct {
	Code        string
	Description string
	Priority    int
}

type GapDetector

type GapDetector interface {
	Detect(Task, Plan, evidence.Report) []Gap
}

type Intent

type Intent struct {
	Kind            string
	Topic           string
	NeedsFreshness  bool
	NeedsAuthority  bool
	NeedsComparison bool
	PreferredSource []searchsystem.SourceKind
}

type IntentAnalyzer

type IntentAnalyzer interface {
	Analyze(Task) Intent
}

type KnowledgeSynthesizer

type KnowledgeSynthesizer interface {
	Synthesize(evidence.Report, []Gap, Usage, string) StructuredResult
}

type Outcome

type Outcome struct {
	Plan         Plan
	Report       evidence.Report
	Result       StructuredResult
	Attempted    []searchsystem.Query
	Observations []searchsystem.Observation
	Failures     []string
	FromCache    bool
}

type Plan

type Plan struct {
	Intent  Intent
	Queries []searchsystem.Query
}

type PlanAdvice

type PlanAdvice struct {
	Queries []AdvisedQuery `json:"queries"`
	Usage   AdvisorUsage   `json:"-"`
}

type PlanAdviceRequest

type PlanAdviceRequest struct {
	Task     Task
	Intent   Intent
	Baseline Plan
	Budget   Budget
}

type Progress

type Progress struct {
	Stage         string
	Message       string
	Percent       int
	Round         int
	Queries       int
	QueryTexts    []string
	Sources       int
	ValuablePages []ValuablePage
	Confidence    float64
	Completed     bool
}

type QueryPlanner

type QueryPlanner interface {
	Plan(Task, Intent, Budget) Plan
}

type ResearchCache

type ResearchCache interface {
	Get(context.Context, string, time.Duration) (evidence.Report, bool)
	Put(context.Context, string, evidence.Report)
}

type RunOptions

type RunOptions struct {
	Advisor              Advisor
	EnableModelPlanning  bool
	EnableSemanticVerify bool
	MaxAdvisorClaims     int
	OnProgress           func(Progress) error
}

type SearchSystem

type SearchSystem interface {
	ExecuteRound(context.Context, []searchsystem.Query, []string, int, int, int) (searchsystem.RoundResult, error)
}

type Source

type Source struct {
	ID        string
	Title     string
	URL       string
	Provider  string
	Score     float64
	Authority float64
	Relevance float64
}

type StructuredResult

type StructuredResult struct {
	Status         string
	StopReason     string
	Confidence     float64
	Claims         []Claim
	Sources        []Source
	Gaps           []Gap
	Contradictions []evidence.Contradiction
	Usage          Usage
}

type Task

type Task struct {
	Kind           string
	Prompt         string
	Goal           string
	Constraints    []string
	InitialQueries []string
	SeedURLs       []string
	MinSources     int
	MaxSources     int
	Date           string
	Language       string
}

type Usage

type Usage struct {
	Rounds           int
	Searches         int
	Pages            int
	CacheHits        int
	AdvisorCalls     int
	PromptTokens     int
	CompletionTokens int
	TotalTokens      int
	ElapsedMS        int64
	LimitReached     bool
}

type ValuablePage

type ValuablePage struct {
	ID            string
	Rank          int
	Title         string
	URL           string
	Domain        string
	Provider      string
	Kind          string
	Snippet       string
	ValueSignals  []string
	Authority     float64
	Relevance     float64
	Freshness     float64
	EvidenceScore float64
	Fetched       bool
	PublishedAt   string
}

ValuablePage is the bounded, UI-safe description of a page that contributed evidence. Raw page content never crosses the progress protocol boundary.

Jump to

Keyboard shortcuts

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