Skip to content

refactor: Model the hosting platform with per-platform classes - #275

Merged
adamlogic merged 3 commits into
mainfrom
platform-refactor
Jun 11, 2026
Merged

adamlogic merged 3 commits into
mainfrom
platform-refactor

Conversation

@adamlogic

@adamlogic adamlogic commented Jun 9, 2026 •

Copy link
Copy Markdown
Member

Summary

Follows up on @carlosantoniodasilva's suggestion in #273: model the hosting platform as a first-class concept instead of a bare "runtime container" string, and put platform-specific behavior on the platform classes that actually have those concepts.

  • Replace Config::RuntimeContainer (a String subclass) with a Judoscale::Platform hierarchy detected from the environment via Platform.detect.
  • Platform-specific checks live on the platforms that have them: Heroku and Scalingo implement redundant_instance?/one_off?; opaque-id platforms (Render, Fly, Ecs, Railway, Custom, Unknown) inherit no-op defaults. This removes the old reliance on a shared regex that only coincidentally didn't match opaque instance ids — those platforms now simply can't be misclassified as redundant or one-off.
  • Config#current_runtime_container is replaced by Config#current_platform (the container id is current_platform.container, still reported under the container JSON key). The old accessor was undocumented and effectively internal, so it's removed rather than shimmed.
  • Drop the \d{1,3} ordinal-width cap now that detection already proves the platform is Heroku/Scalingo; \d+ also correctly classifies formations with 1000+ instances.

Test plan

  • bundle exec rake test (judoscale-ruby): 110 runs, 0 failures
  • bundle exec rake test (judoscale-rails): 7 runs, 0 failures
  • standardrb clean on changed files
  • CI green across adapter gems

Made with Cursor


Note

Medium Risk
Changes how job metrics are skipped on redundant dynos and how platforms are detected; behavior is meant to stay equivalent but affects core reporting paths and removes the internal current_runtime_container API.

Overview
Replaces the string-based Config::RuntimeContainer with a Judoscale::Platform model detected via Platform.detect(ENV). Config#current_platform holds the detected platform; the reported container value is current_platform.container (unchanged JSON shape).

Heroku and Scalingo now own redundant_instance? and one_off?; opaque-id platforms (Render, ECS, Fly, Railway, Custom, Unknown) default both to false instead of inferring from shared container-string regexes. Render also supplies default_api_base_url when JUDOSCALE_URL is unset (legacy adapter URL). Ordinal redundancy matching drops the old 3-digit cap in favor of \d+ (e.g. web.1000 counts as redundant).

Call sites switch from current_runtime_container to current_platform for job metric collection gating, one-off Rails reporting skips, and report payloads. The undocumented current_runtime_container accessor is removed without a shim.

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

adamlogic and others added 2 commits June 9, 2026 17:09
Replace Config::RuntimeContainer with a Platform hierarchy detected from the
environment. Platform-specific checks (redundant_instance?, one_off?) now live
on the platforms that have them (Heroku, Scalingo); opaque-id platforms
(Render, Fly, Ecs, Railway, Custom, Unknown) inherit no-op defaults, instead of
re-deriving behavior from the shape of the container string.

Config#current_runtime_container is replaced by Config#current_platform (the
container id is current_platform.container).

Co-authored-by: Cursor <cursoragent@cursor.com>
The service-id prefix stripping is Render-specific, so it belongs on the Render
class rather than in Platform.detect. Behavior is unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
@adamlogic
adamlogic marked this pull request as ready for review June 9, 2026 21:28

@carlosantoniodasilva carlosantoniodasilva 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.

❤️💜💛💚💙

Comment thread judoscale-ruby/test/config_test.rb Resolved
Comment thread judoscale-ruby/lib/judoscale/config.rb Resolved
Co-authored-by: Carlos Antonio da Silva <carlosantoniodasilva@gmail.com>
@adamlogic
adamlogic merged commit 26d2486 into main Jun 11, 2026
124 checks passed
@adamlogic
adamlogic deleted the platform-refactor branch June 11, 2026 15:06
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.

2 participants