# Who can see what: the access model

> Accounts vs handles, channels vs grants vs roles, what admin mode really does, and why your own alt handle is treated like a stranger — the conceptual map behind every sharing decision.

Source: https://good.vibes.diy/docs/access-model

Every sharing question on Vibes DIY — who can read this document, why did
that write fail, why can my other handle not see my own data — reduces to a
small set of concepts. The [Access API reference](https://good.vibes.diy/access-api) gives you the
`access.js` contract and the [Sharing & Access guide](https://good.vibes.diy/sharing) walks the UI;
this page is the map underneath both, including the parts that surprise
people. The deepest treatment is the
[full visual specification](https://good.vibes.diy/docs/access-function-spec).

## The building blocks

**Channels** route documents. Your `access.js` returns
`{ channels: ["team"] }` for a document, and only identities with that
channel in their grant set can read it. A document on a channel granted to
no one is write-only — the foundation of the
[credential vault pattern](https://good.vibes.diy/docs/patterns/write-only-vault).

**Grants** are additive permissions to channels: named users
(`grant: { users: {...} }`), roles (`grant: { roles: { editor: ["team"] } }`),
or everyone (`grant: { public: ["feed"] }`). Grants only ever add — there is
no deny rule to reason about. Revoking (removing a grant) stops future
delivery; copies already synced to a reader's device persist on it.

**Roles** are named bundles people acquire through the sharing UI — invites,
approved requests, auto-accept. The stock vocabulary is `editor` and
`viewer` (plus a latent `submitter`). One thing to burn in:

> **Roles gate data, not code.** An `editor` grant means someone can write
> to your app's databases. It says nothing about editing, pushing, or
> publishing the app's source — deployment always belongs to the owner's
> account, no matter what roles exist.

**`allowAnonymous`** opts a database into writes from signed-out visitors
(surveys, RSVPs). Everything else fails closed for anonymous callers.

## You have one account and possibly many handles

Your **account** is what signs in. It owns your credit balance, your
settings, your apps, and the right to deploy them. Your **handles** are the
names you act as — and you can have several.

The platform deliberately resolves these two identities differently:

- **Management is account-based.** Pushing code, publishing, changing
  settings, deleting an app, and eligibility for admin mode work from *any*
  handle bound to the owner's account.
- **Data access is handle-based.** Channel and role membership key on your
  single **active handle** (the one your handle switcher shows). A grant
  issued to `alice` is invisible while you're acting as `alice-test`.

That yields the rule that surprises everyone once:

> **Your alt handle is a stranger.** It gets nothing implicitly — not even
> on your own vibes. That's a feature, and arguably the best QA tool on the
> platform: switch to an alt handle and you are experiencing your app
> exactly as an ungranted visitor does. Grant the alt handle explicitly
> (invite it, add it to a role) when you want it inside.

## The two meanings of "owner"

Because of that split, "owner" means two things:

1. **The owner account** — can deploy, publish, change settings, and toggle
   admin mode, from any of its handles.
2. **The owner inside `access.js`** — `user.isOwner` is true only when the
   caller's *active handle* is the vibe's owner handle, and the seeded
   `owner` role is granted to that handle string.

In your own access functions, prefer `ctx.requireRole("owner")` over
checking `user.isOwner`: the role is handle-based, behaves identically on
the write and read paths, and — because the generator seeds it as an
ordinary, revocable role — ownership of *data* privileges can be shared or
transferred like any other grant. (The history of why ambient owner flags
were retired is a story of a vibe
[locking out its own owner](https://good.vibes.diy/blog/retiring-isowner).)

## Admin mode: the escape hatch, labeled

Admin mode is the owner account's explicit override — a switch under
Share → **Your access**, never an ambient state:

- **Reads bypass the channel filter.** With it on, the owner sees every
  document in the app, across all users and channels.
- **`requireAccess`/`requireRole` no-op** on writes; the access function
  still runs, so channels and grants still route what gets written.
- **It follows the account, not the handle** — deliberately, so switching
  to an alt handle never locks you out of your own override.

Three places admin mode appears without the toggle:

- **The scheduled backend.** A `backend.js` `scheduled` handler runs as the
  owner in admin mode on every tick — that's what makes it the only lane
  that can read a vault database. Consequences and cautions are in the
  [backend guide](https://good.vibes.diy/docs/your-app-has-a-backend).
- **The CLI's read commands, on your own vibes.** `vibes-diy db
  get`/`query`/`list` request admin mode implicitly when the vibe belongs to
  your account (that's why the CLI can read a doc your browser can't — it took
  the override lane, not extra grants). Reading **someone else's** vibe is not
  elevated: it goes out as you, and if their access rules refuse you, the read
  is refused. The `--admin` flag on those commands *requests* platform-admin
  elevation; unless you're on the platform-administrator allowlist below, the
  server declines and you see the same refusal either way.

  Writes are honest by default and the two write verbs are deliberately
  different. Both `db put --admin` and `db del --admin` bypass the older
  per-database ACL, but only `del` proceeds past an access function that
  refuses; a `put` the access function refuses stays refused. A delete removes
  something, whereas a forced write would put words in another person's
  mouth — a document attributed to someone who never wrote it. Forced deletes
  are audited.
- **Platform administrators** (a short, verified allowlist) can use the
  admin-mode override on any vibe for support. On the data plane they are
  held to the same write rules above: a write your access function refuses
  stays refused, and the access function is never fooled into reporting them
  as the owner. To keep your app working well, they can also push a fix or
  upgrade to an app you already have, publish or unpublish it, and adjust a
  few support settings such as a version pin. Every one of those acts is
  audited, and a support push shows up in your app's chat as "Automatically
  enhanced by Vibes DIY". They only ever work on an existing app; they never
  create a new app under your handle. You can turn enhancements off in your
  app's Share settings.

## Direct messages are outside all of it

DMs live in dedicated per-handle-pair databases (`_d.<a>.<b>`, surfaced at
`/messages`). They're keyed purely by the two handles — accounts, roles,
grants, and admin mode don't apply, and DM databases are explicitly excluded
from the platform-admin override. Nobody but the two handles reads a DM.

## Allow auto-enhance

Every app has one more owner switch, under the access toggle in Share: **Allow
auto-enhance**. It is on by default. While it is on, the Vibes DIY team may
push fixes and upgrades to your live app, and each one shows in your chat as
"Automatically enhanced by Vibes DIY".

Turn it off and Vibes DIY won't send routine upgrades. We may still make
changes to keep your app and the platform safe and working, such as support
you asked for or moderation, and those show in your chat the same way. Only
the owner can flip it. From the CLI:

```bash
vibes-diy app auto-enhance <handle>/<app>        # read
vibes-diy app auto-enhance <handle>/<app> off    # no routine upgrades
vibes-diy app auto-enhance <handle>/<app> on     # welcome improvements again
```

A remix or clone starts with the switch on, and its new owner decides.

## Where to go next

- [Access API reference](https://good.vibes.diy/access-api) — the `access.js` function contract
  with worked examples, and the
  [full visual spec](https://good.vibes.diy/docs/access-function-spec) behind it.
- [Sharing & Access](https://good.vibes.diy/sharing) — every UI state: the toggles, the request
  queue, Clone vs Remix, the pill.
- [Patterns cookbook](https://good.vibes.diy/docs/patterns/) — channels and grants doing real
  work: vaults, deploy buttons, operator consoles.
