queries

package
v0.54.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AliasEntities added in v0.53.1

func AliasEntities(ctx context.Context, db *sql.DB, targetID string, aliases []ResolvedEntity) error

AliasEntities collapses one or more alias entities into a target canonical entity. It merges all relationships and session mentions in a single transaction and records the mapping in the registry.

func UnaliasEntity added in v0.53.1

func UnaliasEntity(ctx context.Context, db *sql.DB, aliasName string) error

UnaliasEntity removes a mapping from the registry.

Types

type AliasSuggestion added in v0.53.1

type AliasSuggestion struct {
	EntityA    string
	EntityB    string
	Similarity float64
}

func GetAliasSuggestions added in v0.53.1

func GetAliasSuggestions(ctx context.Context, db *sql.DB, threshold float64) ([]AliasSuggestion, error)

GetAliasSuggestions finds pairs of entities that frequently appear in the same sessions. It uses Jaccard similarity: intersection / union of sessions.

type CatchupDelta

type CatchupDelta struct {
	Since        time.Time
	Sessions     []SearchResult
	ClosedIssues []types.Issue
	StateChanges []types.BranchState
}

func GetCatchupDelta

func GetCatchupDelta(ctx context.Context, db *sql.DB, since time.Time) (*CatchupDelta, error)

type CooccurrenceNode

type CooccurrenceNode struct {
	Name  string
	Count int
}

func GetRelatedEntitiesByCooccurrence

func GetRelatedEntitiesByCooccurrence(ctx context.Context, db *sql.DB, entityID string, limit int) ([]CooccurrenceNode, error)

GetRelatedEntitiesByCooccurrence finds entities that frequently appear in the same sessions

type EntityGraph

type EntityGraph struct {
	Nodes []EntityNode
}

func GetEntityGraphExact

func GetEntityGraphExact(ctx context.Context, db *sql.DB, entityName string, depth int, relType string) (*EntityGraph, error)

func GetEntityImpactExact added in v0.53.1

func GetEntityImpactExact(ctx context.Context, db *sql.DB, entityName string, depth int, relType string) (*EntityGraph, error)

type EntityNode

type EntityNode struct {
	ID           string
	Name         string
	Relationship string
	Depth        int
	Path         string
}

type PathStep

type PathStep struct {
	EntityName   string
	SessionID    string
	SessionTitle string
}

func GetPathBetweenEntities

func GetPathBetweenEntities(ctx context.Context, db *sql.DB, startID, endID string) ([]PathStep, error)

GetPathBetweenEntities finds the shortest path between two entities via devlog sessions

type ProximityWarning

type ProximityWarning struct {
	State        types.LifecycleState
	ScopeType    types.ScopeType
	ScopeRef     string
	ShortReason  string
	FullReasonID string
}

func CheckProximityWarnings

func CheckProximityWarnings(ctx context.Context, db *sql.DB, scopeType types.ScopeType, scopeRef string) ([]ProximityWarning, error)

CheckProximityWarnings checks if the given scope overlaps with any paused or abandoned states

type ResolvedEntity

type ResolvedEntity struct {
	ID   string
	Name string
}

func ResolveEntities

func ResolveEntities(ctx context.Context, db *sql.DB, term string, limit int) ([]ResolvedEntity, error)

ResolveEntities finds entities matching the term using Hybrid FTS + LIKE logic. This ensures consistent behavior between "Search" and "Graph/Impact" commands.

type SearchOptions

type SearchOptions struct {
	Query         string
	Author        string
	CurrentBranch string
	Limit         int
	Strict        bool // If true, only BM25 on sessions, no expansion
	TextOnly      bool // If true, only BM25, no entity lookup
	Preview       bool // If true, show first 3 lines instead of snippet
	Explain       bool // If true, show score breakdown
}

type SearchResponse

type SearchResponse struct {
	Results         []SearchResult
	RelatedEntities []string
	Strategy        string // e.g. "exact", "hybrid", "fallback"
}

func HybridSearch

func HybridSearch(ctx context.Context, db *sql.DB, opts SearchOptions) (SearchResponse, error)

type SearchResult

type SearchResult struct {
	ID        string  `json:"id"`
	Title     string  `json:"title"`
	Date      string  `json:"date"`
	Narrative string  `json:"narrative"` // Snippet or Preview
	Score     float64 `json:"score"`
	Reason    string  `json:"reason"` // e.g. "text match", "entity:Modal"

	// Explanation fields (for --explain)
	BM25         float64 `json:"bm25"`
	PhraseBonus  float64 `json:"phrase_bonus"`
	NearBonus    float64 `json:"near_bonus"`
	EntityBonus  float64 `json:"entity_bonus"`
	RecencyBonus float64 `json:"recency_bonus"`

	IsLowConfidence bool `json:"is_low_confidence"`

	// Lifecycle fields
	LifecycleStatus types.LifecycleState `json:"lifecycle_status"`
	StatusReason    string               `json:"status_reason"`
	IsValidated     bool                 `json:"is_validated"`
	Branch          string               `json:"branch"`
	Author          string               `json:"author"`
	AuthorEmail     string               `json:"author_email"`
	Agent           string               `json:"agent"`
}

type Suggestion

type Suggestion struct {
	Name     string
	Distance int    // -1 if not applicable
	Type     string // "exact", "typo", "fuzzy"
}

func SuggestEntities

func SuggestEntities(ctx context.Context, db *sql.DB, term string) ([]Suggestion, error)

SuggestEntities finds potential entity matches for a term that yielded no results. It uses fuzzy matching and Levenshtein distance for typo correction.

Jump to

Keyboard shortcuts

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