Skip to content

Ruby files are indexed with symbols, calls and inheritance - #2157

Open
VanshajPoonia wants to merge 31 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/2120-ruby-code-lane
Open

VanshajPoonia wants to merge 31 commits into
ClickHouse:mainfrom
VanshajPoonia:issues/2120-ruby-code-lane

Conversation

@VanshajPoonia

@VanshajPoonia VanshajPoonia commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #2120

Changelog category (leave one):

  • New Feature

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 parses Ruby (.rb, .rake, .gemspec, Gemfile, Rakefile). Classes, modules and methods are symbols, superclasses and mixins are inherits edges, calls and require are edges, and the SQL handed to ActiveRecord is lifted as statements. A namespace gets these rows for files it already holds with loom code backfill --paths-file over its Ruby files. New and changed files use the parser from the upgrade on.

Why

A .rb file was indexed as text. code.search and code.grep found it. code.symbol, code.callers and code.impact returned nothing for it. The 26 Ruby files under sdk/ruby/ had no symbols while the Go, Rust, Java, Python and TypeScript SDKs beside them did.

The lane reads Ruby with tree-sitter-ruby (0.23.1, MIT, abi3 wheels for macOS, Linux and Windows). It is a new entry in the code extra and in bounded_parse._LOADERS, so every parse still runs in the bounded child first.

Alternatives:

  • A hand-written scanner like the Lua lane. Ruby has heredocs, % literals, command calls without parentheses and do/end blocks that share keywords with modifiers. A scanner would misread all of them.
  • Ruby in the shared chunker and edge walker, as for Go. Both are in the extractor stamp, so the change would re-chunk every namespace in every deployment.
  • A compiler tier on scip-ruby. Out of scope, and it would not replace a fast tier.

Scope and risk

  • No stamped module changes. lang_ruby.py is listed in NON_EXTRACTOR_MODULES. Chunks come from lane_units.span_chunks, one per method, and edges from lane_units.bind_sites, which is how the tree-less lanes work. span_chunks gains a unit_kinds argument so the units are methods and not the class around them. Other lanes pass none.
  • Every line of a Ruby file that holds text stays in a chunk, as when Ruby was text. The lines between two methods are one other chunk however short: a class line, a lone has_many :comments, a constant, a Gemfile's gem "pg". A gap of blank lines is in no chunk, so code.symbol returns a method's body and answers a class or module with its span to read. The 26 files of sdk/ruby give 792 chunks where the text windows were 86, and no line with text is left out.
  • Symbols follow the issue. A method is <file scope>::A::B#name for an instance method and <file scope>::A::B.name for a singleton one (def self.x, class << self, and def Const.x or class << Const as Const.x, with Const read from the innermost namespace out). class A::B and nested blocks give the same name. The file scope is always dotted (root. for a file at the top), because the name gate reads a scope without a . as native. The SQL statements and created objects of a Ruby file take the same scope.
  • Heritage sites are class X < Y and include, extend and prepend of a constant. They bind as inherits edges to a class or a module, same file at 1.0 and repository-unique at 0.6. At both rungs the caller is no candidate, so class Admin::User < ::User binds to the other file's User. This holds for every lane's inherits rule. Const.new binds to Const. new and self.new bind to the class around them, and inside def Const.x or class << Const to Const.
  • A call binds by name. A call with a receiver of unknown type binds only when the name is defined once in the repository, as in the other lanes, and in Ruby the caller's own method counts: @app.call(env) inside Outer#call does not bind to an Inner#call of the same file. A name in a list of Ruby core, Rails and RSpec methods (save, update, puts) is a site only when called on self or on nothing, and then binds only to a method of its own file. A bare word is a site only when no scope around it holds a local variable of that name: parameters and the names a pattern binds count, a block or lambda keeps its own parameters and assignments, a rescue variable counts from its clause on, and a parameter's default value is read. It binds only inside its own file, so the index is not asked for it.
  • lane_units.bind_sites binds a site inside a SQL statement's span from the method around it, not from the statement or the table or function it creates. Those symbols follow the lane's own in the parse, statements first, and span_chunks takes no unit from them either. A qualified name written twice in one file is one same-file target: a Ruby class reopened, and in the other lanes a repeated definition (a Lua function written twice, a protobuf message declared twice), which recorded no edge before. Statement symbols reach bind_sites only from Ruby.
  • Five lane_units and chunk-stage changes reach the other lanes. A unit that starts on the last line of the previous one and runs past it (end; def b) is its own chunk, sharing that line, where it used to fold into the earlier chunk. Compared chunk by chunk, none moved over the 21 lane fixtures and about 3,800 proto, thrift, Go template, HCL, Kubernetes, Jsonnet, Lua and GraphQL files. Lines are counted on \n alone, as the parser and chunker.chunk_file count them: a form feed or a U+2028 used to start a new line in the chunks only. A lane file whose parse failed is cut into line windows, as any other language's, instead of span chunks with no units. The symbols a unit holds are found by bisection, and bind_sites finds the caller of every site in one sweep over the spans. Both grew with units or sites times symbols: a class of 8,000 methods took 4 s to chunk. It now takes 0.08 s to chunk and 0.09 s to bind its 32,000 sites. Over the 39 lane files of the corpus and sdk/ruby the sweep picks the same caller as before for each of 7,401 lines, and expected.json does not move.
  • Not read as symbols: attr_* methods, alias and alias_method, define_method, constants, and the class Struct.new, Class.new, Module.new or Data.define builds. The methods in that call's block belong to the constant it is assigned to (Point = Struct.new(:x) do … end gives Point#norm), and to nothing when no constant holds the class. A method defined on an object names nothing: class << obj, an eval on a variable, and def self.x or class << self inside an instance method or a define_method block, where self is an instance. X.class_eval defines in X, X.instance_eval on X itself, and an eval with no receiver on what self is. A relative X is the class of the innermost namespace around the call whose definition the file holds above it. When the file holds none, a lone X takes the innermost namespace and a path A::B is read as written. A method defined inside any other block is qualified by the class or module around the block. A call outside any method or class (a rake task body, a top-level RSpec block) has no caller symbol, so it records no edge.
  • code.callers on a Ruby class folds in none of its methods, and the dispatch walk finds no base for a Ruby method. Both read Class::member, and the method names follow the issue (A::B#x, A::B.x).
  • As for the other script lanes, a call can bind at 0.6 to the one definition of its name in Python, Go or TypeScript: the name gate classes a definition by the shape of its qualified name, not by its language.
  • require "a/b" resolves under the file's directory and each ancestor, and under their lib/. require_relative resolves beside the file. A gem or a stdlib name resolves to nothing.
  • SQL islands use the Go and Java contract. The sinks are find_by_sql, execute, select_all, where and the other ActiveRecord and pg methods in RUBY_CLIENT_METHODS, with heredocs read. fetch, run and group are left out: over the 3,522 Ruby files of a large open-source Ruby code base they read ENV.fetch("USER") and a pretty printer's group as SQL. Without them the same files give 1 island, and it is a real query.
  • code_sql_units qualifies statements with the scope the island grammar names (ruby_scope for Ruby, module_scope for Go and Java), and the edge stage reads it from the units. _scope_dialects_for keys a file's dialect by each candidate's own scope, which TypeScript islands read when a table name has several definitions. A Ruby heredoc's statement starts on its body's line, which for the second heredoc of a call is below the first.
  • The island walker is recursive, as for Go and Java. A file nested past Python's recursion limit fails its parse and is indexed as line windows with the error recorded.
  • .rb, Gemfile and Rakefile leave the text list in lang_text.py, and .rake and .gemspec are new. A Ruby method is now a function chunk, so the functions_first ranking applies to Ruby. The architecture page says so.
  • The Claude Code plugin's prompt pack still sends every Ruby unit as a place, because it holds only some languages to definitions. Changing that bumps the plugin versions, so it is for another change. hooks/HOOKS.md and the plugin page stop calling Ruby text. That is a wording fix with no behaviour change, so the plugin versions stay.
  • ingest_resolve sends a language that is in both CODE_ISLAND_LANGS and LANE_UNIT_LANGS through the lane's resolver. Ruby is the only one.

Compatibility, rollout and rollback

  • Wire: none. No op, setting or migration.

  • Operator steps: the code extra gains tree-sitter-ruby>=0.23, which the image takes from uv.lock. uv.lock was regenerated with uv 0.13.12. It keeps lock revision 5, as main's lock has, and CI's uv 0.12.19 passes uv lock --check. After the upgrade a namespace keeps its text chunks for Ruby files that do not change. Re-ingest them:

    git ls-files | grep -E '(\.rb|\.rake|\.gemspec)$|(^|/)(Gemfile|Rakefile)$' > ruby-paths.txt
    loom code backfill --org <org> --namespace <code-namespace> --paths-file ruby-paths.txt

    A deployment without the grammar records the parse failure on each Ruby file and indexes it as line windows without symbols.

  • Rollback: reverting reads Ruby as text again. Rows the lane wrote stay until a file is ingested again or a backfill reads it.

Tests

  • tests/unit/test_code_lang_ruby.py (51 tests, 61 cases) covers nesting and names, the owner of a method defined in an instance method, an eval block or a Struct.new block, a relative or qualified constant in an eval, def Const.x and class << Const, block, lambda and rescue scopes for bare words, and new in a singleton definition, bare words under guards, rescue lists and superclasses, multiple assignment targets, a method that starts on another's last line, the scope and lines of a root file's SQL, calls inside SQL that creates objects, a subclass named like its base, doc comments (including private def and a trailing comment), requires, call sites by receiver, locals shadowing a bare word (parameters, defaults, patterns), common names called on self, a reopened class, a call inside a SQL string, new, binding at each rung and for ambiguous names, superclass and mixin edges, require resolution, detection and the text list, chunks per method with every line that holds text covered, LF line counting, the line windows of a failed parse, the SQL islands including a heredoc, the ingest reads for chunks, includes and edges, and linear time for parsing, chunking and binding. A test in test_code_proto_gotemplate_lanes.py covers unit_kinds.
  • The lane has a corpus under tests/fixtures/code_lanes/ruby: a gem with a mixin, a subclass, singleton methods, requires, a rake task, a gemspec and ActiveRecord SQL bound to a table. expected.json gains 10 files and 33 edges, each row checked.
  • On the final branch, 38 unit test files ran in batches: the Ruby lane, every other lane_units lane (proto, thrift, Go templates, HCL, Kubernetes, Jsonnet, Lua, GraphQL), the corpus and its manifest, the extractor stamp, the chunker, ingest errors, lanes and dependents, the Go, Java, Python, shell and host islands, lang_text, the kind prior, the plugin query contract, the name gate, and the doc tests (test_doc_links.py, test_public_copy.py, test_docs_reference.py, test_agent_instructions.py). 1,170 passed and 1 skipped. pytest tests/analyzer/test_corpus.py -k "not live" passes (10 passed, 2 skipped). The plugin's hooks-doc and prompt-pack node tests pass (40).
  • Before the review fixes, 117 unit test files that import the touched modules ran: 2,917 passed and 2 skipped. The 32 failures are the ones that need Linux, all with ValueError: current limit exceeds maximum limit: test_a_registered_lane_costs_linear_time for every lane (27, Ruby among them) and 5 memory-limit tests in test_code_parse_deadline.py. The same tests fail the same way on upstream/main here. The registry cost walk for Ruby ran in process with the same checks: 82 shapes and none over linear.
  • scripts/gates/mypy_gate.py reports 0 errors. scripts/gates/function_length_gate.py is at its baseline. ruff check, ruff format --check and check_no_secrets.py are clean, and so are all 16 scripts/codegen --check steps of make lint. Prettier 3.9.9 is clean on the edited pages. uv 0.12.19 and 0.13.12 both pass uv lock --check.
  • On real code: the 26 Ruby files of sdk/ruby give 28 modules, 259 classes and 640 methods with no parse error. The 3,522 Ruby files of a large open-source Ruby code base parse with no error in 33 seconds, with symbols and SQL islands.
  • Not run: the full unit suite, the integration suite, a live ClickHouse, a backfill on a real namespace, the image build and the Linux-only tests above. CI runs them.

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 wrote the diff and ran the checks listed under Tests.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump), the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py) and the standalone skill bundles (python3 scripts/codegen/standalone_skills.py).
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Note

Medium Risk
Large new parser lane plus shared lane_units and edge/chunk ingest behavior affects all LANE_UNIT_LANGS files; rollout depends on backfill and the new grammar dependency.

Overview
Adds first-class Ruby indexing via a new lang_ruby.py lane and tree-sitter-ruby (stamped extractors unchanged). .rb, .rake, .gemspec, Gemfile, and Rakefile are detected and parsed; Ruby is removed from the text-only fallback in lang_text.py.

Ruby uses the LANE_UNIT_LANGS path: one method chunk per file (span_chunks with unit_kinds), call / new / heritage / bare sites bound by lane_units.bind_sites, require includes, and ActiveRecord-style SQL islands joined at ingest like Go/Java. Ingest registers _parse_ruby, extends CODE_ISLAND_LANGS, and wires lane include resolution separately from tree-sitter import resolution.

Shared lane/ingest fixes that land with Ruby: SiteRule.caller_counts and reopened-class binding; unit_kinds / keep-all leftovers for method-only chunks; parse failures fall back to line windows for lane-unit langs; _lane_site_edges only queries repo-wide names when rules allow; _scope_dialects_for and code-SQL edges use each file’s named scope from CodeSqlUnits.scope (important for dotted ruby_scope and dialect narrowing).

Docs and plugin copy now describe Ruby as a parsed lane (method chunks, inherits, SQL islands). Operators need the updated code extra and a targeted backfill on existing Ruby paths to replace old text chunks.

Reviewed by Cursor Bugbot for commit 3a3ed66. Bugbot is set up for automated code reviews on this repo. Configure here.

The Ruby lane parses with tree-sitter-ruby. Every parse runs in the bounded
child first, so the child has to load the grammar as well. uv.lock is
regenerated with uv 0.13.12 and keeps lock revision 5.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A Ruby class holds its methods. Cut on every top-level symbol, a class
would be one chunk however many methods it has. With unit_kinds only
symbols of those kinds are units and the class lines stay leftovers.
Lanes that pass none keep the chunks they had.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A .rb file was chunked as text, so code.symbol, code.callers and
code.impact had nothing to return for it. The lane reads classes, modules,
methods, requires, call sites, superclasses and mixins, and the SQL handed
to ActiveRecord. Its chunks and edges come from lane_units because the
shared chunker and edge walker are in the extractor stamp.

lane_units counts lines on LF as the parser does, keeps every Ruby
line that holds text in a chunk, and binds a call inside a SQL string from
the method around it. Its unit and caller lookups take one sweep each, so a
class of many methods stays linear.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The language table, the lane guide, the architecture page and the plugin's
place rule still described Ruby as text.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 6, 2026 5:19am UTC
loom-telemetry Ready Ready Preview Dec 6, 2026 5:19am UTC

Request Review

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/domain/extract/lang_ruby.py Resolved
Comment thread server/code/domain/extract/lang_ruby.py Resolved
Comment thread server/code/domain/extract/lang_ruby.py Resolved
@zlareb1 zlareb1 self-assigned this Dec 4, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The focused Ruby and extractor-stamp suites passed 64 cases. A separate probe reproduces three open findings. The second method loses its function chunk when it starts on the preceding method’s last line, a method installed on an instance is indexed on its class, and a SQL statement in a root-level Ruby file gets a native scope. Chunk · Method owner · SQL scope

…ll site

The tree hangs those words under node types `_VALUE_PARENTS` did not list, so
`in x if allowed`, `rescue retryable => e`, `class A < base`, `lookup::Entry`,
`class << target` and `END { flush }` recorded no site. A pinned `^(expr)` is
read, not bound. Words after `return`, `break`, `next` and `yield` sit in an
argument list and were already sites; the test keeps them.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
In an instance method or a `define_method` block `self` is an instance, so
`def self.x` and `class << self` there define on one object and name no class
method. An eval block defines on its receiver: `Store.class_eval { def x }` is
`Store#x`, `Store.instance_eval { def x }` is `Store.x`, and an eval on a
variable names nothing, as `class << obj` already did.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`_top_level` read a unit starting on the previous unit's last line as nested,
so `end; def second` folded `second` into the first chunk and left its other
lines as an `other` chunk. Such a unit now has its own chunk, sharing that one
line, and a comment above it belongs to the earlier unit. A unit wholly on the
shared line still rides the earlier chunk. The other lane_units lanes cut the
same chunks as before over the 21 lane fixtures and about 3,800 proto, thrift,
gotemplate, hcl, k8s, jsonnet, lua and graphql files.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`code_sql_units` qualified statements and created objects with `module_scope`,
which leaves a root file's scope undotted, so the name gate read them as
native while the file's methods stayed script. The island grammar names the
scope (`ruby_scope` for Ruby) and the units carry it, so the edge stage and
the lane corpus name each statement as the parse did.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`test_no_new_tunable_constant` failed CI on `lang_ruby._MAX_DOC`. Like the
other lanes' cuts it shapes every stored doc_comment, so it carries the
`# not a setting:` reason instead of joining the shrinking list.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…rows

The committed translations check matches table cells by position. Ruby above
the Protocol Buffers row moved that row, so the zh-CN page failed on its
protected names. Below Lua it shifts no row that holds one.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…y it

`_scope_dialects_for` keyed each defining file's dialect by `module_scope`, and
`narrow_by_dialect` looks a candidate up by the scope in its qualified name. A
root Ruby file's table is now `root.<name>::t`, so the two never met. The map
is keyed by each candidate's own scope.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`Point = Struct.new(:x) do def norm; end end` inside `module Geo` indexed
`Geo#norm`, a method Geo does not have. The block's defs are now `Geo::Point`'s,
for `Struct.new`, `Class.new`, `Module.new` and `Data.define` assigned to a
constant. One no constant names holds nothing the index can name, as an eval
on a variable.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…file's other fakes do

A type: ignore on the call hid what the fake stands in for.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`_enclosing_by_line` skipped the statement symbol but not the objects it
creates, which share its span. An interpolated call in `CREATE TABLE` or
`CREATE FUNCTION` bound from the table or the SQL function. The SQL's symbols
follow the lane's own in the parse, statements first, so the walk stops at the
first statement; a one-line method holding a statement keeps its calls.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
At the repository rung `bind_sites` kept the caller among the candidates, so
`class Admin::User < ::User` saw two `User` definitions and bound neither.
Nothing inherits from itself, so an `inherits` site drops the caller there, as
the same-file rung does. The thrift and GraphQL `inherits` rules lose nothing:
a service or interface never names itself.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…ould land

The reader's context said where a plain `def` lands but not what `self` is,
so `class_eval` in a method of `class << self` defined singleton methods. In
that method `self` is the class and Ruby defines instance methods. The context
now names `self` as a class, a singleton class or an instance, and an eval with
no receiver reads it.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
The builder match read the receiver's text, so `::Struct.new` missed, and it
took the name only from a direct `=`. `Frozen = Struct.new do … end.freeze` and
`Lazy ||= Class.new do … end` named nothing. The receiver is read as a constant
and the name is taken through calls chained on the block and `||=`.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…arget

Every word under a `left_assignment_list` became a local, so after
`helper.value, rest = 1, 2` the method `helper` was no site anywhere in the
method and `value` read as a call. The walk binds only plain names, splats and
nested lists, and an attribute or element target is a write whose receiver is
read.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
An island took its line from the string node, which for a heredoc is the
marker. `execute(<<~A, <<~B)` put both statements and the tables they create
on the body of A. The island grammar names the line a string's text runs from,
and Ruby reads a heredoc's from its body. Go and Java keep the node's line.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`reference_sites` ran to four lines and `_scope_dialects_for` to five.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A `CREATE FUNCTION` lifted from a heredoc in a class body is a `function`
symbol, so `span_chunks` cut it out as a unit and split the `execute` call
around it. Units now come from the lane's own symbols, the same cut the caller
sweep makes.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
…hing else

The walk up from a builder followed every chained call, so
`Origin = Struct.new(:x) do … end.new(0)` gave `Origin#o` though `Origin` holds
an instance. It follows only `freeze`, `tap` and `itself`, which return the
class.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Its comment narrated the text lane the Ruby lane replaced.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`_string_line` returned the tree's Any, which the gate counts as a new error.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the probe that reproduced the chunk, method owner and SQL scope findings. Each finding has a test that failed before its fix and passes now. Two review passes over the fixes found the rest of the list below.

  • 71d4660 A bare word in a pattern guard, a rescue list or a superclass is a call site
  • 6df1f9b A method defined on an instance is not indexed as a method of its class
  • 5a85650 A method that starts on the last line of another is its own chunk
  • 4f17b0b The SQL of a root Ruby file is scoped like its methods
  • 896b0b3 The Ruby lane's doc comment cut is marked as no setting
  • b64b8d2 The overview lists Ruby beside Lua so the translated table keeps its rows
  • 7316e3a A root Ruby file's tables keep their dialect when an island narrows by it
  • 0c56bb5 A class built by Struct.new or Class.new holds the methods of its block
  • 8c9db68 The dialect narrowing test passes its fake repository as Any, as the file's other fakes do
  • 8fc9b0d A call inside SQL that creates a table or function binds from its method
  • 3acdaa5 A class named like its base in another file inherits from it
  • db30bc9 An eval without a receiver defines on what self is, not where a def would land
  • 0e06e7c A built class keeps its name through ::Struct, a chained call and ||=
  • 8a1948e A multiple assignment reads the receiver of an attribute or element target
  • 6d3a248 Each heredoc of a call is a statement on its own lines
  • 57650b3 Two docstrings of the lane keep to three lines
  • 5bcbfb7 A SQL function outside a method is no chunk of its own
  • 4005bb2 A built class names nothing when a call after its block returns something else
  • 7aadd3d The chunk coverage test says what holds, not what Ruby files were
  • 84b7446 The heredoc line helper returns an int the mypy gate can check

3acdaa5 is worth a look on its own. At the repository rung bind_sites kept the caller among the candidates, so class Admin::User < ::User with User in another file saw two User definitions and bound neither. An inherits site now drops the caller there, as the same-file rung does. Nothing inherits from itself, so the thrift and GraphQL inherits rules lose nothing.

CI on 16ca9ce had two failures of ours. test_no_new_tunable_constant flagged lang_ruby._MAX_DOC (896b0b3). test_the_committed_translations_pass_check failed on the zh-CN overview table, because the Ruby row shifted the row that holds protected names (b64b8d2). The other failures were _MAX_GENERATION and test_ops_that_cannot_bound_their_answer_are_refused, which come from main and pass since #2156.

Left as they are:

  • X.new binds by bare name, so inside a compact class Admin::User, User.new and ::User.new bind to Admin::User when the file defines it. A site carries no rooted flag.
  • In def Bar.m written inside class Foo, an eval or a def self.x lands on Foo. Ruby puts it on Bar. Fixing it needs a second owner in the reader's context, for a shape the corpus does not hold.
  • module Foo; class Foo::Bar gives Foo::Foo::Bar. Ruby resolves it to Foo::Bar. No file in the corpus has it.
  • A bare it, _1 or named regex capture is a bare site. Those bind only inside their own file.

Tests: test_code_lang_ruby.py has 45 tests and 55 cases. The Ruby lane, every other lane_units lane, the TypeScript islands and the lane lookups ran 181 tests. The Go, Java and Python islands, the lane corpus, its manifest and known gaps, the extractor stamp, lang_text, the kind prior and the plugin query contract ran 277. The doc tests, the tunable constants and tests/analyzer/test_corpus.py -k "not live" gave 306 passed and 2 skipped, and the one failure is main's _MAX_GENERATION. test_the_committed_translations_pass_check passes. The Ruby registry cost walk ran in process with 82 shapes and none over linear. ruff, the function length gate, the mypy gate, check_no_secrets.py and the docs and settings reference checks are clean.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/domain/extract/lang_ruby.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared-line chunk and root SQL scope fixes are present. The relative eval owner finding is reproducible. In Ruby, calling Item.class_eval inside Outer installs the method on Outer::Item. The index currently drops Outer from the owner.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Python SDK adapter job fails during test collection with agent-framework-core 1.26.0 and opentelemetry-api 1.46.0. Clean main fails with the same versions and traceback. A separate PR constrains the incompatible dependency. PR job · Main job · Fix #2164

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception-text gate flags the worker setup preview and register handlers on this run and on its clean base. The same gate passes on current main with the merged fix. Failed job · Fix #2163

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`Item.class_eval`, `def Item.x` and `class << Item` inside `module Outer`
read `Item` as a top-level name, so the methods landed on `Item` and not
on `Outer::Item`. Ruby looks a constant up from the innermost namespace
out. The reader now takes the first namespace whose class this file
defined above the reference, else the innermost one. `::Item` stays the
top level.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`ActiveRecord::Base.class_eval` inside `module MyGem` gave
`MyGem::ActiveRecord::Base#x`. A path whose first name the file does not
define names a library class, so it keeps the name as written. A lone name
the file never defines still takes the innermost namespace. A path whose
first name an enclosing namespace defines resolves from there.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the re-reviews and for tracing the two red jobs back to their base.

Drafted with AI help and reviewed by me manually.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/code/domain/extract/lang_ruby.py Resolved
Comment thread server/code/domain/extract/lang_ruby.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Ruby site walk still puts block parameters in the enclosing method scope and keeps the outer class as the owner inside singleton definitions. Both cases change which call edges the index emits. Block scope · Singleton constructor

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
A block or lambda parameter, and a name the body assigns, were stored as
locals of the enclosing method, so a bare call anywhere in the method was
dropped. A rescue variable did the same. Each now lives in a scope of its
own that its body reads through to the scope around it. A name a rescue
body assigns still belongs to the method.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
`def Const.m` and `class << Const` left the enclosing class as the owner,
so a bare `new` or `self.new` bound to the outer class, or was dropped when
there was none. The site walk now reads the owner from the definition. An
object that is no constant names nothing, and `self` keeps the class around.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
Ruby keeps the name bound in the enclosing scope once the clause has run,
and reads it as a method before the clause. The site walk now drops a bare
read of it from the clause's line on and keeps one above it.

Signed-off-by: Vanshaj Poonia <vanshajtheunique@gmail.com>
@VanshajPoonia

Copy link
Copy Markdown
Contributor Author

Thank you for the review and for naming the two Bugbot threads.

  • 122bf43 gives a block, a lambda and a rescue clause their own local scope (thread above).
  • 3a3ed66 keeps a rescue variable a local after its clause, as Ruby does, and a site above the clause.
  • 8ae3e9d reads the owner of new from def Const.m and class << Const (thread above).
  • 21c6f2a merges main at dff1a26 with no conflicts. uv.lock keeps tree-sitter-ruby beside main's pins. The exception-text ratchet passes on it, and so do the codegen checks, ruff, the function-length gate and the mypy gate.
  • All checks on cb99cf4 were green, plugins on macos-15-intel included (7m7s). Nothing from this PR was red.

Drafted with AI help and reviewed by me manually.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 3a3ed66. Configure here.

sig += f" < {_squash(node_text(sup.named_children[0], self.source))}"
kind = KIND_CLASS if node.type == "class" else KIND_MODULE
self._add(f"{self.scope}::{'::'.join(inner)}", parts[-1], kind, sig, node, doc)
return inner, False, _CLASS

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualified class paths ignore lookup

Medium Severity

_namespace always prefixes class and module paths with the current nesting, unless the path is rooted. class A::B inside module M is stored as M::A::B, even when A is an outer class or a library. _owner looks that same path up from the inside out and, when the file never defines it, keeps it as written. Definitions and later class_eval / def owners then disagree with Ruby, so symbols land on a phantom class.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3a3ed66. Configure here.

self._namespace(node, scope)
name = node.child_by_field_name("name")
parts = _const_parts(name, self.source)[0] if name is not None else []
return node.id, parts[-1] if t == "class" and parts else ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class headers use the new scope

Medium Severity

Entering a class or module switches the site scope to that node before its children are walked, and the new scope has no parent link. The superclass expression is evaluated in the enclosing scope in Ruby, but a bare word there is filtered with the class body's locals. An outer local is reported as a call, and a name assigned in the body hides the superclass word.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3a3ed66. Configure here.

return "mysql"
if "sqlite" in low:
return "sqlite"
return ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parenthesized requires miss SQL dialect

Medium Severity

ruby_file_dialect scans source with a regex that only matches require plus whitespace plus a quote. require("pg"), require "pg" without a space, and %q forms never match, so the file's SQL islands get no postgres, mysql, sqlite, or clickhouse default. The AST include reader already accepts those call shapes.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3a3ed66. Configure here.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current extractor gives qualified class declarations a different owner from constant lookup, and its SQL dialect detection misses parenthesized requires. Please address the verified cases in the class owner thread and SQL dialect thread.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The code index parses Ruby: symbols, calls and inheritance for .rb files

2 participants