mir-backend-rubylisted
Install: claude install-skill anantbhandarkar/make-it-right
# /mir-backend-ruby · Make It Right (Ruby runtime)
The middle tier. `mir-backend` decides **what is correct** (any language). The framework module (e.g. `mir-backend-ruby-rails`) knows the **library's mechanics**. This tier owns what's true for **all Ruby backends because they run on YARV (MRI)** — the concurrency model and process model that Rails, Sinatra, Hanami, and Sidekiq all inherit.
**Runtime assumed:** MRI Ruby 3.3+ running under Puma. Notes hold for JRuby except where GVL specifics differ (JRuby has no GVL; true thread parallelism is available). Load order: `mir-backend` → `mir-backend-ruby` → `<framework module>`.
## The YARV footguns AI walks into (framework-agnostic)
### 1. The GVL — threads are NOT CPU parallelism
Ruby's Global VM Lock (GVL, formerly GIL) allows only one thread to execute Ruby bytecode at a time. **CPU-bound work does not run in parallel across threads** — multiple threads serialize on the GVL and you pay context-switch overhead on top.
- **CPU-bound** (image processing, crypto, heavy computation): use multiple **processes** (Puma workers), a C extension that releases the GVL (`mini_magick`, `bcrypt`, `openssl` release it internally), or offload to a dedicated service / background worker. Adding more threads will not help — it will make things worse.
- **I/O-bound** (DB queries, HTTP calls, disk reads): threads are fine — the GVL releases during blocking I/O syscalls, so other threads run while one waits.
- This is the runtime-level reason