Documentation
¶
Index ¶
- func AddManualLink(ctx context.Context, db *sql.DB, fromName, toName, rel string) error
- func AliasEntities(ctx context.Context, db *sql.DB, targetID string, aliases []ResolvedEntity) error
- func AutoAliasDuplicates(ctx context.Context, db *sql.DB) (int, error)
- func DismissAliasPair(ctx context.Context, db *sql.DB, a, b, actor string) error
- func DismissLinkPair(ctx context.Context, db *sql.DB, a, b, actor string) error
- func UnaliasEntity(ctx context.Context, db *sql.DB, aliasName string) error
- type AliasSuggestion
- type CatchupDelta
- type CooccurrenceNode
- type EntityGraph
- type EntityNode
- type FeatureGroup
- type LinkSuggestion
- type ManualLink
- type PathStep
- type ProximityWarning
- type ResolvedEntity
- type SearchOptions
- type SearchResponse
- type SearchResult
- type Suggestion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddManualLink ¶ added in v0.62.0
AddManualLink creates an explicit dependency edge fromName -> toName with the given relationship, marked source='manual' so it is exported to links.jsonl and survives re-extraction. Entity names are resolved to their canonical IDs. Returns an error if either entity is unknown.
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 AutoAliasDuplicates ¶ added in v0.55.0
AutoAliasDuplicates merges entities whose names are identical after normalization. Only exact normalized matches are merged — near matches ("ollama" vs "ollamaextractor") remain suggestions, never auto-merges. The canonical entity is the one with the highest mention_count; variant names stay in the entity_aliases registry so future extractions resolve to the canonical. Returns the number of entities merged away.
func DismissAliasPair ¶ added in v0.58.0
DismissAliasPair records that a suggested pair was reviewed and rejected, so it is never suggested again.
func DismissLinkPair ¶ added in v0.62.0
DismissLinkPair records that a suggested relationship was reviewed and rejected, so it is never suggested again.
Types ¶
type AliasSuggestion ¶ added in v0.53.1
type AliasSuggestion struct {
EntityA string `json:"entity_a"`
EntityB string `json:"entity_b"`
Similarity float64 `json:"session_overlap"`
NameSimilarity float64 `json:"name_similarity"`
Score float64 `json:"score"`
}
func GetAliasSuggestions ¶ added in v0.53.1
func GetAliasSuggestions(ctx context.Context, db *sql.DB, threshold float64, limit int) ([]AliasSuggestion, error)
It uses Jaccard similarity: intersection / union of sessions. GetAliasSuggestions returns entity pairs that are likely the same thing. Candidates need BOTH high session co-occurrence (Jaccard >= threshold) AND name similarity: co-occurrence alone conflates "related" with "identical" (a command and the file it lives in overlap 100%), and single-session pairs are pure noise (1/1 = perfect overlap from one observation) — hence the >= 2 sessions floor. Pairs recorded in alias_dismissals are never returned. limit <= 0 returns all matches; results are ranked by combined score.
type CatchupDelta ¶
type CatchupDelta struct {
Since time.Time
Sessions []SearchResult
ClosedIssues []types.Issue
StateChanges []types.BranchState
}
func GetCatchupDelta ¶
type CooccurrenceNode ¶
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 EntityNode ¶
type FeatureGroup ¶ added in v0.55.0
type FeatureGroup struct {
Key string `json:"key"`
Kind string `json:"kind"` // branch | entity | general
Narrative string `json:"narrative"`
Sessions []SearchResult `json:"sessions"`
Authors []string `json:"authors"`
Entities []string `json:"entities"`
StateChanges []types.BranchState `json:"state_changes"`
}
FeatureGroup is one "feature arc" of the catchup digest: sessions sharing a work branch, or (for trunk work) a dominant entity.
func GroupCatchupDelta ¶ added in v0.55.0
func GroupCatchupDelta(ctx context.Context, db *sql.DB, delta *CatchupDelta) ([]FeatureGroup, []types.BranchState)
GroupCatchupDelta organizes the delta's sessions into feature arcs. Branch is the primary arc key; trunk sessions are grouped by their most shared entity; leftovers form a "General" group. State changes matching an arc's key or entities attach to it; the rest are returned separately.
type LinkSuggestion ¶ added in v0.62.0
type LinkSuggestion struct {
EntityA string `json:"entity_a"`
EntityB string `json:"entity_b"`
CoSessions int `json:"co_sessions"`
Overlap float64 `json:"session_overlap"`
}
LinkSuggestion is a pair of entities that co-occur strongly in devlog sessions but have NO explicit dependency edge — a candidate for the agent to promote into a real relationship (BeadsLog-58r).
func GetLinkSuggestions ¶ added in v0.62.0
func GetLinkSuggestions(ctx context.Context, db *sql.DB, minCo, limit int) ([]LinkSuggestion, error)
GetLinkSuggestions returns entity pairs with high session co-occurrence and no explicit entity_deps edge in either direction. Dismissed pairs and noise endpoints are excluded; ranked by shared-session count. minCo is the minimum shared sessions; limit <= 0 returns all.
type ManualLink ¶ added in v0.62.0
type ManualLink struct {
FromName string `json:"from"`
ToName string `json:"to"`
Relationship string `json:"relationship"`
}
ManualLink is one exported manual edge, keyed by entity NAME so it survives DB reconstruction and travels between clones (links.jsonl).
func GetManualLinks ¶ added in v0.62.0
GetManualLinks returns all manual edges by name, for export to links.jsonl.
type ProximityWarning ¶
type ResolvedEntity ¶
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 ¶
SuggestEntities finds potential entity matches for a term that yielded no results. It uses fuzzy matching and Levenshtein distance for typo correction.