Skip to main content

Module graph

Module graph 

Source
Expand description

Structure half of the store: symbols, and the edges between them.

Extraction is tree-sitter over a file’s text, and it hangs off the same changed-file path that drives re-embedding (see crate::Semlith::index_set). That is the whole freshness story: there is no build step, no separate command, and no artifact that can be out of date with the corpus, because the pass that re-embeds a file is the pass that re-extracts it.

Every language in crate::filter::LANGUAGES carries edges — all forty-six, since 0.17.0 replaced the extractor’s own six-language list with a question asked of the grammar table. A row with no grammar is named in WITHOUT_GRAMMAR with the reason; it is searchable exactly as before and simply has no rows here.

§Where the queries come from

Every grammar ships a TAGS_QUERY written for tree-sitter tags, and it is a good source of definitions — that is what it was built for. Its reference coverage is uneven and none of it covers imports: of the six here, none capture import statements at all, and TypeScript and C capture no calls either. So each language pairs the bundled query with a short supplementary one below, and the two are run together.

§Confidence

An edge is extracted when the syntax tree says where the target came from — a structural edge, or a call whose name the file also imports — and inferred when the target was matched by bare name alone. Two functions called new in different modules is the normal case in real code, not a corner case, so an inferred edge is marked and stays marked everywhere it surfaces. Nothing may present one as the other.

Structs§

Chain
A chain, with what it is worth.
Community
A group of names that call each other more than they call anything else.
Edge
An edge found in a file, before either end has an id.
Evidence
Everything the store knows about one symbol, in one reply.
Extraction
What one file yielded.
Hop
One name two hops from the centre, and the first-ring name it came through.
Hub
One hub of a community: a name and where it is defined.
Impact
Everything that reaches one symbol, to a bounded number of hops.
Neighbours
What points at a symbol, and what it points at.
Reached
One definition that reaches the symbol asked about.
ReachedFile
One file that reaches the symbol, and how closely.
Step
One edge of a path, as the path finder renders it.
Summary
What the chain is made of, counted rather than described.
Support
One hop’s supporting line, as evidence rather than as a picture.
Symbol
A symbol found in a file, before it has an id.
Trace
What a chain is worth, in the shape somebody can paste into a review.

Constants§

AMBIGUOUS
Computed at query time: the name had several definitions and nothing in the source narrowed it to one. An answer that crosses one of these is a guess, and every surface says so.
COMMUNITIES_SHOWN
How many communities the panel lists before it says Shown N of M.
COMMUNITY_EDGES
Most edges the community pass will read out of one store.
CONFIDENCES
Every confidence value a renderer can be handed, strongest first.
DEPENDENCY_KINDS
The edge kinds that mean “depends on”, which are the only ones a path is about.
EXTRACTED
Stored on the edge: the syntax tree said where the target came from.
IMPACT_LIMIT
How many reached definitions one impact answer will carry.
INFERRED
Stored on the edge: the target was matched by bare name alone.
KINDS
Edge kinds, as stored in edges.kind.
MAX_NODES
How many symbols a single traversal will visit before it stops and says so.
NAVIGATIONAL_KINDS
Symbol kinds nothing can point at.
RESOLVED
Computed at query time: the name had several definitions and the hint, the source file, or its imports picked exactly one of them.
WITHOUT_GRAMMAR
Languages in crate::filter::LANGUAGES that ship without a graph, and why.

Functions§

call_site
Where the call, import or reference this edge records was actually written.
collapse
One row per name an edge points at, rather than one row per definition that name could mean.
communities
The communities of a graph, by label propagation.
confidence_rank
How much a confidence value is worth when something has to be ordered by it: lower is better. An unknown value sorts last rather than panicking, so a store written by a newer binary still renders.
dependency_kinds
evidence
The definition, the first ring and the second ring, in one pass.
expand
Rank the neighbourhood of a set of seed symbols by personalised PageRank.
extract
Symbols and edges for one file.
has_graph
Whether the graph covers a language.
impact
Everything that reaches name, breadth first, up to depth hops.
language_grammar
The grammar for a language, for a caller outside the extractor.
language_of
The language label for a path, if this release extracts from it.
languages
Every language the graph covers, in the table’s own order.
neighbours
One hop in each direction around name.
not_connected
What to say when there is no chain.
not_navigational
The same list as a SQL NOT IN list, for the two joins that resolve a name.
scoped
shortest_path
The shortest chain of edges from from to to, if there is one.
support_mark
The mark a hop’s supporting line carries.
trace
Turn a chain into evidence.
verbatim
Leave a path exactly as the store recorded it.