retrieval

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnchorFirstModeV1           = "v1"
	AnchorFirstModeRerankOnly   = "rerank_only"
	AnchorFirstModeSelectedOnly = "selected_only"
	AnchorFirstModeStrongField  = "strong_field"
	AnchorFirstModeStrict       = "strict"
	DefaultAnchorFirstMode      = AnchorFirstModeSelectedOnly
)
View Source
const (
	PackRoleBackgroundDecisions = "background_decisions"
	PackRoleImplementation      = "implementation_surface"
	PackRoleBehaviorTests       = "behavior_tests"
	PackRoleConfigSchema        = "config_schema"
	PackRoleOpenWork            = "open_work"
	PackRoleSupportingContext   = "supporting_context"
	PackRoleExcludedNoise       = "excluded_noise"
)
View Source
const (
	PackTierPrimary    = "primary"
	PackTierRelated    = "related"
	PackTierDiagnostic = "diagnostic"
)
View Source
const EvidenceModeBalanced = "balanced"

Variables

This section is empty.

Functions

func AuthorityCues

func AuthorityCues(c Candidate) []string

AuthorityCues returns short trust/caution labels that are safe to show in human or JSON output. It intentionally exposes less detail than retrieval reasons; the detailed factors remain available through ExplainCandidates.

func CandidatePackTier

func CandidatePackTier(c Candidate) string

func CandidatePaths

func CandidatePaths(candidates []Candidate) []string

func IsPlanningIntentPath

func IsPlanningIntentPath(path string) bool

func IsSourceContextCandidate

func IsSourceContextCandidate(c Candidate) bool

func NormalizeAnchorFirstMode

func NormalizeAnchorFirstMode(mode string) string

func PackRoleTitle

func PackRoleTitle(role string) string

func ValidAnchorFirstModes

func ValidAnchorFirstModes() []string

Types

type AnchorKind

type AnchorKind string
const (
	AnchorCompactIdentifier AnchorKind = "compact_identifier"
	AnchorProperOrRare      AnchorKind = "proper_or_rare_term"
	AnchorQuotedPhrase      AnchorKind = "quoted_phrase"
	AnchorPathLike          AnchorKind = "path_like"
	AnchorArtifactRoleTerm  AnchorKind = "artifact_role_term"
	AnchorGenericTaskWord   AnchorKind = "generic_task_word"
)

type AnchorProfile

type AnchorProfile struct {
	Anchors     []AnchorTerm `json:"anchors"`
	HasSpecific bool         `json:"has_specific"`
}

func BuildAnchorProfile

func BuildAnchorProfile(query string) AnchorProfile

type AnchorTerm

type AnchorTerm struct {
	Term     string     `json:"term"`
	Original string     `json:"original,omitempty"`
	Kind     AnchorKind `json:"kind"`
}

type Candidate

type Candidate struct {
	ID       string
	Path     string
	Kind     string
	Subtype  string
	Title    string
	Status   string
	Body     string
	Source   string
	Metadata map[string]string
	Sections []IndexedSection `json:"sections,omitempty"`
}

Candidate is the shared retrieval unit used by eval and live CLI commands. Path and Body are the minimum fields required by the v0 file retriever; the remaining fields give indexed commands room to preserve artifact metadata.

func EnrichCandidatesWithSectionMatches

func EnrichCandidatesWithSectionMatches(candidates []Candidate, query string) []Candidate

EnrichCandidatesWithSectionMatches adds conservative query-specific section evidence to candidates that were loaded from the SQLite section index.

func QueryBaseline

func QueryBaseline(candidates []Candidate, query string) []Candidate

type ConceptRank

type ConceptRank struct {
	Candidate        Candidate `json:"-"`
	Path             string    `json:"path"`
	Score            float64   `json:"score"`
	MatchedCompacts  []string  `json:"matched_compacts,omitempty"`
	MatchedPhrases   []string  `json:"matched_phrases,omitempty"`
	MatchedPathTerms []string  `json:"matched_path_terms,omitempty"`
	GlossaryMatches  []string  `json:"glossary_matches,omitempty"`
	GlossaryEvidence []string  `json:"glossary_evidence,omitempty"`
}

ConceptRank is an inspectable deterministic score for the experimental concept backfill lane. It is intentionally sparse: the retriever only uses it for a few high-confidence anchor recoveries after the primary ranked pack.

func RankConceptCandidates

func RankConceptCandidates(candidates []Candidate, query string) []ConceptRank

RankConceptCandidates exposes the deterministic concept scorer for eval diagnostics. It should remain a backfill/inspection aid, not a replacement for the weighted retriever.

func RankConceptCandidatesWithGlossary

func RankConceptCandidatesWithGlossary(candidates []Candidate, query string) []ConceptRank

RankConceptCandidatesWithGlossary applies the experimental local glossary gate before ranking. It is primarily used by eval diagnostics.

type IndexedSection

type IndexedSection struct {
	ID            string            `json:"id,omitempty"`
	ArtifactID    string            `json:"artifact_id,omitempty"`
	RevisionID    string            `json:"revision_id,omitempty"`
	SourcePath    string            `json:"source_path,omitempty"`
	HeadingPath   string            `json:"heading_path,omitempty"`
	HeadingDepth  int               `json:"heading_depth,omitempty"`
	StartLine     int               `json:"start_line,omitempty"`
	EndLine       int               `json:"end_line,omitempty"`
	Title         string            `json:"title,omitempty"`
	Body          string            `json:"body,omitempty"`
	TokenEstimate int               `json:"token_estimate,omitempty"`
	Kind          string            `json:"kind,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

type PackGroup

type PackGroup struct {
	Role          string     `json:"role"`
	Title         string     `json:"title"`
	Budget        int        `json:"budget,omitempty"`
	OverflowCount int        `json:"overflow_count,omitempty"`
	Items         []PackItem `json:"items"`
}

type PackItem

type PackItem struct {
	OriginalRank   int      `json:"original_rank"`
	ID             string   `json:"id,omitempty"`
	ShortID        string   `json:"short_id,omitempty"`
	Path           string   `json:"path,omitempty"`
	SourcePath     string   `json:"source_path,omitempty"`
	Kind           string   `json:"kind,omitempty"`
	Subtype        string   `json:"subtype,omitempty"`
	Title          string   `json:"title,omitempty"`
	Status         string   `json:"status,omitempty"`
	PackTier       string   `json:"pack_tier,omitempty"`
	Role           string   `json:"role"`
	RoleConfidence float64  `json:"role_confidence,omitempty"`
	RoleReason     string   `json:"role_reason,omitempty"`
	Reasons        []string `json:"reasons,omitempty"`
	AuthorityCues  []string `json:"authority_cues,omitempty"`
	TokenEstimate  int      `json:"token_estimate,omitempty"`
}

type PackRoleDecision

type PackRoleDecision struct {
	Role       string  `json:"role"`
	Confidence float64 `json:"confidence,omitempty"`
	Reason     string  `json:"reason,omitempty"`
}

func ClassifyPackRole

func ClassifyPackRole(c Candidate, query string) PackRoleDecision

type PackSummary

type PackSummary struct {
	IncludedCount          int      `json:"included_count"`
	ExcludedNoiseCount     int      `json:"excluded_noise_count,omitempty"`
	GroupCount             int      `json:"group_count,omitempty"`
	RoleDiversity          int      `json:"role_diversity,omitempty"`
	HasBackgroundDecisions bool     `json:"has_background_decisions,omitempty"`
	HasImplementation      bool     `json:"has_implementation_surface,omitempty"`
	HasBehaviorTests       bool     `json:"has_behavior_tests,omitempty"`
	HasConfigSchema        bool     `json:"has_config_schema,omitempty"`
	HasOpenWork            bool     `json:"has_open_work,omitempty"`
	HasSupportingContext   bool     `json:"has_supporting_context,omitempty"`
	Notes                  []string `json:"notes,omitempty"`
}

func BuildPackSummary

func BuildPackSummary(groups []PackGroup, excluded []PackItem) PackSummary

type Reason

type Reason struct {
	Path    string   `json:"path"`
	Reasons []string `json:"reasons"`
}

func ExplainCandidates

func ExplainCandidates(candidates []Candidate, query string) []Reason

type RepoVocabulary

type RepoVocabulary struct {
	Terms         map[string]TermStats `json:"terms"`
	DocumentCount int                  `json:"document_count"`
}

func BuildRepoVocabulary

func BuildRepoVocabulary(candidates []Candidate) RepoVocabulary

type Retriever

type Retriever interface {
	Name() string
	Retrieve(candidates []Candidate, query string) []Candidate
}

type RoleGroupedPack

type RoleGroupedPack struct {
	Mode          string            `json:"mode"`
	Summary       PackSummary       `json:"summary,omitempty"`
	Groups        []PackGroup       `json:"groups"`
	ExcludedNoise []PackItem        `json:"excluded_noise,omitempty"`
	Counts        map[string]int    `json:"counts,omitempty"`
	Notes         []string          `json:"notes,omitempty"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

func BuildRoleGroupedPack

func BuildRoleGroupedPack(candidates []Candidate, reasons map[string][]string, query string) RoleGroupedPack

type TermStats

type TermStats struct {
	TotalCount    int     `json:"total_count"`
	DocumentCount int     `json:"document_count"`
	PathCount     int     `json:"path_count"`
	TitleCount    int     `json:"title_count"`
	HeadingCount  int     `json:"heading_count"`
	TestNameCount int     `json:"test_name_count"`
	SymbolCount   int     `json:"symbol_count"`
	RoleCount     int     `json:"role_count"`
	IDF           float64 `json:"idf"`
}

type WeightedFilesRetrieverV0

type WeightedFilesRetrieverV0 struct {
	DisableSectionAware bool
	EvidenceMode        string
	ConceptBackfill     bool
	GlossaryConcepts    bool
	TieredConceptOutput bool
	AnchorFirstRanking  bool
	AnchorFirstMode     string
}

func (WeightedFilesRetrieverV0) Name

func (WeightedFilesRetrieverV0) Retrieve

func (r WeightedFilesRetrieverV0) Retrieve(candidates []Candidate, query string) []Candidate

Jump to

Keyboard shortcuts

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