retrieval

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 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"
	AnchorFirstModeCodeTask         = "code_task"
	AnchorFirstModeCodeTaskFamily   = "code_task_family"
	AnchorFirstModeCodeTaskFamilyV2 = "code_task_family_v2"
	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 (
	FamilyPrimaryPackMode   = "role_grouped_pack_v0_family_primary_v0"
	FamilyPrimaryPackModeV1 = "role_grouped_pack_v0_family_primary_v1"
	FamilyPrimaryPackModeV2 = "role_grouped_pack_v0_family_primary_v2"
)
View Source
const (
	PackScoutUncertaintyKey               = "pack_scout_uncertainty"
	PackScoutUncertaintyReasonsKey        = "pack_scout_uncertainty_reasons"
	PackScoutUncertaintyMissingAnchorsKey = "pack_scout_uncertainty_missing_anchors"
)
View Source
const (
	PackTierPrimary    = "primary"
	PackTierRelated    = "related"
	PackTierDiagnostic = "diagnostic"
)
View Source
const (
	BoundaryPrimaryPackMode = "role_grouped_pack_v0_boundary_primary_v0"
)
View Source
const EvidenceModeBalanced = "balanced"

Variables

This section is empty.

Functions

func AnchorFirstModeUsesCodeTaskFamilyRanking added in v1.0.0

func AnchorFirstModeUsesCodeTaskFamilyRanking(mode string) bool

func AnchorFirstModeUsesCodeTaskFamilyV2 added in v1.0.0

func AnchorFirstModeUsesCodeTaskFamilyV2(mode string) bool

func AnchorFirstModeUsesCodeTaskWeights added in v1.0.0

func AnchorFirstModeUsesCodeTaskWeights(mode string) bool

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 IsBoundaryPrimaryPack added in v1.0.0

func IsBoundaryPrimaryPack(pack RoleGroupedPack) bool

func IsFamilyPrimaryPack added in v1.0.0

func IsFamilyPrimaryPack(pack RoleGroupedPack) bool

func IsPlanningIntentPath

func IsPlanningIntentPath(path string) bool

func IsSourceContextCandidate

func IsSourceContextCandidate(c Candidate) bool

func LocalLanguageReceipts added in v1.0.0

func LocalLanguageReceipts(pack RoleGroupedPack) []string

func NormalizeAnchorFirstMode

func NormalizeAnchorFirstMode(mode string) string

func PackItemIsRelated added in v1.0.0

func PackItemIsRelated(item PackItem) bool

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 AddScoutAnchorAdmissionCandidates added in v1.0.0

func AddScoutAnchorAdmissionCandidates(selected, universe []Candidate, query string) []Candidate

AddScoutAnchorAdmissionCandidates appends a few indexed source/test candidates when the selected set missed a clustered dominant query anchor. This is beta/scout-only plumbing: it does not scan the filesystem and does not affect default retrieval.

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 PackBoundarySummary added in v1.0.0

type PackBoundarySummary struct {
	Role     string   `json:"role"`
	Title    string   `json:"title,omitempty"`
	Boundary string   `json:"boundary"`
	Count    int      `json:"count"`
	Examples []string `json:"examples,omitempty"`
}

PackBoundarySummary is a compact description of related context hidden from the default boundary-primary human view. The underlying items stay present in JSON and verbose output.

func BoundaryRelatedSummaries added in v1.0.0

func BoundaryRelatedSummaries(pack RoleGroupedPack) []PackBoundarySummary

func FamilyPrimaryRelatedSummaries added in v1.0.0

func FamilyPrimaryRelatedSummaries(pack RoleGroupedPack) []PackBoundarySummary

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"`
	Boundary       string   `json:"boundary,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 ApplyBoundaryPrimaryPack added in v1.0.0

func ApplyBoundaryPrimaryPack(pack RoleGroupedPack) RoleGroupedPack

ApplyBoundaryPrimaryPack tiers an already selected pack into a small primary view plus related context. It is presentation/ranking only: no candidates are admitted or removed from JSON/verbose output.

func ApplyBoundaryPrimaryPackForQuery added in v1.0.0

func ApplyBoundaryPrimaryPackForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

func ApplyDemotionOnlyNegativeEvidence added in v1.0.0

func ApplyDemotionOnlyNegativeEvidence(pack RoleGroupedPack, query string) RoleGroupedPack

ApplyDemotionOnlyNegativeEvidence moves likely low-signal rows out of the working set without admitting new candidates. It is intended for explicit scout/beta pack modes, not default pack behavior.

func ApplyFamilyPrimaryPackForQuery added in v1.0.0

func ApplyFamilyPrimaryPackForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

func ApplyFamilyPrimaryPackV1ForQuery added in v1.0.0

func ApplyFamilyPrimaryPackV1ForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

func ApplyFamilyPrimaryPackV2ForQuery added in v1.0.0

func ApplyFamilyPrimaryPackV2ForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

func ApplyScoutSourcePrimaryPreservationForQuery added in v1.0.0

func ApplyScoutSourcePrimaryPreservationForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

ApplyScoutSourcePrimaryPreservationForQuery promotes a small number of already-selected related source rows back into the beta primary tier when family-primary presentation would otherwise hide high-confidence edit-target candidates behind the related wall.

func ApplyScoutSourceTestRescueForQuery added in v1.0.0

func ApplyScoutSourceTestRescueForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

ApplyScoutSourceTestRescueForQuery promotes a small number of related source rows when already-primary tests and the query point at the same source stem. It never admits new candidates and only moves related rows to primary.

func ApplyScoutUncertaintyForQuery added in v1.0.0

func ApplyScoutUncertaintyForQuery(pack RoleGroupedPack, query string) RoleGroupedPack

ApplyScoutUncertaintyForQuery adds beta/scout-only caution receipts when the visible first working set looks exploratory rather than source/test complete.

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