# people and trust

who sees the box and whose app a change goes into

when the runner serves the app, `identity` works out who someone is and `trust` gives them one of four levels

| level | what the box does for them |
| --- | --- |
| owner | changes it for everyone, undoes anything, and decides on other people's versions |
| trusted | changes it for everyone and undoes anything in everyone's version |
| member | changes their own version that only they see, which an owner can make everyone's |
| visitor | nothing, they never see the box and the runner refuses them even by hand. with [guests](/guests) on, someone not signed in becomes a member instead |

click through them here:

_(on the web page there's a little interactive piece here, `apps/docs/playground/people-and-trust.tsx`, that visitors can change by typing into the box)_

## the config for it

```js
trust: {
  owners: ["you@example.com"],
  trusted: ["friend@example.com"],
  members: "everyone",
  memberPaths: ["app/**"],
  memberNote: "you can change the pages, not the layout.",
  memberRules: "change files under app/ only, and keep each page a server component.",
  memberDailyLimit: 20,
  dailyLimit: 200,
},
```

| | |
| --- | --- |
| `owners`, `trusted` | lists matching someone's id or name, ignoring case, so emails work |
| `members` | a list, or `"everyone"` signed in. without it nobody is a member |
| `memberPaths` | globs from the repo root for the files a member's change may touch (`*` stays in one folder, `**` crosses them). anything outside gets taken back out, and without it any file is fair game |
| `memberNote` | a sentence for members about what they can change, shown at the bottom of their box |
| `memberRules` | rules for the agent on top of `memberPaths`, and the agent gets `memberNote` instead if you leave it out |
| `memberCheck` | gets each changed file's new contents and returns why the change isn't okay (it gets taken back out) or `null`. `clientOnly()` is a ready-made one, see [letting anyone change it](/guests) |
| `memberDailyLimit` | requests per member per day, 20 by default |
| `dailyLimit` | a cap for all members together, none unless you set it |

anyone who isn't any of these is a visitor

## your own version

a member's first request makes them a version, a git branch named `computah/u/` plus a short form of their name, which only they get served. its copy starts when they show up and stops after 20 idle minutes, and whenever everyone's version changes it gets merged in so theirs stays current

owners and trusted people can have one too, their box has a "for everyone" switch that flips to "just for me". with your own version, the bottom of the box says which one you're on and links to the other

## promoting and discarding

an owner's box lists other people's versions that have changes, with their requests and two links:

- **make it everyone's** merges and builds it. if it conflicts or doesn't build nothing changes and the box says why, and once it's merged their version goes away and they're back on everyone's
- **discard** throws it away. the runner lets the person themselves discard it too but their box doesn't show that link yet, which i should fix

## who sees and undoes what

everyone with the box sees requests to everyone's version plus their own, and owners see all of them. you can stop or undo your own, trusted people can also stop or undo anything in everyone's version (they could change it anyway), and owners can stop or undo anything. for people who aren't signed in, see [letting anyone change it](/guests)

## when yours and everyone's collide

whenever everyone's version changes it gets merged into yours, and most of the time that's a normal git merge that nobody notices. if we both changed the same lines git can't decide, so your version gets marked behind and the next time you show up the agent sorts it out. it's told what you asked for and what changed in everyone's version and it's supposed to keep both, and you'll see it in your box as "catch up with everyone's version"

if it can't manage it (or what it produces doesn't build) your version stays exactly how it was, and it tries again the next time everyone's version moves. i watched this work on this site with a real agent, my change and a guest's change to the same button, and the guest kept theirs :D
