Skip to main content
Version: 0.2

The app platform's design

Leafen's code cites the app platform's design by section — for example "docs/app-platform.md 16" or "T5". This page keeps those numbers: each section says in a few lines what that part of the design settles and links to where Building Leafen apps describes it for an app's author. The guide is the full description; where the two seem to differ, the guide is right.

1. What it builds on​

Apps reuse what Leafen already has rather than a second system: accounts without a person for an app's account, the native API's key scopes and route table for what an app may reach, the outbound address checks for its relay, durable jobs and schedules for its workers, realtime rooms, history and undo, the administrator settings' encryption for its secrets, and backup and restore. Architecture describes the server they belong to.

2. The package and its manifest​

An app is a .leafenapp zip — a manifest, a screen, workers, data setup and an optional Ed25519 signature — fixed at install by a fingerprint over its files. See What an app is and The manifest.

3. Installs, organizations and permissions​

An app is installed once per server. Each organization that uses it gets its own app workspace and data, and the administrator chooses who there may use it and approves exactly what it may reach. See What an app is and The manifest.

4. The screen: a sealed frame and its channel​

The screen runs in a frame with no origin and talks to Leafen only through one channel; Leafen draws the app's header, its confirm windows and its full window outside the frame. See The screen.

5. Three ways an app acts, and approvals​

An app acts as the person (a short-lived token narrowed to what was approved), as the app (an action run by a worker as the app's account) or on its own (schedules, webhooks, data changes, room messages). See What an app is and Actions and approvals.

6. The app workspace and its data​

The app's account owns a workspace per organization, holding the databases, pages and views the manifest declares, kept by stable keys across versions. See Data.

7. Reaching outside​

The screen reaches only the addresses the manifest names; requests that need a secret, and private addresses an administrator allows, go through Leafen's relay. See Reaching outside.

8. Outside sign-in and secrets​

Outside accounts connect through Leafen, which keeps their tokens and the app's secrets on the server and fills them into relayed requests; the app never sees them. See Reaching outside and Security notes.

9. Rooms, the temporary store and public guests​

Realtime rooms, a temporary key-value store, and guests who join through a link with no Leafen account and no access to Leafen's data. See Rooms, the temporary store and guests.

10. An action is defined once​

One action in the manifest is a button on the screen, an agent's tool and an automation's step, run by the same worker function under the same rules. See Actions and approvals.

10-1. Where an app adds to Leafen​

Besides its own screen: blocks and side panels, lines in the "/" menu and in a row's or a page's "…" menu, and property editors — each declared, approved at install, and gone when the app stops. See Blocks and panels, Menu lines and Property editors.

11. Server workers​

Workers are WebAssembly modules (the Extism calling convention) run in a separate process with no files, network or environment of their own; they reach Leafen and the outside only through host functions. See Workers.

12. Room and connection workers​

Longer-running workers for a room's rules or a connection with no webhook, within limits, reaching outside only through the sockets the manifest lists. See Workers and Reaching outside.

13. Agents​

An app's actions marked as tools, and its instructions, reach the agents connected to Leafen. See Agents.

14. HTML in a page​

An uploaded HTML file shows in a page in the same sealed frame, with no channel and no access to Leafen, under a "User HTML" mark that an organization can turn off. See Embed.

15. Budgets and running apps​

Leafen's own work comes first: apps run within budgets for the whole server, for each app and for each person using it, an app refused too often is stopped, and administrators see each app's use. A person sees what an app read with their access. See Budgets and What people see.

16. Distribution, the catalog and revocation​

Built-in apps, the official catalog and packages installed from a file; signed lists, and a revoked version stops. See Distribution.

An app's screens have addresses of their own under /apps/, open from links and from a home-screen icon. See The manifest (pwa) and Architecture.

18. The SDK, the CLI and the documents​

The SDK in sdk/app, the leafen app commands and this guide. See Quick start and Versions and compatibility.

19. Milestones​

Not kept here: each release's notes say what it adds.

20. Threat model​

Who the design guards against: an app's author who means harm or was broken into, a person using an app to go past their rights, public guests and the open web, instructions hidden in what an app reads, and whoever tampers with how packages are delivered. What it keeps: the bounds of what each person may reach in Leafen, sessions, tokens and secrets, private networks, Leafen's own availability, history and undo that tell the truth, and a screen that doesn't deceive. The code names each threat by its number.

#ThreatWhere its guard is described
T1The frame escapes its seal: reads Leafen's storage, moves the top window, opens an unsealed pop-upThe screen
T2Another frame or document sends commands to the screen's channelThe screen
T3Relayed requests into a private network, by name, by redirect or by a name that changes where it pointsReaching outside
T4A worker gets out of WebAssembly or its process, or reaches the server's files and resourcesWorkers
T5A changed, unknown or revoked package, or code loaded from elsewhereWhat an app is, Distribution
T6A secret leaks through the screen, a worker, a log or a backupReaching outside, Security notes
T7Data leaves through an address or a connection the manifest doesn't nameReaching outside
T8Instructions or tools that steer an agent wrongAgents
T9Public guests who flood a room, send spam or reach for Leafen's dataRooms, the temporary store and guests
T10An app that uses up the server and stalls LeafenBudgets
T11An app that imitates Leafen's sign-in or confirm windowsThe screen, Actions and approvals
T12Rights wider than the person's, a write to a locked database, the app account's rights borrowed by a personWhat an app is, Data
T13An approval used twice, or for another input or actionActions and approvals
T14One organization's app data reaching anotherWhat an app is, Data
T15A forged or replayed incoming webhookReaching outside, Workers
T16An outside sign-in's token taken, or its sign-in forgedReaching outside
T17Script through an app's text in Leafen's screens (names, descriptions, notices)Security notes
T18Script through a file an app uploadedEmbed
T19An update that widens what an app may reach without askingDistribution
T20Changes that slip past history and undoWhat an app is, Actions and approvals