Documentation
¶
Index ¶
- Variables
- func BuildEdges(symbols []core.SymbolRecord) []core.Edge
- func DetectConflicts(a, b core.IsolatedChangeRegion) core.ConflictResult
- func DiffSymbols(before, after []core.SymbolRecord) core.GraphDiff
- type CodeGraph
- func (g *CodeGraph) ComputeICR(intent string) core.IsolatedChangeRegion
- func (g *CodeGraph) Deps(filePath string) []core.Edge
- func (g *CodeGraph) FileSymbols(filePath string) []core.SymbolRecord
- func (g *CodeGraph) Impact(query string, maxDepth int) []core.SymbolRecord
- func (g *CodeGraph) ImpactWithPolicy(query string, maxDepth int, policy TraversalPolicy) []core.SymbolRecord
- func (g *CodeGraph) Neighbors(query, direction string, kinds map[core.EdgeType]bool) []Neighbor
- func (g *CodeGraph) Replace(symbols []core.SymbolRecord, filesIndexed int)
- func (g *CodeGraph) ReplaceWithEdges(symbols []core.SymbolRecord, extraEdges []core.Edge, filesIndexed int)
- func (g *CodeGraph) ReplaceWithStoredEdges(symbols []core.SymbolRecord, edges []core.Edge, filesIndexed int)
- func (g *CodeGraph) Search(query string, limit int) []core.SymbolRecord
- func (g *CodeGraph) SemanticSearch(query string, limit int) []embeddings.Scored
- func (g *CodeGraph) Snapshot() ([]core.SymbolRecord, []core.Edge)
- func (g *CodeGraph) Status() core.Status
- func (g *CodeGraph) TestsFor(query string) []core.SymbolRecord
- func (g *CodeGraph) TestsForSymbol(id string, policy TraversalPolicy) []core.SymbolRecord
- func (g *CodeGraph) TestsForWithStats(query string) ([]core.SymbolRecord, PolicySkips)
- type Neighbor
- type PolicySkips
- type TraversalPolicy
Constants ¶
This section is empty.
Variables ¶
var ( // PolicyDiagnostic walks every edge — debugging / full blast radius. PolicyDiagnostic = TraversalPolicy{Name: "diagnostic"} // PolicyTests: evidence-backed edges only. The 0.7 floor drops type-use // (0.5) and ambiguous name-matched calls (0.6); the reason exclusion drops // the regex body-scan fallback even at same-file confidence (0.85). PolicyTests = TraversalPolicy{Name: "tests", MinConfidence: minTestTraversalConfidence, ExcludeReason: map[core.EdgeReason]bool{core.ReasonRegexFallbck: true}} // PolicyImpact: blast radius keeps dynamic dispatch (real edges) but drops // the regex fallback and the weakest type-use guesses (0.5). PolicyImpact = TraversalPolicy{Name: "impact", MinConfidence: 0.6, ExcludeReason: map[core.EdgeReason]bool{core.ReasonRegexFallbck: true}} // PolicyCertification backs guarantees: only AST-exact / structural / // native edges (≥0.9). The 0.9 floor already drops heuristic dispatch // (0.7) and constructor/inheritance guesses (0.85); the reason exclusions // state the intent. PolicyCertification = TraversalPolicy{Name: "certification", MinConfidence: 0.9, ExcludeReason: map[core.EdgeReason]bool{ core.ReasonDispatch: true, core.ReasonRegexFallbck: true, core.ReasonInheritance: true, core.ReasonConstructor: true, }} )
Functions ¶
func BuildEdges ¶
func BuildEdges(symbols []core.SymbolRecord) []core.Edge
BuildEdges constructs all 8 edge types from the symbol set.
Edge construction order (matches Implementation Plan §3.1):
- defines (file → symbol) confidence 1.0
- contains (parent → child) confidence 1.0
- imports (file → import:path) confidence 0.9
- extends (subtype → supertype) confidence 0.85
- implements (concrete → interface/trait) confidence 0.85
- uses-type (symbol → referenced type) confidence 0.5
- calls (caller → callee) confidence 0.85 same-file, 0.6 cross-file
- tests (test sym → tested sym) confidence 0.8
"calls" and "uses-type" are scoped to same-file + imported-file symbols per the non-negotiable accuracy rule in the plan.
func DetectConflicts ¶
func DetectConflicts(a, b core.IsolatedChangeRegion) core.ConflictResult
DetectConflicts checks whether two ICRs have overlapping exclusive symbols or files.
func DiffSymbols ¶ added in v0.6.0
func DiffSymbols(before, after []core.SymbolRecord) core.GraphDiff
DiffSymbols computes the structural delta between two symbol snapshots (typically: the graph before and after a merge or reindex).
Symbols are matched by stable identity — file path + qualified name + kind — not by symbol ID: IDs embed the file content SHA, so any edit changes every ID in the file and an ID-based diff would report whole-file churn for a one-line change. A symbol whose span moved but whose signature and body are unchanged is not reported at all; that is what makes the diff usable as a drift signal ("the ground shifted under you") rather than a line-number echo.
Same-key collisions (e.g. C++ overloads sharing a qualified name) are paired positionally in document order; surplus entries on either side surface as added/removed.
Types ¶
type CodeGraph ¶
type CodeGraph struct {
// contains filtered or unexported fields
}
func (*CodeGraph) ComputeICR ¶
func (g *CodeGraph) ComputeICR(intent string) core.IsolatedChangeRegion
ComputeICR computes an Isolated Change Region for the given intent string. When no symbol matches the intent, the region is empty with floor confidence and no lock keys: an arbitrary fallback region (the previous behaviour seeded from the first 20 symbols alphabetically) would make two unrelated no-match intents lock and conflict on the same random files.
func (*CodeGraph) Deps ¶
Deps returns all edges that touch the given file path. Uses exact-prefix matching: edges from "file:<path>" or whose node ID begins with "<path>::" (symbol IDs in that file).
func (*CodeGraph) FileSymbols ¶ added in v0.6.1
func (g *CodeGraph) FileSymbols(filePath string) []core.SymbolRecord
FileSymbols returns deep copies of the symbols defined in filePath (slash-separated, repo-relative), ordered by span. Cheap relative to Snapshot: only the one file's symbols are copied.
func (*CodeGraph) Impact ¶
func (g *CodeGraph) Impact(query string, maxDepth int) []core.SymbolRecord
Impact returns all symbols reachable from the seed (identified by query) by traversing inbound edges up to maxDepth. "Inbound" means: things that call, test, or contain the seed symbol — i.e., the blast radius if the seed changes.
func (*CodeGraph) ImpactWithPolicy ¶ added in v0.11.0
func (g *CodeGraph) ImpactWithPolicy(query string, maxDepth int, policy TraversalPolicy) []core.SymbolRecord
ImpactWithPolicy is Impact with an explicit traversal policy — e.g. PolicyCertification for a blast radius that only follows guarantee-grade edges.
func (*CodeGraph) Neighbors ¶ added in v0.13.0
Neighbors returns the seed symbol's direct typed neighbors — one graph hop, edge types preserved (unlike Impact, which flattens the blast radius). This is what lets a caller ask precisely for "what does X call" (direction "out", kind calls), "who calls X" (direction "in", kind calls), or "what tests X" (direction "in", kind tests) instead of a relevance-ranked blob.
direction is "out", "in", or "both"/"". kinds filters by edge type; an empty set returns every kind. Seeds are matched by exact name / qualified name / ID.
func (*CodeGraph) Replace ¶
func (g *CodeGraph) Replace(symbols []core.SymbolRecord, filesIndexed int)
func (*CodeGraph) ReplaceWithEdges ¶ added in v0.5.0
func (*CodeGraph) ReplaceWithStoredEdges ¶ added in v0.6.0
func (g *CodeGraph) ReplaceWithStoredEdges(symbols []core.SymbolRecord, edges []core.Edge, filesIndexed int)
ReplaceWithStoredEdges installs a previously-computed edge set verbatim — the edges persisted by the last index are already the merged (baseline + native) set, so rehydration must not pay the BuildEdges cost again. Databases written before edges were persisted (symbols but no edges) fall back to a full rebuild.
func (*CodeGraph) Search ¶
func (g *CodeGraph) Search(query string, limit int) []core.SymbolRecord
Search returns symbols matching the query (case-insensitive), ranked by match quality: exact name > exact qualified name > name prefix > name substring > qualified-name substring > path/signature substring. Ranking matters because results are truncated at limit — with the previous alphabetical-by-path ordering, the exact-name match for a common query could be cut off by substring hits in files that happened to sort earlier.
func (*CodeGraph) SemanticSearch ¶
func (g *CodeGraph) SemanticSearch(query string, limit int) []embeddings.Scored
SemanticSearch ranks symbols against a free-text intent using the configured embedding backend (Model2Vec by default; TF-IDF if GROVE_EMBEDDINGS=tfidf). Documents are constructed from (name + qualifiedName + signature + docstring + parent). The engine is built lazily and cached until the next Replace().
func (*CodeGraph) TestsForSymbol ¶ added in v0.12.0
func (g *CodeGraph) TestsForSymbol(id string, policy TraversalPolicy) []core.SymbolRecord
TestsForSymbol returns the covering tests for one symbol ID under the given policy — the ID-seeded form of TestsFor, used to benchmark the closure (and to compare policies) without the name-matching phase.
func (*CodeGraph) TestsForWithStats ¶ added in v0.11.0
func (g *CodeGraph) TestsForWithStats(query string) ([]core.SymbolRecord, PolicySkips)
TestsForWithStats is TestsFor plus the per-reason counts of edges the policy excluded from the closure — the evidence Grove chose not to trust, for certification-style "included vs excluded" reporting.
type Neighbor ¶ added in v0.13.0
type Neighbor struct {
Symbol core.SymbolRecord
EdgeType core.EdgeType
Direction string // "out" = seed→symbol (callee, uses-type); "in" = symbol→seed (caller, test)
Confidence float64
}
Neighbor is a symbol reached from a seed by exactly one typed edge.
type PolicySkips ¶ added in v0.11.0
type PolicySkips map[core.EdgeReason]int
PolicySkips counts, per resolver reason, the edges a policy excluded during a traversal — so consumers (certification) can cite the evidence they did not trust.
type TraversalPolicy ¶ added in v0.11.0
type TraversalPolicy struct {
Name string
MinConfidence float64
ExcludeReason map[core.EdgeReason]bool
}
TraversalPolicy decides which edges a consumer closure may walk, by confidence floor and resolver reason. Profiles let tests / impact / certification / diagnostic consumers opt into different strictness instead of one hard-coded threshold, and make the choice explainable (every excluded edge has a reason). See roadmap Wave 4 / Sweep #4.