A shared workspace has to answer two questions about everyone in it, and they're not the same question. Can this person see it? And can this person change it? Most permission bugs in software live in the gap between the two, where a check meant for one was written as the other.
This post explains how Nemi keeps those questions apart. One module defines what each role can do, every check must state which question it's asking, and a build script scans every handler before deploy to catch any that touch a workspace without a write gate.
What is the difference between a member and a role?
Being a member of a workspace means you're in it. In Nemi, that's enough to see everything inside: every file, document, sheet, and photo, and to open, preview, and download them. What you can change depends on your role, and there are four. The owner created the workspace and it runs on their plan. An admin runs it with them. An editor works in it. A viewer looks.
Pick a role below. Every tick in this table comes from the same function our server calls when a request arrives, imported directly into this page.
What each role may do
Viewer. Can see and download everything, and change nothing.
A viewer may do 1 of these 8. Press a row for the reason.
Two rows deserve a closer look. Permanent deletion is split in two because it's the one action in a workspace that can't be undone. An editor can trash anything and permanently delete their own work, while only an admin or the owner can permanently erase a colleague's upload.
And no one, not even an admin, can change the owner's role or remove them. The workspace's storage, limits, and features all come from the owner's plan. The help centre lists the same table in words.
Why does every check have to say read or write?
The table is the easy half. The hard half is making sure every one of the several hundred places in the code that changes data actually asks it, and asks the right row.
So the functions that resolve a request's workspace take an intent, either "read" or "write", with no default. Not read, not write: nothing. A handler that leaves it out won't compile.
That sounds pedantic until you look at the alternatives. Defaulting to read lets a new write handler skip the write check and quietly let a viewer through. Defaulting to write breaks pages that only list files for viewers. Either default is a decision made by no one, so there isn't one.
A request to change something, gate by gate
1/5The request arrives
Under the hood, there's one read check and one write check, and both read from the same table you just clicked through. A second rule keeps the lookup honest: it must always check the role of the person asking. Any query joining workspace members has to be narrowed to the caller, or it could return someone else's role and decide one person's permissions from another's.
How does the build check that writes are gated?
Rules in a doc depend on people remembering them, and people are busy. So the rule is also a script that runs during every production build. It walks every route module, splits each into its handlers, and inspects every method that can change data: POST, PUT, PATCH, and DELETE. If a handler touches a workspace without a write gate, it stops the build and the deploy with it.
367
handlers that can change something, checked before every build
423
route modules read to find them
58
exceptions, each with a written reason
Every handler that can change something, one square each
367
handlers in 423 route modules
How we measuredHide the method
A harness in the repository repeats the guard's scan and sorts each handler into the first group that applies: a written exception, then no workspace in sight, then the kind of gate it carries. It refuses to write its numbers unless its totals match the ones the guard itself prints (367 handlers in 423 modules), and every exception is put in a category by hand, so a new one cannot slip into a group by keyword.
Handlers that can change something, by method: 215 POST, 65 PATCH, 79 DELETE and 8 PUT. Counted at commit fc6cfd7d.
The largest grey block needs a clear label. Those 221 handlers don't name a workspace in their own code. They cover account settings, billing, sign-in, staff tools, account-bound apps like Calendar, and handlers that delegate the role check to a shared helper. Because the guard reads text, it leaves those to code review and tests rather than claiming to have verified them.
What about handlers that have no role to check?
Some handlers write data without anyone signed in to hold a role. A client uploading to an upload link has no account; the link itself is the credential. Other handlers require something stricter than write access.
For those, the build accepts an exception, but only when it's written into a file with a plain reason next to it for a reviewer to check. An allowlist without reasons turns into a rubber stamp. One with reasons can be read, challenged, and fixed.
The exceptions, by what authorises them instead
Authorised by a link, a token or a code, for a guest with no account
Acts on the caller's own account, not on a workspace
Held to a stricter check than write: the owner, or the item's creator who still holds a writing role
A read sent as a POST, which changes nothing
Decided by the document's own role check, which refuses a viewer
- A link, a token, or a code. Uploading to an upload link, answering a form, or dropping a file into a room. The visitor has no account, so the credential in the link is checked instead, and its scope is narrow.
- Stricter than write. Changing workspace settings, or managing a link you created, which requires both that you made it and that you still hold a writing role.
- A read sent as a POST. A search or a zip whose selection is too long or too private for a URL. It changes nothing, so it's held to the read check.
Membership decides who may look. The role decides who may change. The build catches any handler that forgot to ask.
What can an automated check not prove?
It's worth being exact about what this script does. It reads source code as text and checks that every handler naming a workspace carries a write gate or a written exception. It can't prove that the gate is the right one, that it checks the right workspace, or that an exception's reason is true. That's still the job of code review and tests, and every exception was checked by hand against the code it describes.
What the guard changes is the default. Without it, a handler missing a write check stays invisible until someone stumbles on it. With it, that handler breaks the build, and the only way past is to add a gate or explain in writing why it's safe.
Roles decide who can change things. How much a workspace can hold, from storage to document counts, comes from the owner's plan on the pricing page. Roles also say nothing about who can read the underlying data, which we cover in what encrypted at rest protects.
Sharing outside the workspace has its own rules on the Files page, and a custom domain adds one more, explained in why it never serves a sign-in page. For everything else we do to protect your work, see the security page.
Questions people ask
What is role based access control?
Role-based access control means a person's permissions come from their role, not individual settings. Everyone with the same role gets the same access, so updating permissions is just a matter of changing someone's role. A Nemi workspace has four roles: owner, admin, editor, and viewer.
What is the difference between a viewer and an editor?
In Nemi, both can see, open, preview, and download everything in the workspace. An editor can also create, edit, rename, move, and trash items. A viewer can't change anything, and the buttons they can't use are hidden rather than shown and refused.
Can a viewer download files from a shared workspace?
Yes. Being a member of a Nemi workspace lets you see and download what's in it, whatever your role. Your role only decides whether you can change anything. If someone shouldn't be able to download a file at all, it doesn't belong in a workspace they're a member of.
Who can permanently delete files in a shared workspace?
An editor can move anything to the trash and permanently delete files they uploaded themselves. Permanently deleting someone else's upload, including emptying the trash, is limited to admins and the owner, because it's the one action in a workspace that can't be undone.
Can an admin remove the owner of a workspace?
No. No one can change the owner's role or remove them, not even an admin, and no one can change their own role. A Nemi workspace runs on its owner's plan, so its storage, limits, and features all come from that account. Deleting the workspace and connecting a custom domain stay with the owner for the same reason.
Is hiding a button enough to stop somebody changing something?
No. A hidden button only tidies the screen; anyone can send the same request from a script. In Nemi, the check that counts happens on the server, which looks up the caller's own role in the target workspace. A build check also flags any handler that touches a workspace without a write gate or a written reason.
Where the numbers come from
- What each role may do, decided in one place
lib/workspace-permissions.ts (roleCan, roleMayDelete, canManageMember) - Read and write checks against the database
lib/workspace-access.ts (userCanReadWorkspace, userCanWriteWorkspace) - An intent with no default
lib/workspace-route.ts (WorkspaceIntent, resolveRequestWorkspaceId) - The build guard
scripts/check-write-gates.ts (bun run guard:writes, run by bun run build) - The exceptions, each with its reason
scripts/write-gate-baseline.json - The counts in this post, from a harness that must agree with the guard
scripts/blog-bench/role-checked-writes/count.ts, lib/blog/data/write-gates.json - Roles, as customers read them/help/workspaces/members-and-roles