# rust host migration

> Engine note from the Rove documentation: https://docs.rove.wtf/notes/rust-host

The default `rust-host` feature selects the Rust engine and persistent host. It skips
the old C++ engine build entirely. The official Luau VM and compiler remain
in C++; their Rust boundary and ABI checks live in `rust-runtime-sys`.
No Python process is used by this runtime or its build path.

The Rust host owns world handles, local properties, typed values, services,
signals, the task scheduler, script/module lifecycles, Actor VMs and their
local mutations, remote-call routing, input, GUI layout and hit-testing,
Drawing objects, animation/tweens, 3D pathfinding, spatial and
connected-assembly queries, file/console/crypto helpers and network I/O.
Instance selectors/default resets, engine settings globals, and the local
Player.Idled timer also run in Rust. Local primitive mass uses the part's
current size, shape and material, while absent received properties remain
unavailable.
The existing Rust transport, received-world storage, physics solver and
browser frontend use the same bounded host request/response protocol.

`Raycast`, `Blockcast`, `Spherecast`, `Shapecast`, `GetPartBoundsInBox`,
`GetPartBoundsInRadius`, `GetPartsInPart` and `ArePartsTouchingOthers` use
occupied primitive and decoded mesh geometry, with current-world updates,
`RaycastParams` / `OverlapParams` (`:AddToFilter` and separated per-type
fields), hypothetical poses and shape growth. Sparse `4x4x4`-stud `Terrain`
voxels (`WorldToCell`, `WorldToCellPreferSolid`, `WorldToCellPreferEmpty`,
`CellToWorld`, `CellCenterToWorld`, `FillBlock`, `FillBall`, `FillCylinder`,
`FillWedge`, `FillRegion`, `ReplaceMaterial`, `ReadVoxels`, `WriteVoxels`,
`Clear` and `CountCells`, `0 B` idle RAM when unused) participate directly in
3D DDA raycasts (honoring `IgnoreWater`), shape sweeps, spatial overlap
queries and local physics collisions.
See [part collision queries](https://docs.rove.wtf/notes/spatial-queries.md) for supported geometry and limits.

`PathfindingService` (`CreatePath`, `FindPathAsync`, `ComputeRawPathAsync`,
`ComputeSmoothPathAsync`) and `Path` (`ComputeAsync`, `GetWaypoints`,
`CheckOcclusionAsync`, `Status`, `Blocked`, `Unblocked`) run a bounded 3D
multi-layer grid A* solver in Rust over non-materialized `Workspace`
collidable `BasePart`s (`Block`, `Ball`, `Cylinder`, `WedgePart`,
`CornerWedgePart`), `Terrain` voxels/meshes and `PathfindingModifier`
zones. Paths support step climbing, `TrussPart` climbing (`AgentCanClimb`),
parabolic jump arcs (`AgentCanJump`), line-of-sight smoothing and
`WaypointSpacing` subdivision, with GC-pruned `Path` instance bounds.

Client-local service bindings cover `ContextActionService` (`BindAction`,
`BindActionAtPriority`, `UnbindAction`, `UnbindAllActions`,
`GetBoundActionInfo`, `GetAllBoundActionInfo`, touch-button metadata and
`GetButton`), `Selection` (`Get`, `Set`, `Add`, `Remove`, `SelectionChanged`),
`SoundService` (reverb/doppler/rolloff properties and `PlayLocalSound`),
`ProximityPromptService` (visibility/enabled state and prompt/hold signals
paired with `fireproximityprompt`, `fireclickdetector`, `firetouchinterest` and
`firetouchtransmitter`), `TeleportService` (`Teleport`,
`TeleportToPlaceInstance`, `TeleportToPrivateServer`, `TeleportAsync`,
`TeleportPartyAsync`, `GetLocalPlayerTeleportData`, `SetTeleportSetting`,
`GetTeleportSetting`, `SetTeleportGui`, `GetTeleportGui`, `TeleportOptions` and
bounded `teleport_requests` effects), `MarketplaceService`
(`UserOwnsGamePassAsync`, `PlayerOwnsAsset`, `PlayerOwnsBundle`,
`GetProductInfo`, `GetDeveloperProductsAsync` and purchase prompt signals),
`BadgeService` (`UserHasBadgeAsync`, `GetBadgeInfoAsync`), `GroupService`
(`GetGroupsAsync`, `GetGroupInfoAsync`), `Lighting` (`GetMinutesAfterMidnight`,
`SetMinutesAfterMidnight`, bidirectional `ClockTime` / `TimeOfDay` sync,
`GetSunDirection`, `GetMoonDirection`, `GetMoonPhase`), `Chat`
(`FilterStringAsync`, `FilterStringForBroadcast`, `CanUserChatAsync`,
`CanUsersChatAsync`, `Chat`), `SocialService` (`CanSendGameInviteAsync`,
`PromptGameInvite`), `AvatarEditorService` (`SearchCatalog`), `PhysicsService`
(collision-group registration and collidability), `PolicyService`
(`GetPolicyInfoForPlayerAsync`), `UserService` (`GetUserInfosByUserIdsAsync`
over live `Players`), `Players` / `Player` (`GetNetworkPing`, `IsFriendsWith`,
`IsInGroup`, `GetRankInGroup`, `GetRoleInGroup`, `HasAppearanceLoaded`,
`ClearCharacterAppearance`, `OnTeleport`), `DataModel` (`BindToClose`,
`GetJobsInfo`, `GetObjects`, `HttpGet`/`HttpGetAsync`, `HttpPost`/`HttpPostAsync`),
`Workspace` (`GetServerTimeNow`,
`GetRealPhysicsFPS`, `GetNumAwakeParts`, `DistributedGameTime`,
`FallenPartsDestroyHeight`, `StepPhysics`), `LogService` (`MessageOut`,
bounded `GetLogHistory`, `ClearOutput`), `Debris` (`AddItem` tick queue),
`StarterGui` (`SetCoreGuiEnabled`, `GetCoreGuiEnabled`, `CoreGuiChangedSignal`,
`SetCore`, `GetCore`), `GuiService` (`GetScreenResolution`, `SelectedObject`,
`AutoSelectGuiEnabled`, insets/mutators), `CollectionService` (non-materializing
tag queries) and `HttpService` (`JSONEncode`, `JSONDecode`, RFC 4122 v4
`GenerateGUID`, RFC 3986 `UrlEncode`).

Bounded in-VM physics simulation (`local_physics.rs`) exposes
`WorldRoot:StepPhysics(dt, parts?)` (and executor globals `stepphysics`,
`setphysicsenabled` and `isphysicsenabled`) alongside an `O(1)` zero-allocation
idle fast exit during per-frame stepping. When active, it steps unanchored
rigid welded assemblies, legacy `BodyMover`s (`BodyVelocity`, `BodyPosition`,
`BodyGyro`, `BodyForce`, `BodyThrust`, `BodyAngularVelocity`), modern mover and
mechanical constraints (`LinearVelocity`, `VectorForce`, `AlignPosition`,
`AlignOrientation`, `AngularVelocity`, `Torque`, `SpringConstraint`,
`RopeConstraint`, `RodConstraint`, `HingeConstraint`, `PrismaticConstraint`,
`NoCollisionConstraint`), standalone `Humanoid`
controllers (`Move`, `MoveTo` with `MoveToFinished`, `Jump`, zero-gravity
`Flying`), `CustomPhysicalProperties` restitution bounce and Coulomb friction,
static/dynamic AABB and sparse `Terrain` voxel collisions,
`Workspace.FallenPartsDestroyHeight` void cleanup, and `Touched`/`TouchEnded`
signals. `BasePart` and `Model` also support `ApplyImpulse`,
`ApplyAngularImpulse`, `ApplyImpulseAtPosition`, `GetJoints`, `BreakJoints`,
`CanCollideWith` and `Resize`, while `Tool` (`Activate`, `Deactivate`,
`Equipped`/`Unequipped`, bidirectional `Grip` basis sync) and `Humanoid`
(`TakeDamage` honoring `ForceField`, `EquipTool`, `UnequipTools`,
`GetAccessories`, `AddAccessory`, `RemoveAccessories` and `FloorMaterial`)
cover character equipment and accessories. Character and
model transforms decode all 24 wire `rotation_id` shorthands and 6-byte packed
quaternions, Gram-Schmidt orthonormalize `f32`-drifted rotations, support R6
`Torso`/`UpperTorso` root fallbacks, forward `BodyVelocity`/`LinearVelocity`
fly intents to live character prediction, and preserve local overrides when
bringing remote characters.

Value and container parity includes `CFrame` (`lookAt`, `lookAlong`,
`fromRotationBetweenVectors`, `fromMatrix`, `fromAxisAngle`, ordered Euler
angles, `Orthonormalize`, quaternion SLERP `Lerp`), `Color3` (`fromRGB`,
`fromHSV`, `fromHex`, `ToHSV`, `ToHex`, `Lerp`), `UDim` / `UDim2` (`fromScale`,
`fromOffset`, `Lerp`), `BrickColor` (128-entry Studio palette, named
constructors, `palette`, `random`), `Ray` (`Origin`, `Direction`, `Unit`,
`ClosestPoint`, `Distance`), `Rect`, `NumberRange`, `CatalogSearchParams`,
`PathWaypoint`, `PhysicalProperties` and `SharedTable` (`#` length,
generalized Luau iteration, `new`/`clone`/`cloneAndFreeze`/`clear`/
`increment`/`size`/`isFrozen`/`update`, plus `SharedTableRegistry` across
Actor VMs with `Arc`-shared backing buffers). `TweenService:Create`
interpolates `UDim`, `UDim2`, `Rect`, `NumberRange`, `Vector2`, `Vector3`,
`Vector2int16`, `Vector3int16`, `Color3`, `CFrame`, booleans and numbers.

[Model pivots and bounds](https://docs.rove.wtf/notes/model-pivots.md) now use Rust as well. GetPivot,
GetBoundingBox, GetExtentsSize and PivotTo account for primary-part offsets,
automatic versus explicit model pivots, nested geometry and cached relative
transforms. Authored moves commit before callbacks and merge atomically from
Actor VMs.

[Camera projection](https://docs.rove.wtf/notes/camera-projection.md) uses the host display, device/core
insets and each camera's current pose and lens. Perspective projection and
screen rays, `GetPartsObscuringTarget` wallchecks, `GetLargestCutoffDistance`
Poppercam occlusion, `GetRenderCFrame`, `PanUnits`/`TiltUnits`/`Zoom`,
`Interpolate`, active/inactive viewport state, FOV modes and atomic lens edits
run in Rust without materializing untouched `ProjectedNode` stubs and propagate
to Actor VMs. `PlayerGui` and `CoreGui` expose
`BasePlayerGui:GetGuiObjectsAtPosition`, honoring visibility, rotation,
`ClipsDescendants`, `UIScale`, `UISizeConstraint`, `UIAspectRatioConstraint`,
`UIListLayout`, `UIGridLayout`, `UIPageLayout` and `UITableLayout`.

Actors keep separate Luau states and share the configured aggregate VM
memory budget, with Parallel Luau thread state (`task.desynchronize`,
`task.synchronize`, `isparallel`), `getactors`, `run_on_actor`, and cross-VM
`create_comm_channel` / `get_comm_channel` `BindableEvent` bridges. Their
remote request IDs are routed back to the issuing VM;
unknown or mismatched responses do not complete a waiter. World metadata
changes emit the same service and loaded-state signals as the old host.

[Editable animation curves](https://docs.rove.wtf/notes/animation-curves.md) provide scalar, rotation,
vector and Euler-rotation key editing and sampling in Rust. Clones retain
independent edits, and Actor commands reject stale curve state.

[Model scaling](https://docs.rove.wtf/notes/model-scaling.md) adds absolute ScaleTo/GetScale, original-value
restoration, clone baselines, dimensional force/constraint rules, and atomic
Actor replay. Animator pose scaling remains an explicit unsupported case.

| Area | Rust source |
| --- | --- |
| Persistent VM host, frame pacing and task scheduling | `rust-client/src/rust_host/session.rs`, `frame_phases.rs`, `scheduler.rs` |
| Instances, properties, world updates and services | `world.rs`, `world_nodes.rs`, `world_node_entry.rs`, `services.rs`, `interactions.rs`, `render_steps.rs` |
| Typed values, `CFrame`, palettes and `SharedTable` | `cframe.rs`, `numeric.rs`, `value_types.rs`, `sequences.rs`, `misc_values.rs`, `temporal.rs`, `shared_tables.rs` |
| Events, callbacks, scripts, bytecode and Actors | `signals.rs`, `remotes.rs`, `lifecycle.rs`, `script_bytes.rs`, `decompile_binding.rs`, `actors.rs` |
| Movement, local physics, spatial queries, pathfinding, input and playback | `movement.rs`, `local_physics.rs`, `part_velocity.rs`, `geometry.rs`, `geometry_part_queries.rs`, `pathfinding.rs`, `input.rs`, `playback.rs` |
| Camera projection, GUI hit-testing and Drawing | `camera.rs`, `gui.rs`, `drawing.rs` |
| Closures, GC filtering, simulation/property helpers and VM inspection | `closures.rs`, `instance_helpers.rs`, `raw_vm_debug.rs`, `vm_closures.rs`, `instance_cache.rs` |
| Portable font shaping and text layout | `rust-client/src/engine_services/local_text.rs`, `text_shaping.rs` |
| Workspace files, compression, crypto and network bindings | `source_helpers.rs`, `source_crypto.rs`, `host_io_bindings.rs` |
| Official VM compilation and ABI checks | `rust-runtime-sys` |

All short module paths in this table are under `rust-client/src/rust_host`.

TextService and GUI text measurement use HarfRust and the selected content
directory on every platform. Synchronous GUI layout and asynchronous service
requests share one runtime's font provider, with separate measurement caches
for separate runtimes. `TextBounds` and `TextFits` account for wrapping, padding,
UIScale and bounded TextScaled fitting; automatic sizing uses the same font
advances. This measures text; it does not rasterize glyphs.

The backend uses Unicode bidi, script itemization and line-break opportunities,
and keeps graphemes together during emergency wrapping. It retains at most eight
font faces and 2 MiB of cached font file bytes; synchronous measurement entries
are capped at 128 entries / 512 KiB. A request accepts at most 4 KiB of text,
128 rich-text runs, 16 font variants and 8 MiB of font file data, with bounded
shaping work. These are component limits, not total-process RAM limits.
Missing families/faces/glyphs return errors.

VM-local `Drawing` (`Line`, `Text`, `Image`, `Circle`, `Square`, `Quad`,
`Triangle`) supports `Drawing.Fonts`, `isrenderobj`, `getrenderproperty`,
`setrenderproperty`, `cleardrawcache`, bounded `Drawing.ToSVG` export,
PNG/JPEG/WebP image-header validation and implicit `Image.Size` detection, and
multiline `TextBounds` approximation. Drawing's width-table text approximation
is separate from HarfRust font shaping, and full Roblox rendering parity
remains outside this runtime.

`ROBLOX_CONTENT_DIR` selects the content directory. The local CLI modes also
accept `--content-root PATH`, which takes precedence. The portable integration
tests and `examples/text-service-smoke.luau` use the OFL-licensed Noto fixtures
under `tests/fixtures/fonts` and need no Roblox installation.

## remaining parity work

The Rust host is now the default. Legacy API parity is still incomplete;
this is not a claim of a fully compatible Roblox engine or 100% sUNC.
In particular:

- Closure hooking (`hookfunction` / `restorefunction` / `hookmetamethod` /
  `clonefunction` / `newcclosure`), prototype/constant/stack inspection, GC
  heap enumeration and filtering (`getgc`, `filtergc`, `getfunctionhash`),
  `RSB1` container unpacking (`opcode-203` normalization and 2-part `$bytes_hex`
  `Source` payloads), script-bytecode helpers (`getscriptbytecode`,
  `getscripthash`, `dumpstring`), signal/instance-cache/simulation helpers
  (`firesignal`, `getconnections`, `replicatesignal`, `cansignalreplicate`,
  `cloneref`, `compareinstances`, `getinstances`, `getnilinstances`,
  `getscripts`, `getsimulationradius` / `setsimulationradius` / `setsimradius`,
  `isnetworkowner`, `getproperties`, `gethiddenproperties`,
  `gethiddenproperty` / `sethiddenproperty`, `firetouchinterest` /
  `firetouchtransmitter`, immediate `fireproximityprompt` skip, `stepphysics`,
  `setphysicsenabled` / `isphysicsenabled`, `isparallel`, `getactors`,
  `run_on_actor`, `create_comm_channel` / `get_comm_channel`, `saveinstance` /
  `saveplace` `.rbxlx`/`.rbxmx` serialization paired with `DataModel:GetObjects` /
  `GetObjects`, `HttpPost` / `HttpPostAsync` / `httppost`, `getfflag` /
  `setfflag`, `messagebox`),
  LZ4 raw-block compression (`lz4compress` / `lz4decompress`), local
  cryptography (`crypt.hex`, streaming RFC 2104 `crypt.hmac`, RFC 2898
  `crypt.pbkdf2` / `crypt.derive`, SHA-2/SHA-3/Keccak/BLAKE2/BLAKE3 `crypt.hash`,
  AES-128/192/256), window-focus and frame-cap controls (`isrbxactive` /
  `isgameactive` / `iswindowactive`, `setfpscap` / `getfpscap`), and VM-local
  virtual mouse/keyboard helpers (`mouse1click`, `mousemoveabs`, `keypress`,
  etc.) are implemented via `rust-runtime-sys` and `rust-client/src/rust_host`.
  Installed executor closures are tagged with `mark_executor_closure` so
  `isexecutorclosure` reports `true`, `filtergc(..., { IgnoreExecutor = true })`
  excludes them, and `getrenv()` exposes only engine globals.
- Stack inspection uses the official local-variable API. Authored source is
  compiled with local debug metadata; stripped bytecode cannot supply
  missing local names or arbitrary private VM register state.
- Actor text/chat requests and Actor client-invoke replies retain the old
  host's unbridged limitations. No fabricated host or server reply is used.

## verification

`identifyexecutor()` and its `getexecutorname()` alias return this runtime's
name (`rove`) and package version. `gethui()` returns the session's actual
local CoreGui root, so UI children use the existing instance and rendering paths.
`checkcaller()` distinguishes authored threads from lifecycle-owned game script
threads, including inherited task/coroutine context; changing the thread identity
number does not change its origin. `debug.getinfo().is_vararg` uses numeric 0/1.

Long authored workloads can explicitly set `ROVE_SCRIPT_CPU_MS` (1..300000)
and optionally `ROVE_SCRIPT_NONYIELDING_MS` (1..30000, capped at the total).
The second setting requires the first. These host settings opt authored source
jobs into 5 ms resumable slices with a bounded cumulative execution budget;
child tasks inherit their owner's policy. Ordinary limits remain unchanged.
Non-yieldable callbacks still have a hard deadline, and a callback that reaches
it is terminated instead of being replayed. Waiting time is excluded from the
execution budget. These limits are separate from the CLI's wall-clock timeout.

Live CLI reports include the runtime's bounded event history alongside the
final script status. Output dropped by that history remains explicitly marked;
neither process completion nor a partial log establishes a passing test score.

Verified locally on 2026-11-28 on macOS arm64 (1,948 default / 1,952
`embedded-worker` tests across `client-core` (259), `rust-runtime-sys` (8),
`animation-codec` (7), `terminal` (46 default / 50 `embedded-worker`) and
`rust-client` (1,628) with zero failures and zero compiler warnings, including
the `allocator_ownership` check). The default release build runs `hello.luau`
(`0.006 s`, `13.9 MiB` peak memory footprint, `25.1 MiB` max RSS) and all 20
checks in `rust-host-smoke.luau` (`0.065 s` `elapsed_seconds`, `16.0 MiB` peak
memory footprint, `28.9 MiB` max RSS, including temporary child `ActorVm`
execution). On
`memory_bench`, 50,000 received parts run at `33.3 MiB` peak footprint idle
(`35.4 MiB` / `0.056 s` folder-batched `Position.X` walk, `52.4 MiB` / `0.066 s`
full `GetDescendants` walk) and 100,000 received parts run at `52.1 MiB` peak
footprint idle (`62.6 MiB` RSS, `483 B/node`, zero startup bloat; `55.6 MiB` /
`0.123 s` folder-batched walk, `95.7 MiB` / `0.62 s` full `GetDescendants`
walk; see [startup memory](https://docs.rove.wtf/notes/startup-memory.md)).
The smoke covers local construction/mass, property resets, canonical Instance
identity, handles, engine type names, settings, signal tuples, 3D obstacle
pathfinding, `CFrame` and datatype helpers, `SharedTable` iteration, local
engine services, `UDim2` tween and `Sound` state, executor/crypto/`Drawing`
helpers, local physics/impulses, player/character teleports,
`setsimulationradius`, `TeleportService`, `Workspace:GetServerTimeNow()`,
Parallel Luau + `Actor` / `CommChannel` bridges, `saveinstance` + `GetObjects`
XML round-trips, `Terrain` voxels + `Raycast`, `Camera:GetPartsObscuringTarget`,
`Tool`/`Accessory`/`Resize`/`BreakJoints`, `SpringConstraint`/`RopeConstraint`,
`MarketplaceService`/`Lighting`, and `UIPageLayout`/`UIAspectRatioConstraint`.

```sh
./bin/cargo test --locked --manifest-path rust-client/Cargo.toml --lib --tests -- --test-threads=1
./bin/cargo test --locked --manifest-path rust-runtime-sys/Cargo.toml --test vm_boundary -- --test-threads=1
./bin/cargo build --release --locked --manifest-path rust-client/Cargo.toml --bin rove
target/release/rove run --snapshot tests/fixtures/world_snapshot.json --script examples/hello.luau --json
target/release/rove run --snapshot tests/fixtures/world_snapshot.json --script examples/rust-host-smoke.luau --json
```

The suites exercise the real linked Luau VM, persistent execution, snapshots
and deltas, source loading, Actor isolation/routing, resource limits,
loopback HTTP/WebSockets and the UI protocol. These local tests verify the
embedded VM and Rust host; they do not test live server anti-cheat acceptance
or guarantee a fixed peak RAM figure across arbitrary places.

The legacy comparison build uses `--no-default-features` and additionally
requires Python for its old metadata generation step. Both hosts use the
same checked-in VM sources; their build/link boundaries are separate.

On macOS, `--features 'rust-host allocator-mimalloc' --test allocator_ownership`
checks the active VM allocator, its reallocation path, and a real Luau userdata
allocation. The old C++ malloc/new probe only applies to the legacy backend.
This check verifies allocator ownership; it does not measure peak process RAM.

Attachment and Bone coordinate bindings, received updates and Actor replay are now in Rust. See [attachment transforms](https://docs.rove.wtf/notes/attachment-transforms.md) for the supported properties and limits.
