Documentation
¶
Overview ¶
Package capability holds GraphLume's query-layer capabilities: the questions an agent actually asks of an indexed repository.
ImpactMind ("what breaks if I change this?") and TestMind ("which tests cover this?") live in subpackages here. They are QUERY LAYERS OVER THE SHARED GRAPH, not separate products — neither parses, neither writes, and neither owns a schema. Everything they know comes from registry and graph, which is what keeps a single index answering both.
Why this package exists at all ¶
Both capabilities need the same three things: a way to turn a user-supplied symbol name into a symbol id, a hydrated view of the symbol table (ids alone are useless in a report), and a shared, non-negotiable statement of what the answer does NOT cover. Duplicating any of those would let the two drift, and the one most dangerous to drift on is the last.
The honesty contract ¶
A static index resolves only part of any repository. An impact analysis that under-reports makes a developer confident and wrong; one that over-reports gets ignored. So every report produced under this package carries a Completeness value, and Completeness is constructed so that the lower-bound statement and the dynamic-dispatch statement CANNOT be omitted — they are appended by NewCompleteness, not by each caller remembering to. Spec §20.
Testability ¶
Deps is deliberately two narrow interfaces rather than *registry.Registry and *graph.Graph. That is not ceremony: it means a capability test can assert "confidence compounds along a path" against a hand-built fake in microseconds, instead of standing up SQLite and hoping the fixture expresses what the assertion is about. The concrete types satisfy the interfaces structurally, checked at compile time below.
Index ¶
- Constants
- Variables
- func BestPathMatches[T any](items []T, pathOf func(T) string, want string) []T
- func ConventionalTestSuffix(rest string) bool
- func DisplayLanguage(language string) string
- func ExportedFlagTrustedLanguages() []string
- func ExportedKnown(language, filePath string) bool
- func FileStem(p string) string
- func GeneralisesToLanguage(definitions int64) bool
- func IsRunnableTest(kind, name, filePath string) bool
- func IsSiblingTestFile(sourcePath, testPath string) bool
- func IsTestName(name string) bool
- func IsTestPath(p string) bool
- func IsTestSymbol(kind, name, filePath string) bool
- func LanguageBindingFor(langs map[string]registry.LanguageBinding, language string) registry.LanguageBinding
- func NeighboursChecked(ctx context.Context, g Graph, symbolID int64, dir graph.Direction, ...) (ns []graph.Neighbour, truncated bool, reason string, err error)
- func NoReferencesClause(language string, definitions int64) string
- func PathMatch(filePath, want string) int
- func SubjectStem(p string) string
- func TestNameCandidates(symbolName string) []string
- type AmbiguousTargetError
- type BindingReader
- type Completeness
- type Deps
- func (d Deps) Freshen(stamp string)
- func (d Deps) LanguageBindings(ctx context.Context, runID int64) (map[string]registry.LanguageBinding, error)
- func (d Deps) ResolutionStats(ctx context.Context, runID int64) (registry.ResolutionStats, error)
- func (d Deps) SymbolIndex(ctx context.Context, runID int64) (*SymbolIndex, error)
- func (d Deps) TargetBinding(ctx context.Context, runID int64, tgt Target) (TargetBinding, error)
- func (d Deps) Validate() error
- func (d Deps) ValueUse(ctx context.Context, runID int64, tgt Target, idx *SymbolIndex, ...) (ValueUse, error)
- type Graph
- type Marked
- type NameUse
- type Registry
- type Symbol
- type SymbolIndex
- func (idx *SymbolIndex) ByFQN(fqn string) (Symbol, bool)
- func (idx *SymbolIndex) ByName(name string) []Symbol
- func (idx *SymbolIndex) InDir(dir string) []Symbol
- func (idx *SymbolIndex) Len() int
- func (idx *SymbolIndex) Lookup(id int64) (Symbol, bool)
- func (idx *SymbolIndex) RunID() int64
- func (idx *SymbolIndex) WithPrefix(prefix string, accept func(rest string) bool) []Symbol
- type Target
- type TargetBinding
- type TestKind
- type TextReader
- type ValueUse
Constants ¶
const ( // LowerBoundCaveat states the single most important property of any answer // derived from a static index: it is a floor, not a ceiling. LowerBoundCaveat = "This result is a LOWER BOUND, not a complete answer. " + "GraphLume reports only relationships it could resolve statically in the indexed run; " + "anything it could not resolve is absent from this report, not absent from the code." // DynamicDispatchCaveat names the specific mechanisms that are invisible. // Naming them matters: "may be incomplete" is ignorable, "your DI container // wiring is not represented here" is actionable. // // It does not say dynamic dispatch is not represented at all, which would be false: // IMPLEMENTS and EXTENDS edges exist even outside a // compiler-backed SCIP import. The heuristic index emits them for Go, // Java, TypeScript, TSX, JavaScript and Python, and impact expands through // them (see impact.Report.Dispatch), so the blanket denial is not // true. The caveat is the narrower claim that still is: the DECLARED half // of dispatch — which types implement which interface — is represented where // an edge was recorded; the RESOLVED half — which call site reaches which // implementation at run time — is not, and never can be from a static index. // Under-claiming would be as wrong as over-claiming: a reader who is told // dispatch is invisible will not read the dispatch section that is right // there. DynamicDispatchCaveat = "Reflection, runtime dependency injection, code generation, string-keyed lookups " + "and cross-language calls are invisible to static analysis and are NOT represented in this result. " + "Dynamic dispatch is represented only in part: where a declared subtype relationship was indexed " + "(an IMPLEMENTS or EXTENDS edge), implementations reached through it are expanded and labelled as " + "such, never as direct callers. WHICH implementation a given call site actually reaches at run time " + "is still unknown, and any subtype relationship the index did not record is absent from that " + "expansion. Verify before relying on it." // DispatchExpansionCaveat is carried by a report that actually performed the // dispatch expansion, and states what the labelled set does and does not // claim. Separate from DynamicDispatchCaveat because it is only true when // there was something to expand, and a caveat that is present when it does // not apply is a caveat readers learn to skip. DispatchExpansionCaveat = "This report expanded through IMPLEMENTS/EXTENDS edges: symbols listed under the " + "dispatch expansion are reachable at run time because a call naming the target can land on an " + "implementation. That is a POSSIBILITY claim derived from a declared subtype relationship, not a " + "recorded call — it is weaker than a direct caller and must not be counted as one. The expansion is " + "also a lower bound on the implementations themselves: it sees only the ones an edge recorded." )
The two statements every capability report must carry, verbatim.
They are constants rather than prose written at each call site because the requirement is that they CANNOT be forgotten. A caveat that each report author remembers to add is a caveat that a future report omits, and the omission is invisible — the report still looks authoritative. Tests assert these exact strings are present in every report this package produces.
const ( // MaxPathChecks bounds how many symbols ON THE PATH are text-checked besides // the target. The check reads the stored text of up to a dozen files per // name, so it is bounded by a small fixed number and not by the size of the // answer: on a hub with a thousand callers it costs the same as on a leaf. MaxPathChecks = 4 // TextBudget is the time the whole check may take. Each name costs a read of // up to a dozen files from the full-text index, which measured about 90ms a // name when those files are 2,000 lines long (tests/scale), so five names are // near half a second. A check that has used its budget stops and says how // many names it reached: an answer that is late is worth less than one that // says it looked at fewer. It is the user's latency, so a slow test machine // is answered in the test, which accepts a check that stopped on time. TextBudget = 600 * time.Millisecond )
const CoverageFloor = 0.6
CoverageFloor is THE published coverage floor, for every surface that prints a verdict on how far to trust this index's relationships.
One constant because two would disagree in the same session: if impact and tests judged ResolutionStats.Rate against 0.5 while coverage judged BindingRate against 0.6, one real index would be simultaneously "COVERAGE TOO LOW" at 37% and unremarkable at 79%. An agent given both numbers cannot act on either.
The rate that survived is BindingRate, on the argument Rate's own doc comment makes against itself: Rate's denominator counts every reference that matched zero candidates in this index, overwhelmingly calls into libraries, so a project that imports heavily scores badly however well GraphLume resolved it — a dependency surface reading as a defect rate. BindingRate divides by what this index claims to define, which is the population any improvement to binding could ever move.
The value is 0.6, not 0.5, because a floor belongs to its denominator. Half of ALL references is a modest bar over a population GraphLume does not control; over the bindable population it is a low one. Below three in five of what the index itself claims full ownership of, most of it was left unbound, and that is a resolver problem rather than a description of the project.
THE FLOOR DOES NOT LICENSE HIDING THE DENOMINATOR. ResolutionStats.Bindable states the condition on which unresolved references may be excluded: callers print Unresolved beside the rate, never instead of it. Every surface that quotes this floor states the unresolved and ambiguous counts with it.
const MinDefinitionsToGeneralise = 20
MinDefinitionsToGeneralise is how many definitions a language must have in an index, with no reference from any of them, before an answer says GraphLume does not extract that language's calls.
The claim is an inference from the index, and it needs enough of the index behind it. Thousands of Kotlin definitions and not one Kotlin reference is a parser that does not read Kotlin's calls. Six C definitions in two files and no reference is two small files, and saying "GraphLume does not extract calls from C" on that evidence would be a false statement about a language whose calls it does extract. Below the threshold the answer states what the index holds and stops there. Either way nothing about callers follows.
Variables ¶
var ErrTargetNotFound = errors.New("capability: target symbol not found in index")
ErrTargetNotFound means no symbol in the run matches the requested name or FQN. It is a normal outcome (a typo, or a symbol the index could not extract) and not a fault, so callers should test for it.
Functions ¶
func BestPathMatches ¶
BestPathMatches keeps the items whose path matches want best. --path Store.java must not choose SqlStore.java, the first by substring, when Store.java is also a candidate; a substring is used only when nothing matches whole segments.
func ConventionalTestSuffix ¶
ConventionalTestSuffix reports whether what follows a generated test-name prefix keeps the match conventional. Pass it to SymbolIndex.WithPrefix.
Empty means an exact hit (TestUpdateStatus for updateStatus); a leading "_" covers the subtest convention (TestUpdateStatus_NotFound). Anything else is rejected, which costs recall — it misses TestUpdateStatusReturnsError — and buys precision: without the rule, target `Update` would claim `TestUpdateStatus` as its test. Recall lost here is recovered by the call-graph signal whenever a real call edge exists, and the call-graph signal is the one worth trusting anyway.
Trailing digits were allowed at first, for the TestUpdateStatus2 variant convention. They came out after the 100k-symbol benchmark showed what the rule actually does: any identifier ending in a digit swallows its longer neighbours, so `Sha25` would claim TestSha256 and `v1` would claim TestV10. On the benchmark fixture that single rule turned 2 naming hits into 50. A numbered-variant test is rare; digit-suffixed identifiers are not.
func DisplayLanguage ¶
DisplayLanguage names an index language for prose. Empty stays empty.
func ExportedFlagTrustedLanguages ¶
func ExportedFlagTrustedLanguages() []string
ExportedFlagTrustedLanguages lists the languages in the table, sorted, for documentation and tests that must not restate it by hand.
func ExportedKnown ¶
ExportedKnown reports whether the exported flag of a symbol defined in a file of this language can be stated as fact.
language is the index's name for it. filePath is consulted only when the language is empty, which is the case for a Target resolved without its file row.
func GeneralisesToLanguage ¶
GeneralisesToLanguage reports whether definitions with no reference among them are enough to say the language's calls are not extracted at all.
func IsRunnableTest ¶
IsRunnableTest reports whether a test-code symbol is something a test runner runs, as opposed to a helper that lives in a test file.
Only Go is told apart, because only Go fixes it by convention: the runner runs a top-level TestXxx, BenchmarkXxx, FuzzXxx or ExampleXxx of a _test.go file and nothing else, so syntheticRepo or seedChain in a _test.go file is a helper. Elsewhere a test is often named freely (a JUnit method annotated @Test, an `it(...)` block), so every test-code symbol counts as runnable rather than dropping real tests on a guess.
func IsSiblingTestFile ¶
IsSiblingTestFile reports whether testPath is the conventional test file for sourcePath: same directory, and its subject stem is the source file's stem.
This is stricter than "a test file in the same directory", and deliberately so. Plain co-location claims that every test beside a file covers that file, which in a package with twenty files and one test is wrong nineteen times. Requiring the stems to correspond turns co-location from a guess into a convention with a name — and a symbol whose file has no sibling test file then honestly reports having no co-located coverage.
func IsTestName ¶
IsTestName reports whether a symbol name follows a test-function convention.
func IsTestPath ¶
IsTestPath reports whether a repo-relative path looks like test code.
Filename convention first, then directory. Both are conventions, not proofs — a file named foo_test.go is not guaranteed to contain tests — which is why every finding derived from this carries a naming-convention provenance rather than being presented as fact.
func IsTestSymbol ¶
IsTestSymbol reports whether a symbol is test code, by any available signal.
The entity kind is checked first because a parser that emitted model.KindTest actually decided this; path and name are fallbacks for the generic extraction path, which emits plain functions.
func LanguageBindingFor ¶
func LanguageBindingFor(langs map[string]registry.LanguageBinding, language string) registry.LanguageBinding
LanguageBindingFor returns the binding outcomes for language, summed over its family.
func NeighboursChecked ¶
func NeighboursChecked(ctx context.Context, g Graph, symbolID int64, dir graph.Direction, kinds []model.EdgeKind, minConf model.Confidence) (ns []graph.Neighbour, truncated bool, reason string, err error)
NeighboursChecked returns a symbol's neighbours and whether the graph cut them at its safety ceiling. A capability that lists neighbours must carry a cut into its own report: a silently shortened list of implementers or callers reads as the complete one.
func NoReferencesClause ¶
NoReferencesClause states that a language yields no references in this index, as strongly as the evidence allows and no more.
func PathMatch ¶
PathMatch ranks how well a file path matches what a user typed to choose it: 3 the whole path, 2 whole trailing segments ("Store.java" for "src/com/shop/Store.java"), 1 any other substring ("Store.java" inside "SqlStore.java"), 0 no match.
func SubjectStem ¶
SubjectStem strips a test file's test markers to recover the base name of the file it is presumed to cover: status_test.go -> "status", TestStatus.java -> "Status", Status.spec.ts -> "Status".
Returns "" when the path is not a recognised test file, so a caller cannot accidentally treat an ordinary file as its own subject.
func TestNameCandidates ¶
TestNameCandidates returns the conventional test-function names for a symbol, as (prefix, exact) pairs where exact says whether the generated name is a complete convention rather than a prefix to be extended.
Returned as prefixes so a single sorted-key binary search finds both TestUpdateStatus and TestUpdateStatus_NotFound, rather than the caller having to enumerate every subtest suffix that might exist.
Types ¶
type AmbiguousTargetError ¶
AmbiguousTargetError reports that a bare name matched several definitions.
Resolving it by picking the exported one, or the first, would be exactly the silent overclaim this package exists to prevent: an impact analysis of the wrong `Close` is not a partial answer, it is a wrong one. The candidates are returned so the caller can re-ask with an FQN.
func (*AmbiguousTargetError) Error ¶
func (e *AmbiguousTargetError) Error() string
type BindingReader ¶
type BindingReader interface {
NameBinding(ctx context.Context, runID, symbolID int64, name string) (registry.NameBinding, error)
LanguageBindings(ctx context.Context, runID int64) (map[string]registry.LanguageBinding, error)
}
BindingReader is the read surface TargetBinding needs.
It is NOT part of Registry, deliberately. Registry is implemented by every fake in the capability tests, and a method added there is a method each fake must grow. A registry that does not offer these reads yields a TargetBinding with Known false, and every consumer treats that as "not measured" rather than as "nothing unbound".
type Completeness ¶
type Completeness struct {
// LowerBound is always true. It is a field rather than an implicit property
// so that a consumer serialising this to JSON, or rendering it for an
// agent, has a machine-readable flag and not just prose to grep.
LowerBound bool `json:"lower_bound"`
// Resolution is the run's raw reference-resolution outcome. Published as
// recorded, never estimated.
Resolution registry.ResolutionStats `json:"resolution"`
// BindableReferences is the references that name something this index
// defines — bound, plus too ambiguous to choose between — and BindingRate
// is the bound share of it. Together they are the single number that says
// how much of what GraphLume COULD understand it did.
//
// resolved_rate was that number and is deliberately gone rather than kept
// alongside. It divided by every reference including the ones naming
// library code no index of this repository can bind, so a project that
// calls a lot of third-party code scores low however perfectly it resolves
// — and it would disagree with the same figure in the CLI and the portal. The
// raw counts are all in Resolution above, so a consumer that wants the all-reference
// ratio can compute it; there is deliberately no second published answer
// to one question.
BindableReferences int64 `json:"bindable_references"`
BindingRate float64 `json:"binding_rate"`
// UnresolvedReferences and AmbiguousReferences are the counts a reader
// needs to size the gap: each one is a use of a name that could have been
// a call to the target and was not attributed to anything.
UnresolvedReferences int64 `json:"unresolved_references"`
AmbiguousReferences int64 `json:"ambiguous_references"`
PendingReferences int64 `json:"pending_references"`
// IndexedSymbols is the denominator behind every count in the report.
IndexedSymbols int `json:"indexed_symbols"`
// Truncated reports that a traversal stopped at a bound. Distinct from the
// resolution gap: this is GraphLume choosing to stop looking, not failing to
// resolve. Both make the answer a lower bound; only one is fixable by
// re-asking with wider bounds.
Truncated bool `json:"truncated"`
TruncatedReason string `json:"truncated_reason,omitempty"`
// Caveats are the human/agent-readable statements. Always non-empty, always
// beginning with LowerBoundCaveat.
Caveats []string `json:"caveats"`
}
Completeness is the honest account of what a report does not cover.
Every capability report embeds one. It is constructed only through NewCompleteness so the mandatory caveats are always present — see Spec §20, which requires impact results to separate what is known from what is not, and forbids presenting a bounded traversal as an exhaustive one.
func NewCompleteness ¶
func NewCompleteness(stats registry.ResolutionStats, indexedSymbols int, truncated bool, reason string) Completeness
NewCompleteness builds the completeness block for a report.
It is the only constructor. Callers cannot produce a Completeness that omits the mandatory caveats without deliberately building the struct by hand, which is what the tests in this package check has not happened.
func (Completeness) HasCaveat ¶
func (c Completeness) HasCaveat(s string) bool
HasCaveat reports whether a specific statement is present. Used by tests and by anything rendering a report that needs to check for a particular warning.
type Deps ¶
Deps is what a capability is given instead of a database handle.
It carries a memoised symbol index because both capabilities need the whole symbol table hydrated (names, paths, export status) and re-reading ~100k rows per query would dominate every measurement in this package. The cache is keyed by run id, so an index swap invalidates it automatically rather than serving names from a run that CommitRun has already retired.
A zero Deps (struct literal) is usable; it simply loads the symbol index on every call. Long-lived callers — the MCP server especially — should use NewDeps.
func (Deps) Freshen ¶
Freshen tells the cache which state of the index it is serving. The cache is keyed by run ID, and an incremental update rewrites the current run in place without a new ID, so a long-lived caller (the MCP server) passes a stamp that changes with every update — the run's timestamps and counts — and the cache drops what it holds when the stamp moves. A zero Deps has no cache and ignores it.
func (Deps) LanguageBindings ¶
func (d Deps) LanguageBindings(ctx context.Context, runID int64) (map[string]registry.LanguageBinding, error)
LanguageBindings returns per-language binding outcomes for runID, loading them once per run. Nil, with no error, when the registry cannot answer.
func (Deps) ResolutionStats ¶
ResolutionStats returns the run's reference-resolution outcomes, loading them once. Capabilities must read them through here rather than calling the registry directly — see symbolCache.getStats for the measured reason.
func (Deps) SymbolIndex ¶
SymbolIndex returns the hydrated symbol table for runID, loading it once.
func (Deps) TargetBinding ¶
TargetBinding reads the binding evidence for tgt.
A registry that cannot answer yields Known false and no error: a fake in a test is not a malfunction.
func (Deps) Validate ¶
Validate reports whether the dependencies needed to answer a query are present, so a misconfigured server fails with a sentence rather than a nil dereference three frames down.
func (Deps) ValueUse ¶
func (d Deps) ValueUse(ctx context.Context, runID int64, tgt Target, idx *SymbolIndex, reached []int64) (ValueUse, error)
ValueUse checks tgt, and the few symbols on its path that have few recorded callers, for a name that occurs in code the index does not record as a reference. reached is the symbols the answer walked through, strongest path first.
Bounded: at most 1 + MaxPathChecks names are looked up in the text index, whatever the size of reached.
type Graph ¶
type Graph interface {
Traverse(ctx context.Context, q graph.Query) (graph.Result, error)
Neighbours(ctx context.Context, symbolID int64, dir graph.Direction,
kinds []model.EdgeKind, minConf model.Confidence) ([]graph.Neighbour, error)
}
Graph is the traversal surface the capabilities need.
Note what is absent: there is no method here that returns edges in bulk, and no capability implements its own breadth-first search. Traversal bounds, cycle termination and path-confidence arithmetic all live in internal/graph and are used, not reimplemented — a second BFS would be a second place for "reports depth-3 reachability as high confidence" to be reintroduced.
type Marked ¶
type Marked struct {
// Line is the comment's 1-based line in its file.
Line int `json:"line"`
// Text is the comment from its marker on, trimmed.
Text string `json:"text"`
}
Marked is a comment in the source that tells whoever changes the code what not to break: HACK, XXX, DO NOT REMOVE, NOTE(race), INVARIANT, SAFETY...
WHY THE SOURCE AND NOT THE COMMIT LOG. The constraint an agent most needs is the one the author wrote beside the code it protects. A commit message says it once, in a body few tools keep, and keyword matching on messages is noise ("fix" is in most of them). A marked comment stays on the lines it is about for as long as they exist, and moves with them.
func MarkedComments ¶
MarkedComments returns the marked comments in text, whose first line is firstLine in its file.
type NameUse ¶
type NameUse struct {
SymbolID int64 `json:"symbol_id"`
Name string `json:"name"`
Path string `json:"path,omitempty"`
Line int `json:"line,omitempty"`
// OnPath is false for the target itself and true for a symbol the answer
// reaches the target through.
OnPath bool `json:"on_path,omitempty"`
// Places is how many places hold the name outside every definition of it and
// every reference the index recorded. A lower bound when LowerBound.
Places int `json:"places"`
LowerBound bool `json:"count_is_lower_bound,omitempty"`
// Sites are the first few of them.
Sites []registry.Place `json:"sites,omitempty"`
}
NameUse is the finding for one symbol.
type Registry ¶
type Registry interface {
FindSymbolsByName(ctx context.Context, runID int64, name, kind string, limit int) ([]registry.SymbolHit, error)
LoadSymbolIndex(ctx context.Context, runID int64) (map[string][]registry.SymbolIndexEntry, error)
ResolutionStats(ctx context.Context, runID int64) (registry.ResolutionStats, error)
}
Registry is the read surface the capabilities need from the registry.
Narrow on purpose. Every method added here is a method a fake must implement, and a fake that has grown to mirror the real registry has stopped being a test aid. Nothing here writes.
type Symbol ¶
type Symbol struct {
ID int64 `json:"symbol_id"`
Name string `json:"name"`
FQN string `json:"fqn"`
Kind string `json:"kind"`
FilePath string `json:"file_path"`
Exported bool `json:"exported"`
}
Symbol is the hydrated view of a symbol a capability report needs.
Same fields as registry.SymbolIndexEntry, restated here so the capability layer's public types do not leak the registry's resolution-time vocabulary into MCP output. It is deliberately narrow for the same reason the registry's is: the whole table is held in memory, so every field costs ~100 kB per 1,000 symbols and a 100k-symbol repository is the design point.
type SymbolIndex ¶
type SymbolIndex struct {
// contains filtered or unexported fields
}
SymbolIndex is the whole symbol table, indexed for the four lookups the capabilities perform.
Why hold it all: an impact report that returns bare symbol ids is unusable, and hydrating a bounded result set one id at a time is one query per row. The registry already loads exactly this shape during resolution and measured it at roughly 10 MB per 100,000 symbols, so the memory is known, not hoped.
A SymbolIndex is immutable once built and safe for concurrent readers.
func (*SymbolIndex) ByFQN ¶
func (idx *SymbolIndex) ByFQN(fqn string) (Symbol, bool)
ByFQN finds a symbol by fully-qualified name.
func (*SymbolIndex) ByName ¶
func (idx *SymbolIndex) ByName(name string) []Symbol
ByName returns every symbol with exactly this name, ordered by id.
func (*SymbolIndex) InDir ¶
func (idx *SymbolIndex) InDir(dir string) []Symbol
InDir returns every symbol defined in files directly under dir.
func (*SymbolIndex) Len ¶
func (idx *SymbolIndex) Len() int
Len reports how many symbols the run contains. Reports quote it so a reader can judge the denominator behind "N callers found".
func (*SymbolIndex) Lookup ¶
func (idx *SymbolIndex) Lookup(id int64) (Symbol, bool)
Lookup hydrates one symbol id.
func (*SymbolIndex) RunID ¶
func (idx *SymbolIndex) RunID() int64
RunID is the run this index was built from.
func (*SymbolIndex) WithPrefix ¶
func (idx *SymbolIndex) WithPrefix(prefix string, accept func(rest string) bool) []Symbol
WithPrefix returns symbols whose NAME begins with prefix and whose remainder satisfies accept.
The accept callback exists because a bare prefix match is too loose to be honest: searching "TestUpdate" for target `Update` would also claim `TestUpdateStatus` as a test of `Update`. Callers therefore constrain what may follow the prefix (see conventionalSuffix in testfiles.go).
type Target ¶
type Target struct {
// Query is the string the caller supplied, preserved so a report can say
// what was asked as well as what was found.
Query string `json:"query"`
SymbolID int64 `json:"symbol_id"`
Name string `json:"name"`
FQN string `json:"fqn"`
Kind string `json:"kind"`
FilePath string `json:"file_path"`
Line int `json:"line"`
Exported bool `json:"exported"`
// Language is the defining file's language as the index names it. Empty
// when the target was resolved without its file row; ExportedKnown and
// TargetBinding both cope with that.
Language string `json:"language,omitempty"`
// Confidence and Source describe how reliably the SYMBOL ITSELF was
// extracted — a Tier-1 generic extraction is not the same fact as a
// compiler-produced one, and a report built on a shaky definition should
// say so before it says anything about callers.
Confidence model.Confidence `json:"confidence"`
Source model.SourceType `json:"source"`
}
Target is the resolved subject of a capability query.
func ResolveTarget ¶
ResolveTarget turns a symbol name or FQN into exactly one Target.
The name lookup is tried first because it is a single indexed query, and it is the overwhelmingly common case. Only when it finds nothing does this fall back to the FQN map, which costs a full symbol-index load — worth it for a disambiguating re-ask, wasteful as the default path.
func TargetFromCandidate ¶
func TargetFromCandidate(query string, c registry.SymbolCandidate) Target
TargetFromCandidate builds the Target for a definition the caller has already selected, by file and line or any other means. It carries the language, which a Target resolved by name alone does not.
type TargetBinding ¶
type TargetBinding struct {
// Known is false when the registry could not be asked. Every count below
// is then zero and means "not measured".
Known bool `json:"known"`
// Name is the spelling the counts below are about: the target's name.
Name string `json:"name,omitempty"`
// Language is the language of the file defining the target, as the index
// names it ("go", "kotlin", "c_sharp").
Language string `json:"language,omitempty"`
// LanguageExtracts is false when the index holds no reference and no
// relationship originating in the target's language. Nothing about the
// target's callers can then be concluded: the calls were never read.
LanguageExtracts bool `json:"language_extracts_references"`
// LanguageStats is reference resolution over the target's language alone,
// so a Kotlin symbol is not described by the Java files beside it.
LanguageStats registry.ResolutionStats `json:"language_resolution"`
// LanguageDefinitions is how many definitions the index holds in that
// language; it is what makes "0 references" a finding rather than an
// empty directory.
LanguageDefinitions int64 `json:"language_definitions"`
// References is every reference spelled exactly like the target's name.
References int64 `json:"references_to_name"`
// BoundHere were bound to the target; BoundElsewhere to another
// definition of the same name.
BoundHere int64 `json:"bound_to_target"`
BoundElsewhere int64 `json:"bound_to_other_definitions"`
// Ambiguous, Unresolved and Pending are bound to nothing. Any of them may
// be a use of the target.
Ambiguous int64 `json:"ambiguous"`
Unresolved int64 `json:"unresolved"`
Pending int64 `json:"pending"`
// ProvenOther were left unbound by the resolver in files a compiler read
// (the Go type check, or a compiler indexer), which proved them uses of
// something else. They are not counted in Ambiguous, Unresolved or Pending.
// The key keeps the name it had when the Go type check was the only source.
ProvenOther int64 `json:"ruled_out_by_type_check,omitempty"`
// Definitions is how many definitions are spelled like the target in files
// that can call it. Zero means not counted.
Definitions int64 `json:"definitions_of_name,omitempty"`
// InstalledCopy is how many of the unbound references sit where the compiler
// resolved this repository's own package to an installed copy instead of the
// checkout. They are still counted in Ambiguous, Unresolved and Pending.
InstalledCopy int64 `json:"seen_against_installed_copy,omitempty"`
// WithoutEdge counts sites bound to the target that no relationship
// records, because the reference sits outside every extracted definition
// (module top level, an anonymous function). They are uses of the target
// that no caller list contains.
WithoutEdge int64 `json:"bound_without_relationship"`
}
TargetBinding is the binding evidence behind an answer about one symbol.
func (TargetBinding) Unbound ¶
func (b TargetBinding) Unbound() int64
Unbound is the references spelled like the target that are bound to nothing.
func (TargetBinding) Undetermined ¶
func (b TargetBinding) Undetermined() (reason string, undetermined bool)
Undetermined reports whether an EMPTY or SHORT caller list for this target is unexplained by the index, and says why in one sentence.
It is the single test behind every "could not determine" this package prints. Three conditions, in the order of how little is known:
- The target's language yields no references at all. The parser does not read its calls, so absence of callers is a property of the parser.
- The language's references exist but none has been resolved yet.
- References spelled like the target exist and are not listed as its callers, because they are ambiguous, unresolved or outside any extracted definition.
Low run-wide coverage is deliberately NOT a condition. It is reported beside every answer, but it describes the repository; a symbol whose every reference was bound is determined however badly its neighbours resolved.
func (TargetBinding) Unlisted ¶
func (b TargetBinding) Unlisted() int64
Unlisted is every recorded use of the target's NAME that a caller list for the target does not contain: the unbound ones and the ones bound outside any definition.
func (TargetBinding) UnlistedSentence ¶
func (b TargetBinding) UnlistedSentence() string
UnlistedSentence states how many references to the target's name exist and are not among its callers, split by why. Empty when every one is listed.
type TestKind ¶
type TestKind string
TestKind is the level a test operates at, where it can be inferred.
func ClassifyTestKind ¶
ClassifyTestKind infers unit / integration / e2e from path and name.
Order matters: e2e markers are checked before integration ones because "tests/e2e/checkout_integration_test.go" is an e2e test that mentions integration, and the more specific marker should win.
type TextReader ¶
type TextReader interface {
UnrecordedMentions(ctx context.Context, runID int64, name string, defs []registry.DefSpan) (registry.UnrecordedMentions, error)
IncomingEdgeCounts(ctx context.Context, runID int64, ids []int64) (map[int64]int, error)
}
TextReader is the read surface the check needs. Like BindingReader it is not part of Registry: a registry that does not offer it yields an empty ValueUse, which every consumer reads as "not measured" and never as "nothing found".
type ValueUse ¶
type ValueUse struct {
// Checked is how many symbols' text was checked, the target included.
Checked int `json:"checked"`
// PathCandidates is how many symbols on the path had few enough callers to
// be worth checking; Checked can be smaller than 1 + PathCandidates when
// the bound was reached.
PathCandidates int `json:"path_candidates,omitempty"`
// OutOfTime is true when the check stopped at TextBudget with names left.
OutOfTime bool `json:"out_of_time,omitempty"`
// Uses are the symbols whose name occurs elsewhere, the target first.
Uses []NameUse `json:"uses,omitempty"`
}
ValueUse is what the text check found for one answer.
func (ValueUse) Lead ¶
Lead is the clause a first line opens with. Empty when nothing was found.
The wording is fixed because an agent reads it and a test holds it: the name, how many places, that they are not recorded as calls, and the consequence.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package architecture answers "does the code match the architecture we said we had?" — ArchMind from the product spec.
|
Package architecture answers "does the code match the architecture we said we had?" — ArchMind from the product spec. |
|
Package captest builds in-memory fixtures for the capability packages' tests.
|
Package captest builds in-memory fixtures for the capability packages' tests. |
|
Package communities groups a repository's files by how they refer to each other, and reports the groups.
|
Package communities groups a repository's files by how they refer to each other, and reports the groups. |
|
Package deadcode reports definitions nothing in the index points at, and says how far each one can be trusted as actually unused.
|
Package deadcode reports definitions nothing in the index points at, and says how far each one can be trusted as actually unused. |
|
Package hotspots ranks files by how often they change against how much code they hold, and reports which files change together without a static edge between them.
|
Package hotspots ranks files by how often they change against how much code they hold, and reports which files change together without a static edge between them. |
|
Package impact answers "what breaks if I change this?" over the shared code knowledge graph.
|
Package impact answers "what breaks if I change this?" over the shared code knowledge graph. |
|
Package knowledge reports where the recent work on a directory was done by so few people that losing one of them loses most of what is known about it.
|
Package knowledge reports where the recent work on a directory was done by so few people that losing one of them loses most of what is known about it. |
|
Package move plans the move of one top-level Go declaration from one file to another file of the same package.
|
Package move plans the move of one top-level Go declaration from one file to another file of the same package. |
|
Package ownership answers "who has context on the code a change here reaches" by joining git history to a blast radius.
|
Package ownership answers "who has context on the code a change here reaches" by joining git history to a blast radius. |
|
Package rename decides where a rename must edit and whether it may.
|
Package rename decides where a rename must edit and whether it may. |
|
Package runtime correlates observed traces with the indexed graph.
|
Package runtime correlates observed traces with the indexed graph. |
|
Package supplychain answers two questions about a project's declared dependencies: what are they, written in a form other tools consume (a CycloneDX SBOM), and — given advisories the user supplies — which of them fall in an affected range, and does the indexed code actually use them.
|
Package supplychain answers two questions about a project's declared dependencies: what are they, written in a form other tools consume (a CycloneDX SBOM), and — given advisories the user supplies — which of them fall in an affected range, and does the indexed code actually use them. |
|
Package testgap joins the two questions the other capabilities answer separately: "what does changing this reach" and "what covers that".
|
Package testgap joins the two questions the other capabilities answer separately: "what does changing this reach" and "what covers that". |
|
Package tests answers "which tests cover this?" over the shared code knowledge graph.
|
Package tests answers "which tests cover this?" over the shared code knowledge graph. |