Skip to content

Rust: Implement herb-analysis crate based on Rubydex - #1993

Draft
marcoroth wants to merge 7 commits into
mainfrom
herb-analysis-rust
Draft

Rust: Implement herb-analysis crate based on Rubydex#1993
marcoroth wants to merge 7 commits into
mainfrom
herb-analysis-rust

Conversation

@marcoroth

@marcoroth marcoroth commented Aug 4, 2026

Copy link
Copy Markdown
Owner

This pull request adds an exploratory herb-analysis crate that evaluates rubydex as a backend for Herb's cross-file static analysis. This crate is currently considered a spike. It is marked publish = false and might be folded, deleted, or moved into another part of the codebase.

Motivation

#1667 implements Action View template dependency analysis in Ruby. Its weakest part is helper and constant resolution: scan_helpers! flat-scans every def in app/helpers/**/*.rb, so it misses gem-provided helpers like pagy_nav and turbo_frame_tag, misses helpers reaching the view through included concerns, and records constants as a naive "#{receiver}.#{name}" with no namespace resolution. That drives the unknown_calls warnings.

The question worth answering is what rubydex enables in Rust rather than in Ruby.

What it does

The crate wraps rubydex's ID-based Graph API and exposes the experiments as subcommands:

helpers   [path] [--only app,gem,rails,route]    what a template can call, grouped by origin
          [--roots A,B]
audit     [path] [--gem G]                       cross-check the Action View helper registry
ancestors <Name> [path] [--built-ins]            ancestor chain + completeness
constants [NAME] [--nesting A::B] [path]         list constants, or resolve one
stats     [path]                                 counts and per-phase timings

helpers reconstructs everything a template in an arbitrary Rails app can call, grouped by origin. It resolves gems from Gemfile.lock across all three source types (registry, git checkouts including monorepo subdirectories, and path sources), discovers helper modules by the include_all_helpers convention that no static index can infer from code, walks ActionView::Base for the built-ins, reads helper_method declarations off controllers, and derives route helpers from config/routes.rb.

 Helpers (6061 files, 173 gems, 86 helper modules)

   app (94)
   gem (320)
   rails (340)
   route (630, approximate)

   1384 total

   97 locked gems are not installed for this Ruby, so their helpers are missing.

Related #1667

@github-actions github-actions Bot added rust Rust bindings and the Herb Rust crate action-view-helpers Action View helper support and metadata labels Aug 4, 2026
marcoroth and others added 2 commits August 4, 2026 14:39
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Marco Roth <marco.roth@intergga.ch>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit c4ac12d

@pkg-pr-new

pkg-pr-new Bot commented Aug 4, 2026

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1993
npx https://pkg.pr.new/@herb-tools/language-server@1993
npx https://pkg.pr.new/@herb-tools/linter@1993

commit: c4ac12d

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

Labels

action-view-helpers Action View helper support and metadata rust Rust bindings and the Herb Rust crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants