Skip to content

Built like a framework.
Run like a platform.

This page describes the engine behind Biscuit: how it works under the hood, and the code our agents write. Security, durability and speed are built into the framework.

Biscuit engineering6 min read
const Contact = MVC.createModel()
.schema({
name: z.string(),
owner: $.models.User.optional(),
email: z.email().optional(),
})
.policy((item, user) => ({
create: item.owner === user,
read: true,
update: item.owner === user,
delete: item.owner === user,
fields: {
// Only the contact's owner can see the email address.
email: {
read: item.owner === user,
create: item.owner === user,
update: item.owner === user,
},
},
}));
export default Contact;
  1. No policy, no build

    A model without access rules fails to compile. So does one that leaves out an action.

  2. Row-level policies

    Each rule compiles to a SQL condition. The server applies it to every read and write from the app.

  3. Column-level policies

    The server strips the email column from rows sent to anyone who isn't the owner.

How agents write and check code

Agents write TypeScript against one typed framework. Models, screens, workflows and connections are each a module with a schema.

Every change is type checked and linted. We maintain more than 100 lint rules, written from the mistakes agents make most often: hard-coded keys, workflows that can't resume. A tester agent then clicks through the app the way a new hire would.

The framework is opinionated, and that helps the agents. There is one way to define a model, a workflow or a connection, so we tune our models and prompts for exactly that and they handle it well.

Then it goes live. Its data lives in your project's own database, at its own address, behind the access rules the compiler checked.

Row-level and column-level policies

Every model has row-level policies. They say who may create, read, update and delete each row. A model without them fails to compile, and so does one that leaves out an action.

Policies run on the server as SQL. Each one compiles to a SQL condition the server applies to every read and write. They apply to everyone using the app, its creator and workspace owners included.

Column-level policies cover single fields. In the contact model below, the server strips the email from rows sent to anyone who isn't the contact's owner.

Crm.models.Contact
const Contact = MVC.createModel()
.schema({
name: z.string(),
owner: $.models.User.optional(),
email: z.email().optional(),
})
.policy((item, user) => ({
create: item.owner === user,
read: true,
update: item.owner === user,
delete: item.owner === user,
fields: {
// Only the contact's owner can see the email address.
email: {
read: item.owner === user,
create: item.owner === user,
update: item.owner === user,
},
},
}));
export default Contact;
  1. No policy, no build

    A model without access rules fails to compile. So does one that leaves out an action.

  2. Row-level policies

    Each rule compiles to a SQL condition. The server applies it to every read and write from the app.

  3. Column-level policies

    The server strips the email column from rows sent to anyone who isn't the owner.

update rule, as the database runs it
-- ?1 is the person signed in, set by the server
(CASE WHEN json_valid(items.data, 5)
THEN json_extract(items.data, '$.owner.$1') END = ?1)
What the update rule runs as

Durable workflows

A workflow is an async function that runs on Biscuit's servers. The one below sends a welcome email when someone signs up, sleeps for three days, then sends a follow-up. The model is inspired by Temporal.

The compiler makes every await a step. Each awaited call is recorded with its result. A failed step is retried up to three times, after 1, 2 and 4 seconds.

Steps are idempotent. When a run restarts, finished steps return their saved result and are skipped. The welcome email goes out once, however often the run is retried.

Sleeping costs nothing. While the run waits, its state is stored and nothing executes. After three days it continues from the next line.

Crm.functions.SendWelcomeEmails
export default MVC.workflows.create({
context: "server",
triggers: [
MVC.workflows.trigger(Crm.models.Signup.events.created(), ({ event }) => ({
signupId: event.id,
})),
],
run: async (input: { signupId: string }): Promise<void> => {
const signup = await Crm.models.Signup.get(input.signupId);
if (!signup) return;
await Email.send({ to: signup.email, subject: "Welcome to Acme" });
await Server.actions.waitFor({
later: Server.events.time({ at: date.addDays(date.now, 3) }),
});
await Email.send({ to: signup.email, subject: "How is it going?" });
},
});
  1. Starts on an event

    The workflow runs on the server each time a signup is created.

  2. Every await is a step

    The compiler records each awaited call and its result. A retried run returns the saved result, so the welcome email is sent once.

  3. Sleeps for three days

    The run is stored and nothing executes while it waits. After three days it continues from the next line.

Automatic indexes

Nobody writes indexes. Biscuit creates them in three steps.

1. Every query gets an ID at compile time. Queries are declared in code, so the compiler knows each one's shape. Like GraphQL persisted queries, each one is turned into a stable ID at compile time.

2. We weigh each query. By how many places in the code send it, and how many rows the model it reads holds. Queries that run into a missing index ask for one.

3. An index manager creates the indexes. It builds the indexes for the queries that weigh most, in the background, biggest models first, and drops indexes no query needs any more after a day. Indexes are stored as rows of their own, so a write only pays for its own model's indexes, and a project can have as many as its models need.

The result: counting a parent's rows read 35 rows through its index, and 3,002 without one.

35rows read instead of 3,002

Counting a parent's rows, with the index and without it

Indexes no query uses are dropped.

Agents never have access to secrets

Code declares a connection and the capabilities it needs. The app below asks for ContactsRead, so it can read HubSpot contacts and their activities. Biscuit requests read access from HubSpot.

Credentials stay with Biscuit. Each person, or the app's owner for everyone, connects an account. Biscuit stores the credentials encrypted with AES-256-GCM. The framework has no call that returns them, so neither the agent writing the code nor the code itself can read a key.

Biscuit adds the key on its own servers, only to calls going to that service. It checks the request against the declared capabilities first. That makes it safe to let agents build integrations: a key can't leak into code, logs or a prompt.

Crm.connections.HubSpot
export default Biscuit.connections.HubSpot.define({
account: "personal",
capabilities: [Biscuit.connections.HubSpot.capabilities.ContactsRead],
});
  1. Code never holds a token

    Each person connects their own HubSpot, or the app's owner connects one for everyone. Biscuit stores the credentials encrypted with AES-256-GCM and attaches them to requests. App code has no call that returns them.

  2. Capabilities are an allowlist

    ContactsRead allows reading contacts and their activities. Biscuit requests read access from HubSpot and refuses every other request.

App code

Asks for HubSpot contacts. Holds no token.

Biscuit

Checks the request against ContactsRead, then decrypts the credential and attaches it.

HubSpot

Sees a read, with read access only.

How workflows are isolated

Server code runs inside three layers. We built it on what we learned running untrusted code at scale for CodeSandbox. Every request gets a fresh V8 isolate.

Around the isolate, nsjail adds operating-system isolation: its own process and network namespaces, apart from the host. Around that, a Firecracker microVM adds a hardware-level virtual machine.

Apps are served from their own domain, separate from Biscuit's.

Firecracker microVM

A hardware-level virtual machine around all of it.

nsjail

Operating-system isolation: its own process and network namespaces, apart from the host.

V8 isolate

Every request gets a fresh JavaScript isolate.

One request

You own your code and data

You own what you build. The apps, the code and the content your team creates on Biscuit are yours.

Export is self-serve. Any table downloads as CSV, Excel or JSON, ready to import elsewhere. For everything else, ask us for a copy of your data, or for its deletion, at any time.

Deleting your account deletes your data. Delete your account and your personal data is deleted or anonymised within 30 days, unless the law requires us to keep it. Backups expire after a limited period.

You own what you build

The apps, the code and the content your team creates on Biscuit are yours.

Export any table

Download any table as CSV, Excel or JSON, ready to import elsewhere.

A copy of your data on request

Ask us for a copy of your data, or for its deletion, at any time.

Gone when you leave

Delete your account and your personal data is deleted or anonymised within 30 days, unless the law requires us to keep it. Backups expire after a limited period.

Security & compliance

We are working on SOC 2. The examination is under way with an independent auditor. We are also working toward ISO 27001 certification.

Your GDPR rights apply to your data. Transfers out of the EU use safeguards such as the European Commission's standard contractual clauses.

Sign-in has no passwords. People sign in with Google or a one-time email link. Our team signs in to Biscuit's systems with multi-factor authentication. Every dependency is pinned, and most new versions wait 14 days before we take them.

SOC 2

In progress

An examination of our security practices is under way with an independent auditor.

ISO 27001

In progress

We are working toward certification.

GDPR

Covered

Your GDPR rights apply to your data, and transfers out of the EU use safeguards such as the European Commission's standard contractual clauses.

No passwords

By design

Sign in with Google or a one-time email link. There's no password database to steal.

Our own access

MFA

Our team signs in to Biscuit's systems with multi-factor authentication.

Supply chain

Pinned

Every dependency is pinned. Most new versions wait 14 days before we take them.

For our current status, or to report a vulnerability, write to security@flits.inc.

For more detail, see our Trust center →.

Questions

What IT usually asks before saying yes.

How do you handle permissions?

In the data layer. Every model declares who can create, read, update and delete each row, and each field if needed. The compiler refuses a model without rules, and the server runs the rules as SQL on every request from the app. They apply to everyone using the app, its creator and workspace owners included.

What happens if a workflow crashes halfway?

It resumes. Each awaited call is a recorded step, so a retried run returns the saved results of finished steps and skips them. A failed step is retried up to three times, after 1, 2 and 4 seconds.

Can an app read our HubSpot or Google tokens?

No. Credentials are encrypted and stay with Biscuit's API, which attaches them to each request. App code can only make the requests its declared capabilities allow.

Where does code run?

Server code runs inside a V8 isolate, inside nsjail, inside a Firecracker microVM. Apps are served from their own domain, separate from Biscuit's.

Who owns the code?

You do. The apps, code and content your team creates on Biscuit are yours. Any table exports as CSV, Excel or JSON, and we'll send a copy of your data on request.

Are you certified?

We are working on SOC 2 with an independent auditor, and toward ISO 27001. Write to security@flits.inc for our current status or to report a vulnerability.

Send this page to your IT team.

Or bring them to a call with one of our engineers.