Skip to content

feat(extraction): index Solidity (.sol) at the extraction tier - #151

Merged
sunerpy merged 1 commit into
mainfrom
feat/upstream-1.4.1-defer-h2-solidity
Jul 14, 2026
Merged

sunerpy merged 1 commit into
mainfrom
feat/upstream-1.4.1-defer-h2-solidity

Conversation

@sunerpy

@sunerpy sunerpy commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Upstream-sync DEFER item H2 — adds Solidity (.sol) as a first-class Tier-1 extraction language (colby #1170), via the tree-sitter-solidity = "1.2.13" crates.io grammar (no vendored grammar). .sol files now index contracts/libraries/interfaces, structs, enums, functions, modifiers, constructors/fallback/receive, state variables, events, errors, imports, call edges, and is inheritance.

  • Language::Solidity variant + .sol mapping; SOLIDITY_SPEC maps the contract/library/interface containers to class-like symbols with synthetic names for the AST-nameless constructor/fallback/receive; store parse_language learns "solidity"; dedicated solidity golden fixture.
  • Six Solidity-guarded walker extensions for AST shapes tree-sitter-solidity spells differently from C-family grammars: is-inheritance specifiers, direct-name fields on state variables/struct members, leaf enum_value members, header-position modifier invocations (emitted as Calls, not Decorates), top-level constants, and file-level free events/errors — each gated to Solidity so no other language's extraction changes.
  • Nothing deferred: upstream is entirely extraction; the implements-reclassification (Extends→Implements) + import resolution ride the existing resolver.

Verification

  • make ci green (fmt + clippy + test + guardrail); cargo test --workspace 0 failed.
  • Named tests: sol_maps_to_solidity, solidity_contract_is_records_extends, solidity_constructor_fallback_receive_synthetic_names-equivalents, solidity_modifier_guard_is_call, solidity_file_level_event_error_are_fields + ..._do_not_double_emit_inside_contract, enum round-trip at 38, solidity golden self-equivalence + committed-match, schema_parity green.
  • Existing 7 goldens (cpp/godot/ruby/mini/metal/cuda/arkts) byte-identical, NO regen; .schema unchanged (language is a stored TEXT value, not DDL). Post-resolution golden shows resolved Implements Token→IERC20 + resolved Calls, no unresolved refs for resolved targets.
  • No vendored grammar; guardrail clean; Cargo.lock gains only tree-sitter-solidity.
  • Independent momus review: APPROVE.

DEFER item H2 of the 1.2.0→1.4.1 upstream sync. Remaining: Nix, HCL/Terraform, Erlang, CFML (gated); COBOL + VB.NET deferred (no crates.io grammar).

Ports upstream colby Solidity support (#1170). `.sol` files now index their
contracts, libraries, interfaces, structs, enums, functions, modifiers,
constructors/fallback/receive, state variables, events, errors, imports, call
edges, and `is` inheritance as a first-class Tier-1 language, via the
tree-sitter-solidity crates.io grammar (no vendored grammar).

Adds the Language::Solidity variant, the `.sol` extension mapping, a
SOLIDITY_SPEC mapping the grammar's contract/library/interface containers to
class-like symbols with synthetic names for the AST-nameless constructor,
fallback, and receive callables, the store language parser arm so an indexed
`.sol` file round-trips through the DB, and a dedicated solidity golden fixture.

Six Solidity-guarded walker extensions cover the AST shapes tree-sitter-solidity
spells differently from the C-family grammars: `is`-inheritance specifiers, the
direct-`name` fields on state variables and struct members, leaf `enum_value`
members, header-position modifier invocations (emitted as calls, not
decorations), top-level constants, and file-level free events and errors — each
gated to Solidity so no other language's extraction changes. Contract-to-
interface inheritance rides the existing resolver, which promotes the extracted
Extends to Implements.

There is no framework-resolution bridge to defer: the upstream extractor is
entirely extraction, and its implements reclassification and import resolution
ride machinery this port already has. The language enum is a stored TEXT value,
not DDL, so the golden .schema is unchanged and the seven existing golden
fixtures are byte-identical (no regen); only the new solidity fixture is added.
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.43705% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/codegraph-extract/src/lang/solidity.rs 94.93% 11 Missing ⚠️
crates/codegraph-extract/src/walker.rs 97.95% 4 Missing ⚠️

Impacted file tree graph

@@           Coverage Diff            @@
##             main     #151    +/-   ##
========================================
  Coverage   95.49%   95.50%            
========================================
  Files         119      120     +1     
  Lines       58414    58834   +420     
========================================
+ Hits        55783    56189   +406     
- Misses       2631     2645    +14     
Files with missing lines Coverage Δ
crates/codegraph-core/src/types.rs 100.00% <100.00%> (ø)
crates/codegraph-extract/src/engine.rs 95.66% <100.00%> (+0.02%) ⬆️
crates/codegraph-extract/src/lang/mod.rs 100.00% <100.00%> (ø)
crates/codegraph-store/src/queries.rs 98.19% <100.00%> (+<0.01%) ⬆️
crates/codegraph-extract/src/walker.rs 92.65% <97.95%> (+0.27%) ⬆️
crates/codegraph-extract/src/lang/solidity.rs 94.93% <94.93%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sunerpy
sunerpy merged commit beebae7 into main Jul 14, 2026
7 checks passed
@sunerpy
sunerpy deleted the feat/upstream-1.4.1-defer-h2-solidity branch July 14, 2026 18:59
sunerpy added a commit that referenced this pull request Nov 19, 2026
…rates

Rust projects had no routes in the index and no framework edges. A
resolver named `rust` now ports upstream's Rust resolver from `rust.ts`
and its Cargo workspace crate map from `cargo-workspace.ts` as they
stand at e8ddc4e2.

Rust is detected by a root Cargo.toml, read whether or not it is
indexed. A manifest below the root, a workspace member's or a
fixture's, detects nothing.

Routes come from three forms, read on comment-stripped text: attribute
routes (actix's and rocket's #[get("/users")]), each referencing the
next fn; axum's .route("/users", get(a).post(b)), one route for each
method router at the call's top level, none for a get( inside a closure
handler; and actix's builder API, web::resource("/p") chains with
web::METHOD().to(h) and an ANY route for a leading .to(h), and App-level
.route("/p", web::get().to(h)). An axum or builder route stays on its
.route line, and its reference to the handler sits where the handler's
last segment is written (#2359), so the scope rule reads the handler's
own line.

References resolve by upstream's conventions through the shared name
heuristic (#2225): a ..._handler or handle_... function, a ...Service or
...Repository struct or trait, and a CamelCase model struct, each
preferring its conventional folders; and a lowercase name as a module,
the root's src/<name>.rs or src/<name>/mod.rs, else a workspace crate's
src/lib.rs or src/main.rs. The heuristics take only a name the Rust
scope rule lets the reference see (#2224, and #2214's framework half):
no item inside a function body, and no project item where the name is
an outside crate's import or a path through one.

The crate map (#151) reads the root manifest's [workspace] members,
expands glob members through a directory listing the resolution
contexts now offer, and maps each member's [package] name and its `_`
alias to the member's directory.

The module rule links a file node, which no reference's name reaches,
so a sync that adds or removes a root module or a crate root retries
the references named for it: unresolved ones by name, resolved ones at
their sites. So does a sync that keeps one whose file node comes or
goes: a file over max_file_size stays tracked without any node. A new
marker, rust_crate_roots_version, makes a sync that finds it missing
re-resolve every Rust file. The workspace's manifests are the Rust
control kind's inputs.

Kept Rust behavior, recorded in KNOWN_DIFFS:
- a convention whose pick declines ends the chain, the module rule's
  too, where upstream tries the next rule only when no candidate exists;
- a module is its file node, where upstream takes the file's first node;
- a workspace's members stay inside the project: an absolute member
  (`/` included) or one leaving the root, and a glob whose static
  prefix is one, are neither read nor listed; a glob's walk is sorted,
  a name two members give names neither, and a glob reads the
  picomatch forms a Cargo workspace writes;
- a builder route's handler column is a byte column, as the Rust scope
  rule reads it.

The goldens are unchanged, every corpus identical under
scripts/regen-goldens.sh --check: no golden fixture has a root
Cargo.toml (the servers corpus keeps its axum/ and actix/ manifests one
level down), so none detects Rust.

Precision: 78 of 84 corpora index identically. This repository's
snapshot, tokio, realworld-axum-sqlx, axum, actix/examples and
crates.io differ; git detects Rust and is unchanged. The four corpora
#2359 validated link as many routes to handlers as it reported at the
same commits: 19, 204, 116 and 5. 2288 `use` declarations of workspace
crates now import the crate's root file, 4 of them for a registry
crate named like a member, and 3755 references keep their targets at
the conventions' confidence. Of 453 references that move, 389 reach
the declaration the name means, among them 279 `&Store` parameters
here that leave the core crate's trait for the store's struct, and 9
are wrong before and after. 55 move away from the right target, as
upstream's rules move them: a model struct wins a tie with name
matching (17) or outranks it (2), and the model rule answers
`implements`, so crates.io's 36 `impl BackgroundJob for` leave the
worker trait for a struct of that name and the 36 trait-dispatch calls
synthesized from them go. The module rule also newly links 12
lowercase names in crates.io to root module files they do not mean:
builder calls such as `.config(`, the registry `sentry` crate and a
member's own `cloudfront` module.

On a CI runner, init, sync and peak memory stay within the performance
lines on the seven measured workloads across five corpora. Re-syncing
an edited actix-examples main.rs takes 1.12 times as long as before,
an edited axum routing test 1.10 times, and an edited Cargo.toml 1.03
(tokio-stream) and 1.06 (axum-extra) times.
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.

1 participant