Documentation
¶
Overview ¶
Package multilang is the spike's tree-sitter-backed contract extractor. It answers question 5 of the spike: whether a wasm-backed extractor can honor the same contract as internal/contract — never return an error, treat an unparseable or oversized file as "no fingerprint", respect MaxSourceBytes, MaxSymbols and MaxSignatureRunes, and apply the deny wire-gate to every derived signature before it is published.
It deliberately reuses internal/contract for the hashing, normalization, sorting and gating so the spike measures the parser, not a reimplementation of the fingerprint format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor owns one wasm runtime per language, each created on first use.
Lazy per-language loading is the point (ADR-063): compiling every grammar up front costs startup time and resident memory proportional to how many languages Overgent supports, not to how many the member's repository actually contains. A Go and TypeScript repository never pays for the C# grammar.
It is not safe for concurrent use; callers serialize, and the underlying runtimes serialize anyway.
func New ¶
New prepares an extractor. It deliberately loads nothing: no wasm is compiled until a file of that language is actually fingerprinted, so constructing an extractor is free even on a platform where the runtime will later turn out to be unavailable.
loader resolves a tree-sitter language name to its module bytes. Its second result reports whether a module for that language exists at all, which is distinct from failing to load one that does.
func (*Extractor) Close ¶
Close releases every runtime that was actually created. It reports the first failure but always attempts all of them, so one stuck runtime cannot leak the rest.
func (*Extractor) Extract ¶
func (e *Extractor) Extract(ctx context.Context, path string, source []byte, deny func(string) bool) (fingerprint.File, bool)
Extract mirrors fingerprint.Extract for a tree-sitter language. It never returns an error: a path with no grammar, a source over MaxSourceBytes, a parse containing ERROR or MISSING nodes, an unavailable runtime, and any wasm failure all yield (File{}, false), which callers read as "no fingerprint".
func (*Extractor) Fingerprintable ¶
Fingerprintable reports whether this extractor has rules for the path. It does not load anything, so it stays cheap and stays true on a platform where extraction will fail: a platform gap must never be reported as a language gap.