← ClaudeAtlas

mir-backend-rustlisted

Make It Right (Rust runtime tier). Async Rust on Tokio runtime reliability footguns that are shared across EVERY Rust backend framework (Axum, Actix-web, Warp, Poem) — distinct from the generic backend gates and from any one framework's mechanics. Covers: blocking the async runtime (std::thread::sleep / blocking I/O inside async tasks starves Tokio worker threads), holding a std::sync::MutexGuard across an .await point (compile error or deadlock), cancellation safety (futures dropped at any .await under timeout/select!/disconnect leaving partial state), panic-poisoned Mutexes, Arc-based shared state with 'static bounds on spawned tasks, bounded vs unbounded channels for backpressure, and timeout discipline on every outbound call. TRIGGER when the backend runtime is Rust — sits between mir-backend (generic) and the framework module (e.g. mir-backend-rust-axum). SKIP for Python/Node/JVM/Go/.NET/Ruby/PHP/BEAM runtimes (each has its own mir-backend-<runtime> tier), and for framework-library mechanics (those live
anantbhandarkar/make-it-right · ★ 12 · AI & Automation · score 85
Install: claude install-skill anantbhandarkar/make-it-right
# /mir-backend-rust · Make It Right (Rust runtime) The middle tier. `mir-backend` decides **what is correct** (any language). The framework module (e.g. `mir-backend-rust-axum`) knows the **library's mechanics**. This tier owns what is true for **all Rust async backends because they run on Tokio** — the concurrency model and ownership rules that Axum, Actix-web, Warp, and Poem all inherit. **Runtime assumed:** async Rust on Tokio (current-thread or multi-thread scheduler). The notes hold for any Tokio-based framework. Load order: `mir-backend` → `mir-backend-rust` → `<framework module>`. ## The Tokio async Rust footguns AI walks into (framework-agnostic) ### 1. DON'T BLOCK THE ASYNC RUNTIME Tokio runs async tasks on a fixed pool of worker threads (by default, one per CPU core). A blocking call on any of those threads **stalls every task scheduled to that thread** — the async "event loop" analog. Blocking operations that must never appear inside an `async fn` on a Tokio thread: - `std::thread::sleep` → use `tokio::time::sleep` - Synchronous file I/O (`std::fs::read`, `std::fs::write`) → use `tokio::fs` or `spawn_blocking` - Blocking DB or socket calls (any sync driver, e.g. `postgres` crate's sync API) → use async driver (`sqlx`, `tokio-postgres`) or `spawn_blocking` - Heavy CPU computation (hashing, encoding, ML inference, large sort) — blocks a Tokio thread even though it's "not I/O" → use `tokio::task::spawn_blocking` (runs on a separate blocking thread pool) or a de