Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateSemanticSimilarity(nodeA, nodeB *Node) float64
- func MakeNodeID(kind NodeKind, parts ...string) string
- type Edge
- type EdgeType
- type Evolver
- type ExploreRequest
- type ExploreResult
- type FeatureExtractor
- type FetchNodeRequest
- type FetchNodeResult
- type GOBRPGStore
- type Graph
- func (g *Graph) AddEdge(e *Edge)
- func (g *Graph) AddNode(n *Node)
- func (g *Graph) GetIncoming(nodeID string) []*Edge
- func (g *Graph) GetNeighbors(nodeID string, direction string) []string
- func (g *Graph) GetNode(id string) *Node
- func (g *Graph) GetNodesByFile(path string) []*Node
- func (g *Graph) GetNodesByKind(kind NodeKind) []*Node
- func (g *Graph) GetOutgoing(nodeID string) []*Edge
- func (g *Graph) NodePath(id string) (string, bool)
- func (g *Graph) RebuildIndexes()
- func (g *Graph) RemoveEdgesBetween(from, to string)
- func (g *Graph) RemoveEdgesBetweenOfType(from, to string, edgeType EdgeType)
- func (g *Graph) RemoveEdgesIf(predicate func(*Edge) bool)
- func (g *Graph) RemoveNode(id string)
- func (g *Graph) Stats() GraphStats
- type GraphStats
- type HierarchyBuilder
- func (h *HierarchyBuilder) BuildHierarchy()
- func (h *HierarchyBuilder) ClassifyFile(filePath string) (string, string)
- func (h *HierarchyBuilder) ClassifySymbol(feature string) string
- func (h *HierarchyBuilder) ClusterSymbols(symbols []*Node) map[string][]*Node
- func (h *HierarchyBuilder) EnrichLabels()
- func (h *HierarchyBuilder) EnsureArea(name string) string
- func (h *HierarchyBuilder) EnsureCategory(areaID, name string) string
- func (h *HierarchyBuilder) EnsureSubcategory(catID, name string) string
- type LLMExtractor
- func (e *LLMExtractor) ExtractAtomicFeatures(ctx context.Context, symbolName, signature, receiver, comment string) []string
- func (e *LLMExtractor) ExtractFeature(ctx context.Context, symbolName, signature, receiver, comment string) string
- func (e *LLMExtractor) GenerateSummary(ctx context.Context, name, contextStr string) (string, error)
- func (e *LLMExtractor) Mode() string
- type LLMExtractorConfig
- type LocalExtractor
- func (e *LocalExtractor) ExtractAtomicFeatures(_ context.Context, symbolName, signature, receiver, comment string) []string
- func (e *LocalExtractor) ExtractFeature(_ context.Context, symbolName, signature, receiver, comment string) string
- func (e *LocalExtractor) GenerateSummary(_ context.Context, name, contextStr string) (string, error)
- func (e *LocalExtractor) Mode() string
- type Node
- type NodeKind
- type ProgressObserver
- type QueryEngine
- func (qe *QueryEngine) Explore(_ context.Context, req ExploreRequest) (*ExploreResult, error)
- func (qe *QueryEngine) FetchNode(_ context.Context, req FetchNodeRequest) (*FetchNodeResult, error)
- func (qe *QueryEngine) FetchNodes(ctx context.Context, req FetchNodeRequest) ([]*FetchNodeResult, error)
- func (qe *QueryEngine) SearchNode(_ context.Context, req SearchNodeRequest) ([]SearchNodeResult, error)
- type RPGEncoder
- func (idx *RPGEncoder) BuildFull(ctx context.Context, symbolStore trace.SymbolStore, ...) error
- func (idx *RPGEncoder) GetEvolver() *Evolver
- func (idx *RPGEncoder) GetGraph() *Graph
- func (idx *RPGEncoder) HandleFileEvent(ctx context.Context, eventType string, filePath string, symbols []trace.Symbol) error
- func (idx *RPGEncoder) LinkChunksForFile(ctx context.Context, filePath string, chunks []store.Chunk) error
- func (idx *RPGEncoder) RefreshDerivedEdgesFull(ctx context.Context, symbolStore trace.SymbolStore) error
- func (idx *RPGEncoder) RefreshDerivedEdgesIncremental(ctx context.Context, symbolStore trace.SymbolStore, changedFiles []string) error
- func (idx *RPGEncoder) Stats() GraphStats
- type RPGEncoderConfig
- type RPGStore
- type SearchNodeRequest
- type SearchNodeResult
- type Summarizer
Constants ¶
const CurrentRPGIndexVersion = 2
Variables ¶
var ErrRPGIndexOutdated = errors.New("rpg index outdated")
Functions ¶
func CalculateSemanticSimilarity ¶ added in v0.35.0
CalculateSemanticSimilarity computes a heuristic similarity score between two nodes based on their feature labels. It uses a token-based Jaccard similarity.
func MakeNodeID ¶
MakeNodeID creates a deterministic node ID. For symbols: "sym:<path>:<receiver>.<name>" or "sym:<path>:<name>" For files: "file:<path>" For hierarchy: "area:<name>", "cat:<parent>/<name>", "subcat:<parent>/<name>" For chunks: "chunk:<chunkID>"
TODO: consider adding ParseNodeID to avoid prefix-stripping in callers
Types ¶
type Edge ¶
type Edge struct {
From string `json:"from"` // source node ID
To string `json:"to"` // target node ID
Type EdgeType `json:"type"` // relationship type
Weight float64 `json:"weight,omitempty"` // edge weight/confidence
UpdatedAt time.Time `json:"updated_at"`
}
Edge represents a directed edge in the RPG graph.
type EdgeType ¶
type EdgeType string
EdgeType represents the type of relationship between nodes. EdgeType defines the relationship between nodes. In paper terms: - E_feature (Functional): EdgeFeatureParent, EdgeContains - E_dep (Dependency): EdgeInvokes, EdgeImports, EdgeSemanticSim
const ( EdgeFeatureParent EdgeType = "feature_parent" // parent -> child in feature hierarchy [E_feature] EdgeContains EdgeType = "contains" // container -> contained implementation (file -> symbol) [E_feature] EdgeInvokes EdgeType = "invokes" // symbol calls symbol [E_dep] EdgeImports EdgeType = "imports" // file imports file/package [E_dep] EdgeMapsToChunk EdgeType = "maps_to_chunk" // symbol maps to vector chunk [Implementation] EdgeSemanticSim EdgeType = "semantic_sim" // symbols with similar features/co-call patterns [Implementation] )
type Evolver ¶
type Evolver struct {
// contains filtered or unexported fields
}
Evolver handles incremental updates to the RPG graph. Implements "RPG Evolution: Incremental Maintenance" from arXiv:2602.02084.
func NewEvolver ¶
func NewEvolver(graph *Graph, extractor FeatureExtractor, hierarchy *HierarchyBuilder, driftThreshold float64) *Evolver
NewEvolver creates an Evolver with the given drift threshold. driftThreshold controls when a file is considered to have changed semantically (0.0 = never, 1.0 = always). A typical value is 0.3.
func (*Evolver) HandleDelete ¶
HandleDelete removes all nodes associated with a file and prunes orphaned hierarchy nodes.
func (*Evolver) HandleModify ¶
HandleModify re-extracts semantic features for all symbols in the changed file, updates file-level semantics, and reroutes file hierarchy placement when drift crosses the configured threshold.
type ExploreRequest ¶
type ExploreRequest struct {
StartNodeID string `json:"start_node_id,omitempty"`
StartCodeEntities []string `json:"start_code_entities,omitempty"`
StartFeatureEntities []string `json:"start_feature_entities,omitempty"`
Direction string `json:"direction"` // forward, reverse, both
Depth int `json:"depth,omitempty"` // max depth (default: 2)
TraversalDepth int `json:"traversal_depth,omitempty"` // alias for depth
EdgeTypes []EdgeType `json:"edge_types,omitempty"` // filter by edge type
EntityTypeFilter string `json:"entity_type_filter,omitempty"` // directory | file | class | function | method
Limit int `json:"limit,omitempty"` // max nodes returned
}
ExploreRequest is the input for Explore.
type ExploreResult ¶
type ExploreResult struct {
StartNode *Node `json:"start_node"`
Nodes map[string]*Node `json:"nodes"`
Edges []*Edge `json:"edges"`
Depth int `json:"depth"`
}
ExploreResult contains the explored subgraph.
type FeatureExtractor ¶
type FeatureExtractor interface {
// ExtractFeature generates a feature label for a symbol.
// Returns a verb-object string like "handle-request", "validate-token", "parse-config".
ExtractFeature(ctx context.Context, symbolName, signature, receiver, comment string) string
// ExtractAtomicFeatures generates one or more atomic semantic features.
// Returns normalized verb-object phrases like "handle request".
ExtractAtomicFeatures(ctx context.Context, symbolName, signature, receiver, comment string) []string
// GenerateSummary generates a high-level summary for a node.
// Returns the summary string or error.
GenerateSummary(ctx context.Context, name, contextStr string) (string, error)
// Mode returns the extractor mode name.
Mode() string
}
FeatureExtractor extracts semantic feature labels from code symbols.
type FetchNodeRequest ¶
type FetchNodeRequest struct {
NodeID string `json:"node_id,omitempty"`
CodeEntities []string `json:"code_entities,omitempty"`
FeatureEntities []string `json:"feature_entities,omitempty"`
}
FetchNodeRequest is the input for FetchNode.
type FetchNodeResult ¶
type FetchNodeResult struct {
Node *Node `json:"node"`
FeaturePath string `json:"feature_path"`
Parents []*Node `json:"parents,omitempty"` // hierarchy chain
Children []*Node `json:"children,omitempty"` // contained nodes
Incoming []*Edge `json:"incoming,omitempty"` // incoming edges
Outgoing []*Edge `json:"outgoing,omitempty"` // outgoing edges
CodePreview string `json:"code_preview,omitempty"` // source snippet when available
}
FetchNodeResult contains detailed node info with context.
type GOBRPGStore ¶
type GOBRPGStore struct {
// contains filtered or unexported fields
}
GOBRPGStore implements RPGStore using GOB encoding.
func NewGOBRPGStore ¶
func NewGOBRPGStore(indexPath string) *GOBRPGStore
NewGOBRPGStore creates a new GOB-based RPG store.
func (*GOBRPGStore) Close ¶
func (s *GOBRPGStore) Close() error
Close cleanly shuts down the store by persisting data.
func (*GOBRPGStore) GetGraph ¶
func (s *GOBRPGStore) GetGraph() *Graph
GetGraph returns the in-memory graph.
func (*GOBRPGStore) GetStats ¶
func (s *GOBRPGStore) GetStats(ctx context.Context) (*GraphStats, error)
GetStats returns graph statistics.
type Graph ¶
type Graph struct {
Nodes map[string]*Node `json:"nodes"`
Edges []*Edge `json:"edges"`
// contains filtered or unexported fields
}
Graph is the in-memory RPG graph with fast lookup indexes.
func (*Graph) AddNode ¶
AddNode adds or updates a node and maintains indexes. If a node with the same ID already exists, old index entries are removed first to prevent stale reference accumulation.
TODO: consider map[string]int index for O(1) stale-entry removal during bulk operations
func (*Graph) GetIncoming ¶
GetIncoming returns all incoming edges to a node.
func (*Graph) GetNeighbors ¶
GetNeighbors returns neighbor node IDs in a given direction ("forward", "reverse", "both").
func (*Graph) GetNodesByFile ¶
GetNodesByFile returns all nodes for a given file path.
func (*Graph) GetNodesByKind ¶
GetNodesByKind returns all nodes of a given kind.
func (*Graph) GetOutgoing ¶
GetOutgoing returns all outgoing edges from a node.
func (*Graph) RebuildIndexes ¶
func (g *Graph) RebuildIndexes()
RebuildIndexes rebuilds all in-memory indexes from Nodes and Edges. Called after deserialization.
func (*Graph) RemoveEdgesBetween ¶
RemoveEdgesBetween removes all edges between two nodes.
func (*Graph) RemoveEdgesBetweenOfType ¶ added in v0.35.0
RemoveEdgesBetweenOfType removes edges of a specific type between two nodes.
func (*Graph) RemoveEdgesIf ¶
RemoveEdgesIf removes edges that match the predicate and rebuilds edge indexes.
func (*Graph) RemoveNode ¶
RemoveNode removes a node and all its edges, updating indexes.
type GraphStats ¶
type GraphStats struct {
TotalNodes int `json:"total_nodes"`
TotalEdges int `json:"total_edges"`
NodesByKind map[NodeKind]int `json:"nodes_by_kind"`
EdgesByType map[EdgeType]int `json:"edges_by_type"`
LastUpdated time.Time `json:"last_updated"`
}
GraphStats holds graph statistics.
type HierarchyBuilder ¶
type HierarchyBuilder struct {
// contains filtered or unexported fields
}
HierarchyBuilder constructs the area/category/subcategory hierarchy for RPG nodes.
func NewHierarchyBuilder ¶
func NewHierarchyBuilder(graph *Graph, extractor FeatureExtractor) *HierarchyBuilder
NewHierarchyBuilder creates a new hierarchy builder for the given graph and feature extractor.
func (*HierarchyBuilder) BuildHierarchy ¶
func (h *HierarchyBuilder) BuildHierarchy()
BuildHierarchy constructs hierarchy nodes and edges for the entire graph. It examines all KindFile and KindSymbol nodes and organizes them into area/category/subcategory based on directory structure and feature labels.
NOTE: This implements a heuristic approximation of the RPG-Encoder "Structure Reorganization" (Phase 2). While the paper describes an LLM-driven clustering approach to induce functional centroids, this implementation utilizes the explicit directory structure as a proxy for high-level functional areas ($V_H$), combined with symbol-level verb extraction for finer granularity. This trade-off significantly reduces indexing cost while maintaining structural coherence.
Strategy:
- Group files by top-level directory -> these become "areas"
- Within each area, group by subdirectory or file stem -> "categories"
- Within each category, group symbols by feature verb -> "subcategories"
- Connect hierarchy as area -> category -> subcategory -> file via EdgeFeatureParent
- Keep implementation containment as file -> symbol via EdgeContains
func (*HierarchyBuilder) ClassifyFile ¶
func (h *HierarchyBuilder) ClassifyFile(filePath string) (string, string)
ClassifyFile determines the area and category for a file based on its path. It uses directory structure:
"cli/watch.go" -> area="cli", category="watch" "store/gob.go" -> area="store", category="gob" "indexer/chunker.go" -> area="indexer", category="chunker" "main.go" -> area="root", category="main" "internal/foo/bar.go" -> area="internal", category="foo" "a/b/c/deep.go" -> area="a", category="b"
Returns (areaName, categoryName).
func (*HierarchyBuilder) ClassifySymbol ¶
func (h *HierarchyBuilder) ClassifySymbol(feature string) string
ClassifySymbol determines the subcategory for a symbol based on its feature label. It uses the first word (verb) of the feature as the subcategory grouping.
"handle-request" -> "handle" "validate-token" -> "validate" "parse-config" -> "parse" "operate-server" -> "operate" "unknown" -> "general" "" -> "general"
func (*HierarchyBuilder) ClusterSymbols ¶ added in v0.35.0
func (h *HierarchyBuilder) ClusterSymbols(symbols []*Node) map[string][]*Node
ClusterSymbols groups symbols based on their feature labels. It uses a heuristic to determine the best clustering strategy (e.g. by verb, or by object if verb is generic).
func (*HierarchyBuilder) EnrichLabels ¶
func (h *HierarchyBuilder) EnrichLabels()
EnrichLabels enriches area and category nodes with semantic summaries derived from their descendant symbol features. This adds semantic depth to directory-based hierarchy labels by populating the SemanticLabel field.
Example: area "cli" with descendants [handle-search, handle-trace, run-watch] becomes "cli [handle, run]" providing semantic context about what the area does.
func (*HierarchyBuilder) EnsureArea ¶
func (h *HierarchyBuilder) EnsureArea(name string) string
EnsureArea ensures an area node exists and returns its ID. If the node already exists, it is not recreated.
func (*HierarchyBuilder) EnsureCategory ¶
func (h *HierarchyBuilder) EnsureCategory(areaID, name string) string
EnsureCategory ensures a category node exists under an area and returns its ID. The areaID is used to extract the area name for building the category's node ID and feature path. A EdgeFeatureParent edge from area to category is created if the category is new.
func (*HierarchyBuilder) EnsureSubcategory ¶
func (h *HierarchyBuilder) EnsureSubcategory(catID, name string) string
EnsureSubcategory ensures a subcategory node exists under a category and returns its ID. The catID is used to extract the category feature path for building the subcategory's node ID and feature path. A EdgeFeatureParent edge from category to subcategory is created if the subcategory is new.
type LLMExtractor ¶
type LLMExtractor struct {
// contains filtered or unexported fields
}
LLMExtractor generates feature labels using an LLM API. Falls back to LocalExtractor on error.
func NewLLMExtractor ¶
func NewLLMExtractor(cfg LLMExtractorConfig) *LLMExtractor
NewLLMExtractor creates an LLM-based feature extractor with local fallback.
func (*LLMExtractor) ExtractAtomicFeatures ¶ added in v0.35.0
func (e *LLMExtractor) ExtractAtomicFeatures(ctx context.Context, symbolName, signature, receiver, comment string) []string
ExtractAtomicFeatures calls the LLM to generate atomic semantic features. Falls back to local extraction on any error.
func (*LLMExtractor) ExtractFeature ¶
func (e *LLMExtractor) ExtractFeature(ctx context.Context, symbolName, signature, receiver, comment string) string
ExtractFeature calls the LLM to generate a semantic feature label. Falls back to local extraction on any error.
func (*LLMExtractor) GenerateSummary ¶ added in v0.35.0
func (e *LLMExtractor) GenerateSummary(ctx context.Context, name, contextStr string) (string, error)
GenerateSummary calls the LLM to generate a high-level summary.
func (*LLMExtractor) Mode ¶
func (e *LLMExtractor) Mode() string
type LLMExtractorConfig ¶
type LLMExtractorConfig struct {
Provider string // "openai" compatible
Model string
Endpoint string
APIKey string
Timeout time.Duration
}
LLMExtractorConfig configures the LLM feature extractor.
type LocalExtractor ¶
type LocalExtractor struct{}
LocalExtractor generates feature labels using heuristic rules. It splits camelCase/PascalCase/snake_case names into verb-object patterns.
func NewLocalExtractor ¶
func NewLocalExtractor() *LocalExtractor
NewLocalExtractor creates a new local heuristic feature extractor.
func (*LocalExtractor) ExtractAtomicFeatures ¶ added in v0.35.0
func (e *LocalExtractor) ExtractAtomicFeatures(_ context.Context, symbolName, signature, receiver, comment string) []string
ExtractAtomicFeatures generates normalized atomic semantic features.
func (*LocalExtractor) ExtractFeature ¶
func (e *LocalExtractor) ExtractFeature(_ context.Context, symbolName, signature, receiver, comment string) string
ExtractFeature generates a feature label for a symbol using heuristic rules. It splits the symbol name into words, identifies a verb-object pattern, and returns a lowercase kebab-case string like "handle-request".
func (*LocalExtractor) GenerateSummary ¶ added in v0.35.0
func (e *LocalExtractor) GenerateSummary(_ context.Context, name, contextStr string) (string, error)
GenerateSummary builds a deterministic local summary from child feature hints.
func (*LocalExtractor) Mode ¶
func (e *LocalExtractor) Mode() string
Mode returns the extractor mode name.
type Node ¶
type Node struct {
ID string `json:"id"`
Kind NodeKind `json:"kind"`
Feature string `json:"feature"` // primary semantic feature label (kebab-case)
Features []string `json:"features,omitempty"` // atomic semantic features (verb-object phrases)
Path string `json:"path,omitempty"` // file path (for file/symbol/chunk nodes)
SymbolName string `json:"symbol_name,omitempty"` // symbol name (for symbol nodes)
Receiver string `json:"receiver,omitempty"` // Go receiver type
Language string `json:"language,omitempty"` // programming language
StartLine int `json:"start_line,omitempty"`
EndLine int `json:"end_line,omitempty"`
Signature string `json:"signature,omitempty"` // function signature
ChunkID string `json:"chunk_id,omitempty"` // linked vector chunk ID
SemanticLabel string `json:"semantic_label,omitempty"` // enriched label with semantic context
Summary string `json:"summary,omitempty"` // high-level semantic summary (LLM generated)
UpdatedAt time.Time `json:"updated_at"`
}
Node represents a node in the RPG graph.
type NodeKind ¶
type NodeKind string
NodeKind represents the type of node in the RPG graph. NodeKind distinguishes between implementation nodes and hierarchy nodes. In paper terms: - V_L (Low-level): File, Symbol, Chunk - V_H (High-level): Area, Category, Subcategory
const ( KindArea NodeKind = "area" // functional area (top level) [V_H] KindCategory NodeKind = "category" // category within an area [V_H] KindSubcategory NodeKind = "subcategory" // subcategory within a category [V_H] KindFile NodeKind = "file" // source file [V_L] KindSymbol NodeKind = "symbol" // function/method/class/type [V_L] KindChunk NodeKind = "chunk" // vector chunk reference [V_L] )
type ProgressObserver ¶ added in v0.34.0
ProgressObserver is a callback for reporting indexing progress.
type QueryEngine ¶
type QueryEngine struct {
// contains filtered or unexported fields
}
QueryEngine provides the 3 RPG query operations.
func NewQueryEngine ¶
func NewQueryEngine(graph *Graph) *QueryEngine
NewQueryEngine creates a QueryEngine backed by the given graph.
func (*QueryEngine) Explore ¶
func (qe *QueryEngine) Explore(_ context.Context, req ExploreRequest) (*ExploreResult, error)
Explore traverses the graph from a start node using BFS.
func (*QueryEngine) FetchNode ¶
func (qe *QueryEngine) FetchNode(_ context.Context, req FetchNodeRequest) (*FetchNodeResult, error)
FetchNode retrieves detailed information about a specific node.
func (*QueryEngine) FetchNodes ¶ added in v0.35.0
func (qe *QueryEngine) FetchNodes(ctx context.Context, req FetchNodeRequest) ([]*FetchNodeResult, error)
FetchNodes retrieves details for one or more entities. Resolution order:
- req.NodeID
- req.CodeEntities (node IDs, file paths, or symbol names)
- req.FeatureEntities (feature paths)
func (*QueryEngine) SearchNode ¶
func (qe *QueryEngine) SearchNode(_ context.Context, req SearchNodeRequest) ([]SearchNodeResult, error)
SearchNode finds nodes matching a query within optional scope. Scoring uses Jaccard similarity between query words and the union of a node's Feature label words and SymbolName words.
type RPGEncoder ¶ added in v0.35.0
type RPGEncoder struct {
// contains filtered or unexported fields
}
RPGEncoder orchestrates building and maintaining the RPG graph. It connects the trace symbol store, vector store, and RPG graph. Formerly RPGIndexer.
func NewRPGEncoder ¶ added in v0.35.0
func NewRPGEncoder(rpgStore RPGStore, extractor FeatureExtractor, projectRoot string, cfg RPGEncoderConfig) *RPGEncoder
NewRPGEncoder creates a new RPG encoder instance.
func (*RPGEncoder) BuildFull ¶ added in v0.35.0
func (idx *RPGEncoder) BuildFull(ctx context.Context, symbolStore trace.SymbolStore, vectorStore store.VectorStore, observer ProgressObserver) error
BuildFull performs a complete rebuild of the RPG graph from scratch.
func (*RPGEncoder) GetEvolver ¶ added in v0.35.0
func (idx *RPGEncoder) GetEvolver() *Evolver
GetEvolver returns the evolver for direct use.
func (*RPGEncoder) GetGraph ¶ added in v0.35.0
func (idx *RPGEncoder) GetGraph() *Graph
GetGraph returns the underlying graph pointer. The pointer is NOT concurrency-safe on its own. Use RPGEncoder.Stats() for safe concurrent stats access. Direct graph access is safe when each caller owns a separate store instance (e.g., MCP per-request pattern).
func (*RPGEncoder) HandleFileEvent ¶ added in v0.35.0
func (idx *RPGEncoder) HandleFileEvent(ctx context.Context, eventType string, filePath string, symbols []trace.Symbol) error
HandleFileEvent handles incremental updates for file events. The caller is responsible for persisting the store after updates.
func (*RPGEncoder) LinkChunksForFile ¶ added in v0.35.0
func (idx *RPGEncoder) LinkChunksForFile(ctx context.Context, filePath string, chunks []store.Chunk) error
LinkChunksForFile links vector chunks to overlapping symbols in the graph. The caller is responsible for persisting the store after updates.
func (*RPGEncoder) RefreshDerivedEdgesFull ¶ added in v0.35.0
func (idx *RPGEncoder) RefreshDerivedEdgesFull(ctx context.Context, symbolStore trace.SymbolStore) error
RefreshDerivedEdgesFull rebuilds all derived edges from current graph nodes.
func (*RPGEncoder) RefreshDerivedEdgesIncremental ¶ added in v0.35.0
func (idx *RPGEncoder) RefreshDerivedEdgesIncremental(ctx context.Context, symbolStore trace.SymbolStore, changedFiles []string) error
RefreshDerivedEdgesIncremental updates derived edges for changed files.
func (*RPGEncoder) Stats ¶ added in v0.35.0
func (idx *RPGEncoder) Stats() GraphStats
Stats returns graph statistics in a concurrency-safe manner.
type RPGEncoderConfig ¶ added in v0.35.0
type RPGEncoderConfig struct {
DriftThreshold float64
MaxTraversalDepth int
FeatureGroupStrategy string
Seed int64 // RNG seed for reproducible builds (0 = use current time)
}
RPGEncoderConfig configures the RPG encoder behavior.
type RPGStore ¶
type RPGStore interface {
// Load reads the graph from persistent storage.
Load(ctx context.Context) error
// Persist writes the graph to persistent storage.
Persist(ctx context.Context) error
// Close cleanly shuts down the store.
Close() error
// GetGraph returns the in-memory graph.
GetGraph() *Graph
// GetStats returns graph statistics.
GetStats(ctx context.Context) (*GraphStats, error)
}
RPGStore persists and loads the RPG graph.
type SearchNodeRequest ¶
type SearchNodeRequest struct {
Query string `json:"query"` // natural language or feature query (legacy)
Scope string `json:"scope,omitempty"` // area/category path to narrow search (legacy)
Kinds []NodeKind `json:"kinds,omitempty"` // filter by node kind (default: symbol)
Limit int `json:"limit,omitempty"` // max results (default: 10)
Mode string `json:"mode,omitempty"` // features | snippets | auto
FeatureTerms []string `json:"feature_terms,omitempty"` // behavior/functionality phrases
SearchScopes []string `json:"search_scopes,omitempty"` // optional scope filters
SearchTerms []string `json:"search_terms,omitempty"` // snippet-oriented query terms
LineNums []int `json:"line_nums,omitempty"` // reserved for parity (not used in graph search)
FilePathOrPattern string `json:"file_path_or_pattern,omitempty"` // optional file path/glob filter
}
SearchNodeRequest is the input for SearchNode.
type SearchNodeResult ¶
type SearchNodeResult struct {
Node *Node `json:"node"`
Score float64 `json:"score"`
FeaturePath string `json:"feature_path"` // area/category/subcategory path
}
SearchNodeResult is a single search result.
type Summarizer ¶ added in v0.35.0
type Summarizer struct {
// contains filtered or unexported fields
}
Summarizer handles the generation of semantic summaries for the hierarchy.
func NewSummarizer ¶ added in v0.35.0
func NewSummarizer(graph *Graph, extractor FeatureExtractor) *Summarizer
NewSummarizer creates a new Summarizer.
func (*Summarizer) SummarizeHierarchy ¶ added in v0.35.0
func (s *Summarizer) SummarizeHierarchy(ctx context.Context, force bool) error
SummarizeHierarchy traverses the hierarchy bottom-up and generates summaries. It skips nodes that already have a summary unless force is true.