Skip to content

Bind the pure-Go rails meta-gem: top-level Rails.* accessors + rails/all - #193

Closed
tannevaled wants to merge 1 commit into
mainfrom
feat/bind-rails
Closed

tannevaled wants to merge 1 commit into
mainfrom
feat/bind-rails

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Layers the pure-Go rails meta-gem (github.com/go-ruby-rails/rails, pinned at 5ddb406) onto the railties binding already merged (Wave 1). The rails gem ships almost no code of its own; it ties the framework components together and vends the top-level Rails module. This binding extends the Rails module registerRailties() created — it does not recreate it or re-register the "rails" feature.

Ruby surface added

  • Top-level Rails.* singleton accessors: application / application=, env / env=, root, public_path, configuration, autoloaders, logger / logger=, cache / cache=, groups, version / gem_version, backtrace_cleaner, error.
  • Rails::VERSION module (STRING/MAJOR/MINOR/TINY/PRE; targets 8.1.3).
  • Rails::EnvironmentInquirer (< Rails::StringInquirer): the Rails.env type, with the dynamic name? predicate and the environment-specific local? (development/test).
  • require "rails/all": added to providedFeatures and wired as a feature hook that triggers a require of every shipped (Available) catalog component whose feature the VM already provides (active_support/active_model/active_job/active_storage/action_cable; components without a provided feature yet are skipped, so the aggregate tracks the catalog as bindings land).

How railties is extended, not duplicated

registerRails() runs immediately after registerRailties() and grabs the existing Rails module (vm.consts["Rails"].(*RClass)), adding the singleton methods, Rails::VERSION and Rails::EnvironmentInquirer onto it. The Railtie/Engine/Application/StringInquirer classes and the "rails"/"rails/railtie"/… features stay owned by railties.

App-seam wiring

Application state (root/public_path/configuration/autoloaders/cache) delegates to the meta-gem, which resolves it against the bound railties Application through its App interface — bridged here by railsAppAdapter (Root/Config/Autoloaders/PublicPath/Cache). Rails.application= records the Ruby wrapper on the VM and threads the underlying railties *Application into rails.SetApplication; Rails.application returns the Ruby *RailsAppVal Ruby set. RailsEnvVal is added to classOf and to hasCustomEq so Rails.env == "production" dispatches the wrapper's == rather than pointer identity.

Verification (all exit 0)

  • go build ./internal/vm/ — OK; orphan scan clean.
  • 100% coverage of the new files (rails_meta.go, rails_meta_bind.go) via -covermode=count.
  • Full suites go test ./internal/vm/ ./internal/object/ -count=1 — both ok (railties tests still green).
  • gofmt -l empty; go vet ./internal/vm/ clean.
  • 6-arch GOOS=linux GOARCH={amd64,arm64,riscv64,loong64,ppc64le,s390x} — all build.

🤖 Generated with Claude Code

Layer github.com/go-ruby-rails/rails onto the railties binding already in
place. The `rails` gem ships almost no code of its own: it ties the framework
components together and vends the top-level Rails module. This extends the
Rails module registerRailties created (never recreating it) with:

- The singleton accessors: Rails.application / application=, env / env=,
  root, public_path, configuration, autoloaders, logger / logger=,
  cache / cache=, groups, version / gem_version, backtrace_cleaner, error.
- Rails::VERSION (STRING/MAJOR/MINOR/TINY/PRE; targets 8.1.3) and
  Rails::EnvironmentInquirer (< Rails::StringInquirer) so Rails.env.production?
  and Rails.env.local? read naturally.
- require "rails/all", wired as a feature hook that triggers a require of
  every shipped (Available) catalog component whose feature the VM provides.

Application state (root/public_path/configuration/autoloaders/cache) delegates
to the meta-gem, which resolves it against the bound railties Application
through its App seam, bridged by railsAppAdapter. Rails.application keeps
returning the Ruby Application wrapper (*RailsAppVal) Ruby registered.

RailsEnvVal is added to classOf and to hasCustomEq (so `Rails.env ==
"production"` dispatches the wrapper's == rather than pointer identity).
"rails/all" is added to providedFeatures; "rails" stays owned by railties.

100% coverage of the new files; full internal/vm + internal/object suites
green; gofmt/vet clean; builds on all six 64-bit Linux arches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tannevaled

Copy link
Copy Markdown
Contributor Author

Superseded by the wave-2 consolidation PR (single merge onto main; shared builtins/require/object_model/vm/arith/digest_bind). Work preserved verbatim; branch kept for reference.

@tannevaled tannevaled closed this Jul 6, 2026
tannevaled added a commit that referenced this pull request Jul 6, 2026
…ils (#197)

Completes the Rails-core stack (batch 4 = 11 bindings across waves 1+2). require "rails/all" now boots the component set. Supersedes #193-196.
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