Documentation

Docs / Reference

ADR 0002 — Tree-sitter integration through WASM

Status: Accepted (2026-10-05, after T001 and T002 review) Date: 2026-10-05

Context

Graphvein needs deterministic tree-sitter parsing while remaining buildable on Windows machines with only Go installed. T001 compares upstream tree-sitter compiled to WASM inside a pure-Go runtime with official native cgo bindings. The experiment lives in its own module under spike/parsing/, separate from future application dependencies and interfaces.

Options considered

Measurements

Windows/amd64, Go 1.27.1, Git Bash, no GCC/Clang/cc. No system tools installed. WASM uses wasitter v0.1.0 and wazero v1.10.1; native uses go-tree-sitter v0.25.0. Both candidates pin TSX v0.23.2 and Rust v0.24.2 grammars.

See the report for methodology, reproduction, limitations and links to raw results. There is no measured WASM/native ratio.

Decision

Use Option A: upstream tree-sitter in WASM through a pure-Go runtime for the built-in parser. The validated initial adapter is wasitter/wazero, with matching, pinned WASM releases. T001 explicitly prefers A when B needs extra system installs; that branch applies here. This decision is grounded in correctness and distribution evidence, not a claim that A meets the 3× native speed threshold.

Production parser integration belongs in internal/parse. No production cgo is approved. The sole experimental exception is the official cgo dependencies imported by spike/parsing/internal/parse/native.go, gated by native && cgo, for this comparison. No other application package may introduce cgo.

Consequences

Known gaps

Report a problem with this pageSource: docs/adr/0002-tree-sitter-integration.md