← All posts

Cydonia apps are moving from Rust and wasm to Luau

A Cydonia app is a small program with a view of its own inside Cydonia: a tracker, a dashboard, a form over a table. Today you write one as a Rust crate compiled to WebAssembly. That means installing Rust, adding the wasm32-unknown-unknown target, rebuilding on every save and turning on Developer mode. That's fine for us, and too much for most people who just want a small tool next to their notes. It's slow for agents too.

So apps are moving to Luau, and Rust and wasm apps are going away. This post describes where we're going; none of it has shipped yet.

What stays the same

An app has never drawn on the screen itself. It hands Cydonia a tree of nodes (rows and columns, text, buttons, inputs, lists, images), and Cydonia draws them with its own components. Clicks and typing come back to the app as events. The app reaches the outside world only through calls Cydonia answers: its own tables, and web requests to the hosts it declares.

None of that changes. What changes is the language behind it, and how an app gets to your machine.

Luau

Script apps are written in Luau, the Lua dialect Roblox built to run code written by strangers inside its own process. That's the situation of an app you install from someone else, so we're using an engine designed for exactly that:

  • A sandbox by design. No file or process access, the os library cut down to the clock, no way to load bytecode, and read-only globals and libraries, so one script can't tamper with what another sees. Luau's sandbox describes it in full.
  • Limits from Cydonia. The engine lets the host interrupt a script that runs too long and control how much memory it allocates; Cydonia uses both to cap each app.
  • Years of hostile code. Luau runs scripts from millions of creators, under a bug bounty and continuous fuzzing. It's still C++, so engine bugs remain possible, but few interpreters have been tested this hard against code that wants out.
  • Types if you want them. Cydonia will ship type definitions for its nodes, events and calls, so mistakes show before the app runs.

An app is a view that returns nodes and an update that handles events:

local cydonia = require("@cydonia")

function view(state)
	return column({ gap = "m" }, {
		text(`Notes: {#state.notes}`),
		button("Refresh", "refresh"),
	})
end

function update(state, event)
	if event.click == "refresh" then
		state.notes = cydonia.query("select * from notes order by id desc")
	end
	return state
end

Everything an app can do arrives through that @cydonia module. If a function isn't there, the app can't do it. A slow call like a web request reads as a plain call: the script pauses while the request runs, and the interface never waits on it.

Developing one is: open the folder in Cydonia, edit the file, save. The app reloads. No compiler, no toolchain, and no Developer mode to turn on first. Opening a folder shows the same permission screen an install does, so you see what it can reach before it runs.

Permissions you see before installing

An app declares what it needs in app.toml:

name = "notes"
version = "1.0.0"
tables = ["notes"]
hosts = ["api.example.com"]

Cydonia shows these permissions when you install the app, before any of its code is downloaded. An app that declares no hosts gets no way to make web requests at all. One that declares hosts can reach those and no others, and Cydonia checks every request itself, outside the script. An update that asks for more than you agreed to is shown to you again.

Installed from a GitHub repository

An app is a GitHub repository with app.toml at its root. Installing takes the repository and, if you like, a tag:

owner/[email protected]

Cydonia resolves the tag to a commit and installs the source at that commit. Tags can be moved; commits can't, so what you installed stays exactly what you agreed to. It reads app.toml first, which is why the permissions show before any code arrives. Updates are newer tags of the same repository.

Publishing is pushing a tag. There's no registry and no package format. And to change someone's app, you fork it: install your fork, or clone it and open the folder in Cydonia to edit it.

Why source and not bytecode

Luau can compile to bytecode, which looks like the natural thing to ship. We won't. Luau doesn't check bytecode when it loads it, and a hand-crafted file can do things the compiler never would, including getting out of the sandbox. Lua learned this the hard way: Lua 5.1 shipped a bytecode verifier, and Lua 5.2 removed it, noting the old one was already insecure because of flaws in its algorithm. Luau's own documentation says untrusted bytecode "may lead to exploits". WebAssembly is safe to accept from strangers because every module is validated before it runs; Luau bytecode has no such step.

So apps ship as source. Cydonia compiles an app when it's installed, which takes milliseconds, and keeps the bytecode it produced itself. A side effect we like: anyone, or any agent, can read what an app does before installing it.

Sources