graph

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package graph provides entity resolution and graph traversal over the SQLite index.

Index

Constants

This section is empty.

Variables

View Source
var ConfidenceLevel = map[string]int{
	"low":    1,
	"medium": 2,
	"high":   3,
}

ConfidenceLevel maps confidence label to numeric rank (higher = more confident).

Functions

func MeetsConfidence

func MeetsConfidence(edgeConf, minConf string) bool

MeetsConfidence reports whether edgeConf satisfies the minConf threshold. An edge meets confidence if its level is >= the minimum required level.

Types

type InLink struct {
	SourceID    string `json:"source_id"`
	SourceTitle string `json:"source_title,omitempty"`
	SourcePath  string `json:"source_path,omitempty"`
	EdgeType    string `json:"edge_type"`
	Confidence  string `json:"confidence"`
	Origin      string `json:"origin,omitempty"`
	Resolved    bool   `json:"resolved"`
}

InLink represents a single inbound edge (for links in).

func LinksIn

func LinksIn(db *index.DB, noteID, edgeTypeFilter string) ([]InLink, error)

LinksIn returns all inbound edges pointing to the given note. Uses dst_raw matching for unresolved edges and dst_note_id for resolved ones.

type Match

type Match struct {
	ID     string  `json:"id"`
	Type   string  `json:"type"`
	Title  string  `json:"title"`
	Path   string  `json:"path"`
	Status *string `json:"status,omitempty"`
}

Match holds one candidate note from a resolution attempt.

type OutLink struct {
	TargetID    *string `json:"target_id"`
	TargetTitle string  `json:"target_title,omitempty"`
	TargetPath  string  `json:"target_path,omitempty"`
	TargetRaw   string  `json:"target_raw,omitempty"`
	EdgeType    string  `json:"edge_type"`
	Confidence  string  `json:"confidence"`
	Origin      string  `json:"origin,omitempty"`
	Resolved    bool    `json:"resolved"`
}

OutLink represents a single outbound edge (for links out).

func LinksOut

func LinksOut(db *index.DB, noteID, edgeTypeFilter string) ([]OutLink, error)

LinksOut returns all outbound edges from the given note. If edgeTypeFilter is non-empty, only edges of that type are returned.

type ResolveResult

type ResolveResult struct {
	Resolved       bool    `json:"resolved"`
	Ambiguous      bool    `json:"ambiguous"`
	Input          string  `json:"input"`
	ResolutionTier *string `json:"resolution_tier"`
	Matches        []Match `json:"matches"`
}

ResolveResult is the full output of entity resolution.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver performs 5-tier entity resolution against the SQLite index.

func NewResolver

func NewResolver(db *index.DB) *Resolver

NewResolver creates a Resolver backed by the given database.

func (*Resolver) Resolve

func (r *Resolver) Resolve(input string) (*ResolveResult, error)

Resolve runs the full resolution cascade for the given input string. Priority: path shortcut → id → title → alias → normalized → unresolved.

func (*Resolver) Traverse

func (r *Resolver) Traverse(cfg TraverseConfig) (*TraverseResult, error)

Traverse performs a BFS from cfg.StartID up to cfg.MaxDepth hops, respecting cfg.MinConfidence and cfg.MaxNodes limits. Both outbound and inbound resolved edges are followed (bidirectional).

type TraverseConfig

type TraverseConfig struct {
	StartID       string
	MaxDepth      int
	MinConfidence string
	MaxNodes      int
}

TraverseConfig holds parameters for a BFS traversal.

type TraverseEdge

type TraverseEdge struct {
	SourceID   string  `json:"source_id"`
	EdgeType   string  `json:"edge_type"`
	Confidence string  `json:"confidence"`
	Weight     float64 `json:"weight"`
}

TraverseEdge describes the edge by which a node was reached.

type TraverseNode

type TraverseNode struct {
	ID       string        `json:"id"`
	Distance int           `json:"distance"`
	EdgeFrom *TraverseEdge `json:"edge_from,omitempty"`
}

TraverseNode represents a node in the BFS result.

type TraverseResult

type TraverseResult struct {
	StartID         string         `json:"start_id"`
	Nodes           []TraverseNode `json:"nodes"`
	MaxNodesReached bool           `json:"max_nodes_reached"`
}

TraverseResult is the full output of a BFS traversal.

Jump to

Keyboard shortcuts

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