Documentation
¶
Index ¶
- func ValidCallType(t CallType) bool
- func ValidNodeKind(k NodeKind) bool
- type CallEdge
- type CallNode
- type CallType
- type CalleeOfResult
- type CallerOfResult
- type NodeKind
- type Store
- func (s *Store) AddEdge(e CallEdge) (*CallEdge, error)
- func (s *Store) AddEdgesBatch(edges []CallEdge) error
- func (s *Store) CalleesOf(nodeID int64) ([]CalleeOfResult, error)
- func (s *Store) CallersOf(nodeID int64) ([]CallerOfResult, error)
- func (s *Store) DeleteNode(id int64) error
- func (s *Store) DeleteNodesByDirectory(directory string) error
- func (s *Store) DeleteNodesByFile(directory, filePath string) (int64, error)
- func (s *Store) GetNode(id int64) (*CallNode, error)
- func (s *Store) GetNodeBySymbol(directory, pkg, symbol string) (*CallNode, error)
- func (s *Store) ListEdgesByDirectory(directory string) ([]CallEdge, error)
- func (s *Store) ListNodesByDirectory(directory string, pkgFilter string, kindFilter NodeKind) ([]CallNode, error)
- func (s *Store) ReachableFrom(nodeID int64, maxDepth int) ([]CallNode, error)
- func (s *Store) SearchNodes(directory, query string, limit int) ([]CallNode, error)
- func (s *Store) Stats(directory string) (nodes int, edges int, err error)
- func (s *Store) UpsertNode(n CallNode) (*CallNode, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidCallType ¶
ValidCallType reports whether t is a known call/relationship type.
func ValidNodeKind ¶
ValidNodeKind reports whether k is a known node kind.
Types ¶
type CallEdge ¶
type CallEdge struct {
ID int64 `json:"id"`
Directory string `json:"directory"`
CallerID int64 `json:"callerId"`
CalleeID int64 `json:"calleeId"`
CallType CallType `json:"callType"`
CreatedAt int64 `json:"createdAt"`
}
CallEdge represents a directed relationship between two nodes in the graph.
type CallNode ¶
type CallNode struct {
ID int64 `json:"id"`
Directory string `json:"directory"`
Package string `json:"package"`
Symbol string `json:"symbol"`
FilePath string `json:"filePath"`
Line int `json:"line"`
Kind NodeKind `json:"kind"`
Signature string `json:"signature,omitempty"`
Doc string `json:"doc,omitempty"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
CallNode represents any code symbol in the knowledge graph.
type CallType ¶
type CallType string
CallType classifies the relationship between two nodes in the graph. Named CallType for historical reasons; it covers all relationship types, not just function calls — including type, structural, and dependency edges.
const ( // ── Call relationships (function/method → function/method) ─────────────── CallDirect CallType = "direct" // explicit synchronous call: A() CallDynamic CallType = "dynamic" // via function pointer, stored closure, or first-class function CallInterface CallType = "interface" // via interface/virtual/dynamic dispatch CallCallback CallType = "callback" // passed as a callback or higher-order argument CallAsync CallType = "async" // concurrent/async invocation: goroutine spawn, JS await, Python asyncio, thread // ── Type / structural relationships ────────────────────────────────────── CallImplements CallType = "implements" // type → interface/trait/protocol/ABC it satisfies CallExtends CallType = "extends" // type → parent type (class inheritance, struct embedding, mixin) CallOverrides CallType = "overrides" // method → parent method it overrides/shadows CallInstantiates CallType = "instantiates" // function/method → type it constructs (new, make, literal, factory) CallContains CallType = "contains" // type → type of a field/property it holds (composition) CallAliases CallType = "aliases" // type → type it is an alias/typedef for // ── Dependency relationships ────────────────────────────────────────────── CallImports CallType = "imports" // module → module it imports or depends on CallUses CallType = "uses" // function/method → type or const it references without instantiating CallReads CallType = "reads" // function/method → module/global variable it reads CallWrites CallType = "writes" // function/method → module/global variable it writes or mutates CallDecorates CallType = "decorates" // function/class → entity it wraps or transforms (Python/TS decorator) CallThrows CallType = "throws" // function/method → exception/error type it can raise )
type CalleeOfResult ¶
CalleeOfResult holds a call edge along with the callee's info, returned by queries like "what does X call?".
type CallerOfResult ¶
CallerOfResult holds a call edge along with the caller's info, returned by queries like "who calls X?".
type NodeKind ¶
type NodeKind string
NodeKind classifies what kind of code entity a node represents. Kinds are language-agnostic — the same kind covers equivalent constructs across programming languages (Go, Python, TypeScript, Java, Rust, C/C++, etc.).
const ( // ── Callable entities ──────────────────────────────────────────────────── KindFunction NodeKind = "function" // standalone callable: Go func, Python def, JS function, Rust fn, C function KindMethod NodeKind = "method" // instance-bound callable: Go method, Python instance method, Java/C# method KindConstructor NodeKind = "constructor" // instance creation: Python __init__, Java/C# constructor, Rust new(), Swift init KindInit NodeKind = "init" // module/package initializer: Go init(), Python module-level setup, static initializers // ── Structural entities ─────────────────────────────────────────────────── KindType NodeKind = "type" // composite data type: Go struct, Python/Java/TS class, Rust struct/enum-with-data, Swift struct, record KindInterface NodeKind = "interface" // behavioral contract: Go interface, Rust trait, Java/C# interface, Python ABC/Protocol, Swift protocol, TS interface KindEnum NodeKind = "enum" // pure named-value set: Java enum, TS enum, Python Enum, C/C++ enum, Swift enum (no associated values) // ── Value entities ──────────────────────────────────────────────────────── KindConst NodeKind = "const" // named constant: Go const, Rust const/static, Java static final, JS/TS const, C #define/constexpr KindVariable NodeKind = "variable" // module/global mutable state: Go package var, Python global, JS module-level let, Rust static mut // ── Organizational entities ─────────────────────────────────────────────── KindModule NodeKind = "module" // organizational unit: Go package, Python module, JS/TS ES module, Rust mod, C++ namespace, Java package KindMacro NodeKind = "macro" // code-generating metaprogramming: Rust macro, C/C++ macro, Lisp macro, Elixir macro )
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides persistence operations for call graph nodes and edges.
func (*Store) AddEdgesBatch ¶
AddEdgesBatch inserts multiple edges in a single transaction.
func (*Store) CalleesOf ¶
func (s *Store) CalleesOf(nodeID int64) ([]CalleeOfResult, error)
CalleesOf returns all nodes that the given node calls, along with the edge info.
func (*Store) CallersOf ¶
func (s *Store) CallersOf(nodeID int64) ([]CallerOfResult, error)
CallersOf returns all nodes that call the given node, along with the edge info.
func (*Store) DeleteNode ¶
DeleteNode removes a call node by ID and its associated edges.
func (*Store) DeleteNodesByDirectory ¶
DeleteNodesByDirectory removes all call nodes and edges for a directory.
func (*Store) DeleteNodesByFile ¶
DeleteNodesByFile removes all call nodes (and their edges) for a given file path within a directory. This is used to purge stale call graph data after a file is mutated, so the agent can re-populate it with accurate information.
func (*Store) GetNodeBySymbol ¶
GetNodeBySymbol retrieves a call node by directory + package + symbol.
func (*Store) ListEdgesByDirectory ¶
ListEdgesByDirectory returns all call edges for a directory.
func (*Store) ListNodesByDirectory ¶
func (s *Store) ListNodesByDirectory(directory string, pkgFilter string, kindFilter NodeKind) ([]CallNode, error)
ListNodesByDirectory returns all call nodes for a directory, optionally filtered by package or kind.
func (*Store) ReachableFrom ¶
ReachableFrom returns all nodes reachable from the given node via call edges (transitive closure up to maxDepth hops). maxDepth=0 means unlimited.
func (*Store) SearchNodes ¶
SearchNodes searches call nodes by substring matching on symbol names, doc text, and signatures. It returns nodes whose symbol, doc, or signature contains the query string (case-insensitive). This enables discovery-oriented queries like "find all functions related to encryption" or "where is Store defined" without knowing exact package or symbol names — replacing many grep + read cycles with a single call graph query.