Documentation
¶
Overview ¶
Package source builds a repository graph and discovers MCP registrations. Build walks, parses, resolves symbols, and finds MCP registrations. It is the independent entry point for every graph-consuming analyzer, so none depends on analyzer execution order.
Index ¶
- Constants
- func Build(ctx context.Context, root string) (*graph.Graph, model.Coverage, error)
- func FoldWalkCoverage(a *analyzer.Artifacts, cov model.Coverage) model.Coverage
- func LoadGraph(ctx context.Context, ac *analyzer.AnalysisContext, root string) (g *graph.Graph, cov model.Coverage, walkCoverageMissing bool, err error)
- func Publish(a *analyzer.Artifacts, g *graph.Graph, cov model.Coverage)
- func ResolveRoot(targetPath, acRoot string) (string, error)
- func Synthesize(g *graph.Graph) (*model.Snapshot, model.Coverage)
- func UnresolvedDescriptions(g *graph.Graph) map[string]bool
- type Analyzer
Constants ¶
const ArtifactKey = "source.graph"
ArtifactKey is where the built graph is published on ac.Artifacts
const SynthesizeCoverageKey = "source.synthesize_coverage"
SynthesizeCoverageKey lets snapshot consumers include unresolved source declarations in their coverage. The caller publishes the value.
const WalkCoverageKey = "source.walk_coverage"
WalkCoverageKey stores coverage from the walk that produced ArtifactKey. Consumers that reuse the graph must also reuse its blind spots instead of claiming a fresh, complete walk.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build walks root, parses every file discovered, resolves the call graph and discovers MCP registrations. It always returns a graph, even an empty one, because the caller still needs the coverage counters to report a gap honestly rather than silently.
func FoldWalkCoverage ¶
FoldWalkCoverage merges file counters, skips, and limits into a graph consumer's coverage without overwriting analyzer-specific symbol or capability counts. Missing shared coverage leaves cov unchanged, which lets callers report that absence according to the target type rather than fabricating counters.
func LoadGraph ¶
func LoadGraph(ctx context.Context, ac *analyzer.AnalysisContext, root string) (g *graph.Graph, cov model.Coverage, walkCoverageMissing bool, err error)
LoadGraph reuses a published graph or builds one independently. A reused graph without walk coverage is accepted but reported as PARTIAL, so missing metadata cannot resemble an empty tree.
func Publish ¶
Publish shares a built graph and the coverage of the walk that produced it.
The two go together: a consumer that reuses the graph has to reuse its blind spots too, or it reports a complete walk it never performed. Coverage is stored first on purpose. Artifacts is mutex-guarded, so a consumer that sees the graph is guaranteed to see the coverage stored before it - publishing them the other way round leaves a window where the graph looks like the product of a walk that found nothing.
func ResolveRoot ¶
ResolveRoot picks the scan root, preferring ac.Root over target.Path: a caller that set Root has already fixed the filesystem boundary, so target.Path cannot override it. If Root is unset, target.Path is used as-is. When both are present, symlinks are resolved and target.Path must remain beneath the established root.
func Synthesize ¶
Synthesize builds a Snapshot from discovered capabilities so analyzers that read declared text can run against a source tree. The returned coverage records unresolved names or descriptions as reasoned skips; prompt defense later converts unresolved fields into an analyzed-count gap.
Types ¶
type Analyzer ¶
type Analyzer struct{}
Analyzer walks a source tree, builds the symbol/call graph and discovers MCP registrations. Its own findings are limited to what the discovery pass itself can say about a capability's declared metadata; dataflow and behavioral comparison are separate analyzers that consume the same graph.
func (*Analyzer) Analyze ¶
func (*Analyzer) Analyze(ctx context.Context, target model.Target, ac *analyzer.AnalysisContext) model.AnalyzerResult
func (*Analyzer) Describe ¶
func (*Analyzer) Describe() analyzer.Description
Directories
¶
| Path | Synopsis |
|---|---|
|
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it
|
Package graph is the exported source-code model shared between the discovery pass and every analyzer that reasons about dataflow: symbols, imports, the call graph and the MCP capabilities found in it |
|
Package inventory walks regular source files within a hard root boundary and records reported skips.
|
Package inventory walks regular source files within a hard root boundary and records reported skips. |
|
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal)
|
Package language adapts each supported source language to a common shape: its file extensions, its tree-sitter grammar, and the small set of node kinds the parser and taint walker need to recognize (a function, a call, an assignment, a string literal) |
|
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries.
|
Package parser turns one source file into symbols, imports and calls using the language's tree-sitter grammar and queries. |
|
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime
|
Package queries embeds the tree-sitter query files for every supported language, so parsing never depends on a query file being present on disk at runtime |
|
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source.
|
Package registration finds where MCP tools, prompts and resources are registered, across direct SDK calls, decorators/annotations/attributes, a wrapper function that forwards into the SDK, and registration inside a loop - working entirely off the graph the parser already built, so it never re-reads source. |