Documentation
¶
Index ¶
- Constants
- func BuildSearchTerms(symbolName, filePath string) string
- type Store
- func (s *Store) Close() error
- func (s *Store) DB() *sql.DB
- func (s *Store) DeleteByFile(filePath string) error
- func (s *Store) DeleteFTSByFile(filePath string) error
- func (s *Store) FindRouteNodesByKeywords(keywords []string, limit int) ([]types.SearchResult, error)
- func (s *Store) GetAllBetweenness() (map[string]float64, error)
- func (s *Store) GetAllEdges() ([]types.ASTEdge, error)
- func (s *Store) GetAllFilePaths() ([]string, error)
- func (s *Store) GetAllNodeIDs() ([]string, error)
- func (s *Store) GetAllNodeScores() ([]types.NodeScore, error)
- func (s *Store) GetAllProjectSummaries() ([]types.ProjectSummary, error)
- func (s *Store) GetEdgesFrom(nodeID string) ([]types.ASTEdge, error)
- func (s *Store) GetEdgesTo(nodeID string) ([]types.ASTEdge, error)
- func (s *Store) GetFileIntent(filePath string) (*gitmeta.FileIntent, error)
- func (s *Store) GetFileIntentsByPaths(paths []string) (map[string]*gitmeta.FileIntent, error)
- func (s *Store) GetIncomingCrossFileEdges(filePath string) ([]types.ASTEdge, error)
- func (s *Store) GetLatestStoredCommitHash() (string, error)
- func (s *Store) GetNode(nodeID string) (*types.ASTNode, error)
- func (s *Store) GetNodeByName(symbolName string) (*types.ASTNode, error)
- func (s *Store) GetNodeIDsByFile(filePath string) ([]string, error)
- func (s *Store) GetNodeScore(nodeID string) (*types.NodeScore, error)
- func (s *Store) GetNodesByFile(filePath string) ([]types.ASTNode, error)
- func (s *Store) GetProjectSummary(project string) (*types.ProjectSummary, error)
- func (s *Store) GetRepoSnapshot(repoRoot string) (*gitmeta.RepoSnapshot, error)
- func (s *Store) GetSymbolIndex() (map[string]string, error)
- func (s *Store) HasVecTable() bool
- func (s *Store) RawQuery(query string) ([]map[string]interface{}, error)
- func (s *Store) SchemaVersion() (int, error)
- func (s *Store) SearchLexical(query string, limit int) ([]types.SearchResult, error)
- func (s *Store) SearchLexicalByType(query string, nodeType types.NodeType, limit int) ([]types.SearchResult, error)
- func (s *Store) SearchLexicalFilteredRaw(query string, nodeTypes []types.NodeType, limit int) ([]types.SearchResult, error)
- func (s *Store) SearchLexicalRaw(query string, limit int) ([]types.SearchResult, error)
- func (s *Store) SearchNodesByName(pattern string) ([]types.ASTNode, error)
- func (s *Store) SearchSemantic(queryEmbedding []float32, limit int) ([]types.SearchResult, error)
- func (s *Store) UpdateFTS(node types.ASTNode) error
- func (s *Store) UpsertEdge(edge types.ASTEdge) error
- func (s *Store) UpsertEdges(edges []types.ASTEdge) error
- func (s *Store) UpsertEmbedding(nodeID string, embedding []float32) error
- func (s *Store) UpsertFileHistory(changes []gitmeta.FileChange) error
- func (s *Store) UpsertFileIntents(intents []gitmeta.FileIntent) error
- func (s *Store) UpsertGitCommits(commits []gitmeta.CommitInfo) error
- func (s *Store) UpsertNode(node types.ASTNode) error
- func (s *Store) UpsertNodeScores(scores []types.NodeScore) error
- func (s *Store) UpsertNodes(nodes []types.ASTNode) error
- func (s *Store) UpsertProjectSummary(summary types.ProjectSummary) error
- func (s *Store) UpsertRepoSnapshot(snap gitmeta.RepoSnapshot) error
Constants ¶
const DefaultEmbeddingDim = 384
DefaultEmbeddingDim is the default embedding dimension (TFIDF fallback).
Variables ¶
This section is empty.
Functions ¶
func BuildSearchTerms ¶
BuildSearchTerms produces a space-separated string of tokens derived from the symbol name (CamelCase-split) and the file basename (split on . _ -). This string is stored in the FTS index so that inner tokens of compound identifiers like "PaymentMappingService" become individually searchable. The original unsplit symbol name and file basename are prepended (preserving case) to enable compound prefix matching, matching the C reference codebase's behavior.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages all SQLite database operations
func NewStore ¶
NewStore opens (or creates) a SQLite database at the given path and runs migrations. embeddingDim sets the expected embedding vector dimension (0 uses DefaultEmbeddingDim).
func (*Store) DB ¶
DB returns the underlying sql.DB for raw queries. WARNING: Bypasses all safety checks (read-only enforcement, blocklist). Use RawQuery for safe user-facing queries. Only use DB() for internal operations.
func (*Store) DeleteByFile ¶
DeleteByFile removes all nodes and their edges for a given file path
func (*Store) DeleteFTSByFile ¶
DeleteFTSByFile removes FTS entries for all nodes in a file
func (*Store) FindRouteNodesByKeywords ¶
func (s *Store) FindRouteNodesByKeywords(keywords []string, limit int) ([]types.SearchResult, error)
FindRouteNodesByKeywords searches for route-type nodes whose search_terms contain any of the given keywords. Returns matching route nodes with relevance scoring.
func (*Store) GetAllBetweenness ¶
GetAllBetweenness retrieves all betweenness centrality scores as a map
func (*Store) GetAllEdges ¶
GetAllEdges retrieves all edges from the database
func (*Store) GetAllFilePaths ¶
GetAllFilePaths returns all unique file paths from the nodes table
func (*Store) GetAllNodeIDs ¶
GetAllNodeIDs retrieves all node IDs from the database
func (*Store) GetAllNodeScores ¶
GetAllNodeScores returns all node scores as a slice
func (*Store) GetAllProjectSummaries ¶
func (s *Store) GetAllProjectSummaries() ([]types.ProjectSummary, error)
GetAllProjectSummaries retrieves all project summaries
func (*Store) GetEdgesFrom ¶
GetEdgesFrom retrieves all outgoing edges from a node
func (*Store) GetEdgesTo ¶
GetEdgesTo retrieves all incoming edges to a node
func (*Store) GetFileIntent ¶
func (s *Store) GetFileIntent(filePath string) (*gitmeta.FileIntent, error)
GetFileIntent returns the stored intent summary for a file.
func (*Store) GetFileIntentsByPaths ¶
GetFileIntentsByPaths returns intent summaries for multiple files.
func (*Store) GetIncomingCrossFileEdges ¶
GetIncomingCrossFileEdges returns edges where the target node belongs to filePath but the source node does NOT belong to filePath (cross-file incoming references).
func (*Store) GetLatestStoredCommitHash ¶
GetLatestStoredCommitHash returns the most recent commit hash stored in git_commits. Returns empty string if no commits stored.
func (*Store) GetNodeByName ¶
GetNodeByName retrieves a node by symbol name (exact match)
func (*Store) GetNodeIDsByFile ¶
GetNodeIDsByFile retrieves all node IDs for a given file path. Used for incremental graph updates: remove old nodes before adding new ones.
func (*Store) GetNodeScore ¶
GetNodeScore retrieves the scores for a single node
func (*Store) GetNodesByFile ¶
GetNodesByFile returns all nodes for a given file path
func (*Store) GetProjectSummary ¶
func (s *Store) GetProjectSummary(project string) (*types.ProjectSummary, error)
GetProjectSummary retrieves a project summary by project name
func (*Store) GetRepoSnapshot ¶
func (s *Store) GetRepoSnapshot(repoRoot string) (*gitmeta.RepoSnapshot, error)
GetRepoSnapshot returns the stored git snapshot for the given repo root.
func (*Store) GetSymbolIndex ¶
GetSymbolIndex returns a map of symbol_name -> node_id for symbols used in cross-file edge resolution during incremental re-index. It includes type nodes plus functions/methods, and also adds a best-effort bare-method alias (e.g. "Controller.handle" -> "handle") when the alias is not already claimed by another symbol.
func (*Store) HasVecTable ¶
HasVecTable returns whether the sqlite-vec virtual table is available
func (*Store) RawQuery ¶
RawQuery executes a read-only SQL query and returns results as maps. Only SELECT statements are allowed to prevent SQL injection.
func (*Store) SchemaVersion ¶
SchemaVersion returns the current schema version (exported for testing)
func (*Store) SearchLexical ¶
SearchLexical performs FTS5 BM25 lexical search
func (*Store) SearchLexicalByType ¶
func (s *Store) SearchLexicalByType(query string, nodeType types.NodeType, limit int) ([]types.SearchResult, error)
SearchLexicalByType performs FTS5 BM25 search filtered to a specific node type. Used for route-specific candidate injection when query intent indicates routes.
func (*Store) SearchLexicalFilteredRaw ¶
func (s *Store) SearchLexicalFilteredRaw(query string, nodeTypes []types.NodeType, limit int) ([]types.SearchResult, error)
SearchLexicalFilteredRaw performs FTS5 BM25 search filtered to specific node types. Like SearchLexicalRaw but adds WHERE n.node_type IN (...) filter. Used to exclude route nodes from general FTS (routes are found via edge-based lookup).
func (*Store) SearchLexicalRaw ¶
SearchLexicalRaw performs FTS5 BM25 lexical search without sanitizing the query. Use this when the caller has already constructed a valid FTS5 query (e.g., with boolean operators like OR and prefix wildcards like *). For untrusted user input, use SearchLexical instead which sanitizes automatically.
func (*Store) SearchNodesByName ¶
SearchNodesByName searches for nodes whose symbol_name contains the given pattern (case-insensitive)
func (*Store) SearchSemantic ¶
SearchSemantic performs KNN semantic search using sqlite-vec. Returns nil, nil (empty results, no error) if sqlite-vec is not available, enabling graceful degradation to lexical-only search.
func (*Store) UpdateFTS ¶
UpdateFTS updates the FTS index for a node. Wrapped in a transaction so DELETE+INSERT are atomic — if INSERT fails, the old entry is preserved.
func (*Store) UpsertEdge ¶
UpsertEdge inserts or ignores an edge in the database
func (*Store) UpsertEdges ¶
UpsertEdges batch-inserts edges using a transaction
func (*Store) UpsertEmbedding ¶
UpsertEmbedding stores a vector embedding for a node. The embedding dimension must match the configured store dimension. Returns nil (no-op) if sqlite-vec is not available, enabling graceful degradation. Wrapped in a transaction to ensure delete + insert are atomic.
func (*Store) UpsertFileHistory ¶
func (s *Store) UpsertFileHistory(changes []gitmeta.FileChange) error
UpsertFileHistory stores file-commit associations in batch.
func (*Store) UpsertFileIntents ¶
func (s *Store) UpsertFileIntents(intents []gitmeta.FileIntent) error
UpsertFileIntents stores compacted file intent summaries in batch.
func (*Store) UpsertGitCommits ¶
func (s *Store) UpsertGitCommits(commits []gitmeta.CommitInfo) error
UpsertGitCommits stores commit metadata in batch.
func (*Store) UpsertNode ¶
UpsertNode inserts or updates a node in the database. Uses ON CONFLICT to avoid DELETE+INSERT which would cascade-delete edges. Wrapped in a transaction to ensure node + FTS index stay in sync.
func (*Store) UpsertNodeScores ¶
UpsertNodeScores batch-inserts node scores using a transaction
func (*Store) UpsertNodes ¶
UpsertNodes batch-inserts nodes using a transaction
func (*Store) UpsertProjectSummary ¶
func (s *Store) UpsertProjectSummary(summary types.ProjectSummary) error
UpsertProjectSummary inserts or updates a project summary
func (*Store) UpsertRepoSnapshot ¶
func (s *Store) UpsertRepoSnapshot(snap gitmeta.RepoSnapshot) error
UpsertRepoSnapshot stores or updates the repository git snapshot.