Documentation
¶
Index ¶
- func ParseDir(dir, pkgPath string, store *Store) error
- type Edge
- type EdgeKind
- type Index
- func (idx *Index) Callees(symID NodeID) []*Node
- func (idx *Index) Callers(symID NodeID) []*Node
- func (idx *Index) Impact(symID NodeID) []*Node
- func (idx *Index) Lookup(id NodeID) *Node
- func (idx *Index) Rebuild(root string) error
- func (idx *Index) Search(name string) []*Node
- func (idx *Index) Store() *Store
- type LatentInjector
- type Node
- type NodeID
- type NodeKind
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
Index is the primary entry point for the codegraph. It manages incremental parsing and exposes query methods.
func (*Index) Impact ¶
Impact performs a reverse-BFS from symID over CALLS edges and returns all nodes that transitively call symID (i.e., would be affected by a change).
func (*Index) Lookup ¶
Lookup returns the Node with the given id, or nil if not present. It holds idx.mu.RLock for both the store dereference and the map lookup, preventing a data race with a concurrent Rebuild that atomically swaps idx.store.
func (*Index) Rebuild ¶
Rebuild walks root, re-parses files whose content hash changed, and removes nodes/edges for files that disappeared. It is safe to call repeatedly.
func (*Index) Search ¶
Search returns all nodes whose Name matches the query (exact match first, then prefix matches when no exact match is found).
func (*Index) Store ¶
Store returns a snapshot pointer to the underlying Store at the instant of the call. The pointer is valid for READ-ONLY use only. It carries no durability guarantee: a concurrent Rebuild may atomically replace idx.store at any time after Store() returns, making the returned pointer stale. Callers must NOT retain the pointer across yield points and must NOT call AddNode / AddEdge through it; doing so introduces a data race. Use the Index query methods (Search, Callers, Callees, Impact, Lookup) for safe access.
type LatentInjector ¶
type LatentInjector struct {
// contains filtered or unexported fields
}
LatentInjector renders the top-N most central symbols from an Index into a compact markdown snippet suitable for injection into the dynamic context window (i.e., AFTER prompt.DynamicContextBoundary).
func NewLatentInjector ¶
func NewLatentInjector(idx *Index, topN int) *LatentInjector
NewLatentInjector creates a LatentInjector that will render the top-N symbols by PageRank centrality.
func (*LatentInjector) Render ¶
func (li *LatentInjector) Render() string
Render returns a markdown-formatted symbol table of the most central nodes. The output is intended for placement AFTER prompt.DynamicContextBoundary.
type Node ¶
type Node struct {
ID NodeID
Kind NodeKind
Name string
File string
Line int
Snippet string // first line of declaration
}
Node represents a single named symbol.
func RankByPageRank ¶
RankByPageRank runs `iterations` steps of PageRank over the CALLS edge set and returns nodes sorted descending by score. A sensible value for iterations is 20–100 for small graphs; higher values cost more but converge more tightly. When iterations is 0 or negative the loop is skipped and every node receives an equal score of 1/n, with ties broken arbitrarily by the final sort.
type NodeID ¶
type NodeID string
NodeID is a fully-qualified symbol identifier: "<pkg-path>.<Name>". Defined as a distinct type (not an alias) to prevent raw strings from being passed where a NodeID is expected.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the in-memory graph. The adjacency maps are unexported to ensure all mutations go through AddEdge, which maintains Out/In consistency and deduplication.
func NewStore ¶
func NewStore() *Store
NewStore returns an empty Store with all internal maps initialised.
func (*Store) InEdges ¶
InEdges returns a copy of the incoming edges to the given node. Returns nil when the node has no incoming edges. Callers may freely modify the returned slice without affecting store internals.