Documentation
¶
Index ¶
Constants ¶
const DefaultSimilarityThreshold = 0.92
DefaultSimilarityThreshold is the default cosine similarity threshold for entity merging.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsolidationResult ¶
type ConsolidationResult struct {
KBID string `json:"kb_id"`
Candidates int `json:"candidates"`
Merged int `json:"merged"`
Pairs []*MergePair `json:"pairs,omitempty"`
RelationsFixed int64 `json:"relations_fixed"`
RelationsDeduped int64 `json:"relations_deduped"`
}
ConsolidationResult summarizes a consolidation run.
type Consolidator ¶
type Consolidator struct {
// contains filtered or unexported fields
}
Consolidator finds and merges duplicate entities based on embedding similarity.
func NewConsolidator ¶
func NewConsolidator(store storage.Store, threshold float64) *Consolidator
NewConsolidator creates a consolidator with the given similarity threshold.
func (*Consolidator) FindCandidates ¶
FindCandidates returns pairs of entities with similarity above threshold. This is a brute-force O(n²) scan — suitable for <10K entities per KB.
func (*Consolidator) Merge ¶
func (c *Consolidator) Merge(ctx context.Context, kbID string, pair *MergePair) (*MergeResult, error)
Merge executes a consolidation: redirects relations from merged entity to survivor, deduplicates any resulting duplicate edges, then deletes the merged entity.
func (*Consolidator) RunConsolidation ¶
func (c *Consolidator) RunConsolidation(ctx context.Context, kbID string) (*ConsolidationResult, error)
RunConsolidation finds candidates and merges them all. Returns a summary.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager runs periodic decay and prune cycles across all knowledge bases.
func NewManager ¶
func NewManager(store storage.Store, cfg ManagerConfig) *Manager
NewManager creates a lifecycle manager.
type ManagerConfig ¶
type ManagerConfig struct {
DecayInterval time.Duration // how often to run decay (default 1h)
PruneInterval time.Duration // how often to run prune (default 24h)
DecayHalfLife float64 // half-life in hours (default 168 = 1 week)
PruneThreshold float64 // minimum strength to keep (default 0.05)
}
ManagerConfig configures the background lifecycle manager.
type MergePair ¶
type MergePair struct {
Survivor *domain.Entity `json:"survivor"`
Merged *domain.Entity `json:"merged"`
Score float64 `json:"score"` // cosine similarity
}
MergePair represents two entities that should be merged.
type MergeResult ¶
MergeResult holds counters from a single entity merge operation.