Skip to main content

Is Stof right for you?

Stof is just-in-time software: data and logic together, in one document that runs anywhere, travels anywhere, and builds itself as it goes. Your app loads the document and runs it in a sandbox, inside its own process, in Rust, JavaScript/TypeScript, or Python. The document can only use what your app hands it.

Here's who it's for, who it isn't for, and what to use instead.

Stof is a good fit for​

  • Logic a model writes. Rules, filters, transforms, scoring, or agent tools that a model writes at runtime. Parse it as untrusted (nothing runs while it parses), seal it to what you list, and run it in your app on every request. With intents, you describe the function and a model writes it the first time it's called, checked by your examples, then it's plain code.
  • Behavior per customer or per user. One document per account holds its rules, limits, state, and even its UI. An agent can edit it, a person reviews the diff, and your app behaves differently for that account with no deploy.
  • Logic that moves between services, browsers, and workers. A document goes over the wire in one payload, as text or compact binary: its data, its functions, and its fields as they are now. The other side gives the same answer in Rust, JavaScript, or Python. What you send is the text itself, often a few hundred bytes.
  • The rules engine, config format, or DSL you were about to build. Describe your domain in Stof instead, and get types, units, schemas, tests, a sandbox, a language server, and a VS Code extension with it.
  • Config that checks itself. #[schema] rules and computed values in the config, still exported as plain JSON, YAML, or TOML.

Stof isn't the right fit for​

  • Your application code. Stof isn't a language for writing apps. Write your app in your main language and hand Stof documents the functions they need.
  • Heavy number crunching. Stof is fast for decisions (a small call takes microseconds), not for tight loops over millions of items. Do that work in your app and give it to the document as a function. For a fast general-purpose embedded language, see Lua.
  • Code that needs a full machine. If an agent needs Python and its packages, a shell, or files, use a sandbox that runs a whole computer, like E2B, or Pyodide for Python in the browser.
  • Long-running services. Stof calls make a decision and return. They have time and memory limits (2 minutes and 256 MB by default).
  • Coordinating work across machines. Stof moves logic and state between machines; it doesn't schedule, queue, or retry work. Use it inside the system that does.
  • Infrastructure policy. For Kubernetes admission and cloud-native authorization, OPA and its integrations are the point.
  • A single condition that must never loop. If all you need is one fast expression, like an authorization check, CEL is smaller and can't loop by design.

What you get​

  • A sandbox that's on by default. A document sees itself and the functions your app registers. The file system, network, and environment are off unless you turn them on. See Security and the Sandbox.
  • Limits on every call. A time and a memory limit per call, and a sealed part can have its own, like 50 ms.
  • Any JSON is already Stof. Add types and functions to data you have, and export it back to JSON, YAML, or TOML.
  • One runtime, three languages. cargo add stof, npm i @formata/stof, or pip install stof. The same document gives the same result in each.
  • Fast, in your process. No server or cold start: a small document parses in well under a millisecond, and calls take microseconds. See Performance.
  • Open source. Apache 2.0, made by Formata, Inc., and the engine behind Limitr.

Next​