Repository navigation
The code index reads Lua files with a tree-less lane - #743
Conversation
`.lua` files were chunked as plain text, so code.symbol, code.callers and code.outline knew nothing in them. A tree-less lane (no new tree-sitter dependency), in the shape of lang_proto.py, now reads them:
- `function a.b()`, `function a:b()`, `function f()`, `local function f()`, `M.f = function()` and `local f = function()` are `function` symbols qualified by the module path (`<mod>::a.b`), spanning to the `end` that closes them;
- `f(...)` and `a.b(...)` are call sites bound by lane_units.bind_sites (same file 1.0, repository-unique 0.6); Lua's own functions, its standard libraries and method calls on an unknown receiver name nothing;
- `require("a.b")` is an include of `a/b.lua` or `a/b/init.lua` under the file's directory and its nearest ancestors, then the root; a module the repository does not hold resolves to nothing.
Strings, long brackets and comments are skipped, so a keyword inside them moves no block. The module is outside the extractor stamp (listed in NON_EXTRACTOR_MODULES), so existing deployments re-chunk nothing; a namespace gains its Lua rows by a backfill of its `.lua` files.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Rahul <[email protected]>
zlareb1
left a comment
There was a problem hiding this comment.
Verdict: request changes. The function-length gate fails on this head; the inline comment names the required split. The Lua and extractor-stamp tests pass locally. The corpus tests could not complete on this host because the bounded tree-sitter child process exits with status 1; CI must verify that surface.
zlareb1
left a comment
There was a problem hiding this comment.
A second required check fails on this head: the test inventory does not claim the Lua fixtures.
… an inventory workflow Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Rahul <[email protected]>
|
@zlareb1 thanks, both fixed in cba885c: |
|
The one failing check on the last run is That's linear up to 64k units, so I read the CI result as a slow runner rather than a regression. I've merged the latest |
|
Hi @rahulsjha , you have made many contributions on the repo. Would you like to publish a blog about your changes or loom? |
|
Sure, I will make a Loom video with my experience and details. |
zlareb1
left a comment
There was a problem hiding this comment.
The function-length and fixture-inventory findings are fixed. The 59 focused Lua, extractor-stamp and inventory tests pass, and the function-length gate passes without changing its baseline. No further findings in symbol spans, call binding or require resolution; CI is running.
Closes: #625
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
The code index reads Lua files: functions become symbols,
f(…)anda.b(…)calls become call edges, andrequire("a.b")becomes an include of the repository'sa/b.luaora/b/init.lua.Why
.luawas in_CODE_TEXT_EXTENSIONS, so Lua files were chunked and searchable butcode.symbol,code.callersandcode.outlineknew nothing in them.Scope and risk
A tree-less lane, following
docs/development/adding-language-support.mdand shaped likelang_proto.py/lang_jsonnet.py:server/code/domain/extract/lang_lua.py:parse_lua(path, source) -> ParsedFile,reference_sites,SITE_RULES,CHUNK_OPTIONS,wanted_paths/resolve_imports.function a.b(),function a:b(),function f(),local function f(),M.f = function()andlocal f = function()→functionsymbols named by the last part and qualified by the module path (<mod>::a.b; a method's:reads as., the signature keeps it). A span runs to theendthat closes the function: blocks open atfunction,if,do(whichfor/whileuse) andrepeat, and close atend/until. Strings, long brackets ([[…]],[==[…]==]) and comments (--,--[[…]]) are skipped, so a keyword inside them moves nothing.f(…)anda.b(…)→callsites on the bare name, bound bylane_units.bind_sites(same file 1.0, repository-unique 0.6, ambiguous → nothing). Lua's base functions (print,ipairs,setmetatable, …) and standard libraries (string.*,table.*,math.*, …) name nothing;obj:m()is not a site, the receiver's type being unknown.require("a.b")/require "a.b"→a/b.luaora/b/init.luaunder the file's directory and its nearest ancestors (lane_units.ancestor_dirs), then the root, settled against the namespace's live paths; a module the repository does not hold (a rock, a C module) resolves to nothing; a..or absolute path names nothing.".lua": "lua"inLANG_BY_EXTENSION, removed from_CODE_TEXT_EXTENSIONS;_parse_luain_PARSERS,luainLANE_UNIT_LANGSand_lane_module;"lua": SCRIPTinname_scope.lang_lua.pyis listed inNON_EXTRACTOR_MODULESand no stamped module changes, so existing deployments re-chunk nothing. A namespace that already indexed Lua as text gains the rows withloom code backfill --paths-fileof its.luafiles.Compatibility, rollout and rollback
.luafiles only)..luafiles gives an already-indexed namespace its Lua symbols and edges..luato plain text; the Lua rows written meanwhile stay until the files are re-indexed.Tests
tests/unit/test_code_lang_lua.py(15 tests): symbols, spans and signatures; a method, long comment, string holdingend function (and nestedif/repeat … until; builtins / library / method calls are not sites; binding same file first then repository-unique; a name defined twice binds to nothing; require candidates (nearest first,init.lua, a slash path, a..escape); detection (.luais no longer text); chunks; and 7 linear-time cases (assert_linear) over pathological inputs (unclosed headers, long brackets,ifruns,require(").tests/fixtures/code_lanes/lua/(synthetic, listed inNOTICE.md): a vector module and a menu scene that requires it.LANESintests/code_lanes/corpus.pygainslua/, and the corpus resolves its includes and binds its sites like proto's.expected.jsonregenerated withpython -m tests.code_lanes.corpus --write; its diff is only the two Lua files (menu.luaincludeslua/game/lib/vec.lua; 5 call edges; 445 → 451 edges).SAMPLESintests/unit/lane_walks.pygainsluafortest_code_regex_cost.py.Run in Linux (
python:3.12,uv sync --frozen --all-extras, as CI):the lane on a sample module: symbols with spans,
init.luaresolution, and the sites (no builtins, nothing from the comment or the string).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. I read every registration point against the adding-language-support guide, checked the parser on a sample module, ran the lane, corpus, stamp and cost tests in Linux and reviewed the regenerated
expected.json.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed. (ruff format and check, and the lane / corpus / stamp / cost tests above were run; the fullmake test-unitwas not)docs/reference/configuration.mdand thedocs/reference/tables (python scripts/codegen/docs_reference.py), the reach manifest,schemas/schema.sql(make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py). (expected.jsonregenerated; no other generated file changes)main; no merged migration is edited. (n/a)hooks/,lib/,bin/,skills/,.mcp.json, the Codexplugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version. (n/a)npm --prefix frontend run build) and its tests pass, iffrontend/changed. (n/a)docs/describe the system as it now is, and this description names any operator steps and wire changes. (code-index overview language table; adding-language-support lane list)tests/unit/test_public_copy.py).git commit -s), as CONTRIBUTING.md asks.