Repository navigation
Conversation
loadGrammarsForLanguages loads grammars one at a time, because web-tree-sitter corrupts a grammar loaded while another one is loading (tree-sitter#2338). That held only within one call. Two calls started together, like a daemon's sync beside a request that loads a grammar for branch guards or syntax tokens, each ran Parser.init and loaded side by side. A grammar loaded that way stayed cached, and every later parse of its language threw "Incompatible language version" until the process exited. initGrammars now initializes the runtime once for callers that arrive together, and every load joins one queue that skips a grammar an earlier call has loaded. The new test starts six loads together: on main the runtime initializes six times, and parses fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ymbol
A LuaJIT program calls its Rust library through the FFI by symbol, so the
Lua call named a C function no Lua file defines and every flow stopped at
it. A synthesis pass, run only where a Lua file names "ffi" and a Rust file
declares an export, links each call through a proven FFI receiver to the
one Rust C-ABI export with that symbol (lua-rust-ffi).
A receiver is proven from require("ffi") through ffi.C, ffi.load and
pcall(ffi.load), their aliases, table members and function returns, and a
library another module returns as a member or from a function, as an
OpenResty binding's cdefs.clib. Shadowing, reassignment, a write through a
function's parameters or a receiver the analysis can't resolve, and a value
handed to code in another file withdraw the proof. A symbol two exports
share links neither; ffi.cdef asm labels rename the symbol.
The pass analyzes the Lua files that name "ffi" and, round by round, the
files holding a string that can name a module found to hand out a library,
since require reads only a literal, and scans the Rust files that name
no_mangle or export_name for their exports. Each file's analysis is stored
under the index directory, keyed by a fingerprint of the analyzers and
grammars and by the file's path and text, so a sync re-analyzes only what
changed. A file nested too deep, unreadable as a chunk or over its work
budget is declined, and the pass never throws, so no other pass loses its
edges. Lua and Rust files are synthesis inputs only once the bridge is open.
Validated on twelve public corpora, kernel and wasm giving identical graphs,
and on three controls left byte-identical; see docs/design/lua-rust-bridge.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it selects
A LuaJIT program that calls one shared Rust export with an operation name,
call("task.run", ...) into match op { "task.run" => run(), ... }, made every
Lua caller reach every handler through the export. The bridge now follows a
literal operation through Lua wrappers and modules that forward it, and Rust
functions, methods, closures and declarative macros that forward it, into
the match, and links the Lua call to the one handler its arm selects
(lua-rust-operation). The call into the shared export is kept as a
transport reference that every walk treats as a boundary, explore's test
notes and the viewer's walks included.
Arms are tried in order: a guard, a #[cfg] arm, a binding or a wildcard
that may take a literal leaves it unresolved, and an operation an earlier
return always takes never reaches its arm. A C string read with CStr is its
text. Positions skip comments and attributes; for, while-let and let-chain
bindings shadow; crate:: paths go through the Cargo identity. An export that
maps strings to values is no dispatcher. A Rust function nested too deep or
over its budget is declined.
The analysis store also keeps each Rust file's dispatch analysis and module
declarations, so a sync re-analyzes only what changed; a Cargo.toml edit
refreshes synthesis on sync.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 15, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #3304. A LuaJIT program that calls one shared Rust export with an operation name now reaches the handler that operation selects, not every handler behind the export.
With FFI links alone,
run_task→dispatchis a plain call, sorun_taskreaches bothrunandread, and every Lua caller ofdispatchshows up among the callers ofrun. With this change,run_tasklinks torunwith the hopLuaJIT → Rust operation `task.run` via `dispatch`. The call intodispatchis kept as a transport hop that walks stop at, soreadis no longer reachable fromrun_task.What it does
match, and links the Lua call to the handler the arm selects (lua-rust-operation). Strings may cross as a pointer and length or as aCStr.#[cfg], a binding or a wildcard may pre-empt.returnalways takes, judged on the string tests the source spells.letbinding.metadata.transportOnly). Every walk stops at it: BFS, DFS, callers, callees, impact, paths, explore's test notes and the viewer's walks. An export that maps strings to values is no dispatcher, and its calls stay plain.crate::need declared modules and local path dependencies.Cargo.tomledit refreshes synthesis on sync.docs/design/lua-rust-bridge.mdhas the rules, the limits and the validation.What I ran
On Linux x64 (WSL2), Node 24.19.0, against main at
f72c9d2with the grammar fix and #3304:match. This change adds 125 operation edges and turns its 4 calls into the export into transport hops. A script checked the flows on that index:sendforwards three literal operations and reaches exactly those three handlers;codegraph_explorelabels each hop with its operation and the Rust line that dispatches it.CODEGRAPH_KERNEL_EXPECT=1: 11,369 passed, 2 expected failures, 58 skipped (platform-gated), none failed. WithCODEGRAPH_KERNEL=0, the bridge's tests and every Lua and Rust resolution test: 49 files, 546 passed. The module-declaration test fails when the stored declarations are keyed without the file's text; I checked it by breaking the code.Not done
This branch carries the commits of #3303 and #3304 until they merge; review only the last one. It takes
EXTRACTION_VERSION30, or the next free one after #3304.🤖 Generated with Claude Code