Expand description
§waggle-lens-code — the symbol lens (design doc 20)
Source-code structure, computed once at mint where the artifact is
at hand, stored content-addressed beside the snapshot, served
everywhere as plain data. This crate is the extraction half:
tree-sitter parses the snapshot, each grammar’s tags.scm query marks
the definitions, and the result is a flat, compact SymbolOutline —
never an AST, never an index, never retained.
The performance discipline (doc 20 §4) is structural here:
compiled queries are cached once per process (std::sync::OnceLock),
parsers are reused per thread, the outline is an arena (one Vec, one
shared name buffer, parent links by index), and the parse tree drops
before extraction returns. extract is a pure function of its inputs —
no clock, no I/O — so the sans-I/O law holds even though this crate
lives outside waggle-core (it must: grammars are C, and this crate is
never compiled to wasm; the edge serves precomputed outlines).
Structs§
- Symbol
Outline - The arena. Construction happens in
crate::extract; consumers get lookups and the wire form.
Enums§
- Lang
- The languages the v1 lens ships (doc
20 §9): chosen by agent traffic; each addition pays its binary-size cost consciously.
Constants§
- OUTLINE_
CONTENT_ TYPE - The outline blob’s content type (doc
20 §3). - WIRE_
VERSION - Wire version — pins the
(bytes, extractor) → outlinefunction so a future extractor bump mints new outlines without ambiguity (doc 20 §3).
Functions§
- detect
- Detect a supported language from a path — extension first, then the
well-known extension-less basenames have no grammar here (they are
text-sniffed upstream); a
Nonesimply means “no outline”, never an error: the lens degrades to the plain text loop (doc20 §9). - extract
- Extract the symbol outline from source text. Pure: same inputs, same outline, always. Returns an empty outline (callers store no blob) when the text does not parse at all or yields no definitions — degradation is to today’s text loop, never below it.