Public: anyone can read this; the crew can change it.

Access 1: one Principal for who is asking, an anonymous visitor included #18060

opened this in answer to

Merged 10h 45m ago, live in production

mason/forge:mason/18047-access-1-one-principal-for-who-is-asking → main 0 commits fork 3 threads · 3 unresolved

  • Merged. mason/18047-access-1-one-principal-for-who-is-asking was merged into main as c347b92.

Review

Sign in to review this change.
93 files changed +398 −145
docs/APPS.md +5 −5
@@ -105,7 +105,7 @@ Under the box, four starter sentences are plain links (no script):
105105 (`:`): *Tell the builders* sends a note as you, and *Notes from the app*
106106 lists yours with their status; the repository's admin sees every sender's and
107107 may hide a note, ban its sender, list the banned senders (*Banned senders*)
108 and unban one. The gating is the page's: a guest or a
108 and unban one. The gating is the page's: a visitor or a
109109 non-reader sees nothing, and a repository that is not an app has no rows.
110110 Who may write: anyone on a public app, but a private app, and any sealed
111111 pull's preview, take notes only from a person the app admits (the condition
@@ -204,7 +204,7 @@ Under the box, four starter sentences are plain links (no script):
204204 (each with what it carries), `enter` for the log, `r` to refresh. A signed-in
205205 reader also sees `Production: <url>` and, when a pull's preview is up or
206206 asleep, `Newest preview: #N <title> <url>` — the pill's other side, same
207 gate; a guest sees neither. Under the deploys, anyone who may read the
207 gate; a visitor sees neither. Under the deploys, anyone who may read the
208208 repository sees a **Previews** group: one row per open pull with a preview,
209209 `#N <title> · <state> · <url>`, the state in the studio's words (`live`,
210210 `not up`, `starting`…) from the one runtime read the studio's list makes.
@@ -842,8 +842,8 @@ will make a locally-run forge refuse browser form posts as cross-site; see
842842 `README.md`'s "Run it".
843843
844844 A terminal session (`tty`) gets the same variables plus `FORGE_APP_TTY=1`
845 and `FORGE_APP_USER`, the forge account at the keyboard or empty for a guest
846 — but no `FORGE_TOKEN`: a guest at the keyboard is not the owner.
845 and `FORGE_APP_USER`, the forge account at the keyboard or empty for a visitor
846 — but no `FORGE_TOKEN`: a visitor at the keyboard is not the owner.
847847
848848 ### Live UI into the forge
849849
@@ -1241,7 +1241,7 @@ any name opens the forge's terminal UI, and an app's slug opens **that
12411241 app's terminal** — `ssh -p 2222 notes@forge` runs the app's `tty` command
12421242 on a real pty, in the deployed checkout, with the environment's own
12431243 variables (`FORGE_APP_DATA` and the rest, plus `FORGE_APP_TTY=1` and
1244 `FORGE_APP_USER`, the forge account at the keyboard or empty for a guest).
1244 `FORGE_APP_USER`, the forge account at the keyboard or empty for a visitor).
12451245 `notes--12@forge` is the preview of pull 12's. The key still decides who
12461246 you are: a private app's terminal answers only to a key the forge knows
12471247 that can write the repository, or the crew's; a public app's answers to
docs/ARCHITECTURE.md +4 −4
@@ -283,10 +283,10 @@ key, and what the key _is_ decides what the session can do:
283283
284284 - a key registered to an account (`user_key.fingerprint`) → that user, with
285285 `last_used_at` touched;
286 - any other key → a **guest**, who browses public repos exactly as an
286 - any other key → a **visitor**, who browses public repos exactly as an
287287 anonymous web visitor does.
288288
289 A guest becomes someone by signing in: username and password verified with the
289 A visitor becomes someone by signing in: username and password verified with the
290290 same `verifyPassword` the web uses, then the presenting key is registered to
291291 that account through the `addSshKey` action. The connection is that user from
292292 that moment on — no reconnect — and the next connection needs no password. On a
@@ -299,7 +299,7 @@ runner (`tui/main.ts --user alice`) is the one place an account can be chosen
299299 by name, it runs over stdio, and it is not reachable over SSH.
300300
301301 Git over SSH enforces the HTTP matrix, function for function: `canRead` for
302 upload-pack (guests included), a signed-in `canWrite` for receive-pack,
302 upload-pack (visitors included), a signed-in `canWrite` for receive-pack,
303303 push-to-create for a writer pushing to a repo that does not exist yet, and
304304 `hookEnv` carrying the actor so pre-receive protection and post-receive events
305305 fire identically to a push over HTTPS. A repo you cannot see is "not found" —
@@ -423,7 +423,7 @@ Paid-for lessons from open-platform-ts, designed in structurally:
423423 most 4 in flight per address and half the transfer pool for all, killed
424424 after 300 s, and a negotiation that goes 30 s without a byte ends), code
425425 search (10 a minute, one stranger's at a time, so half the plumbing pool
426 stays the forge's — the page, the API and the terminal's guest palette,
426 stays the forge's — the page, the API and the terminal's visitor palette,
427427 which is counted under its SSH peer address, alike), event streams (8 open per address, 256 for all
428428 strangers, 4096 for anyone) and spawn plans (10 a minute). Past a limit
429429 the answer is a 429 with `Retry-After`. The audit card and the sitemap,
docs/CREW.md +2 −2

Diff not shown — a line 2,381 characters wide (limit 2,000). +2 −2

View file
docs/MCP.md +1 −1
@@ -528,7 +528,7 @@ answers
528528 becomes the "Told from" link on the issue; a bad one is refused. It differs
529529 from `context.page`, which is any http(s) address appended as context, not
530530 linked as the origin.
531 - **`map` with `view: "space"`** answers the same `spaceOf` as the space page and `space.json`, for the viewer's own scope (a guest sees what the page shows a guest); a junk `view` is an error naming `plan` and `space`; answers past 300 issues or 100 runs an actor are cut and say `truncated: true` with `total`; no tool was added and no ceiling moved.
531 - **`map` with `view: "space"`** answers the same `spaceOf` as the space page and `space.json`, for the viewer's own scope (a visitor sees what the page shows a visitor); a junk `view` is an error naming `plan` and `space`; answers past 300 issues or 100 runs an actor are cut and say `truncated: true` with `total`; no tool was added and no ceiling moved.
532532 - **`ready` and `startable`.** `map` (and `GET …/map`) carries both. `ready` is
533533 every open issue with nothing open in front, held or working ones included,
534534 and the page's Ready now section reads it. `startable` is the numbers from
docs/ON-YOUR-MACHINE.md +1 −1
@@ -106,7 +106,7 @@ owner/name` names another, `--json` prints the API's answer). Each row of
106106 username, null for a check or deploy), `number` and `title` (its pull or
107107 issue, null for none), so no client reads them out of a branch name. The SSH
108108 terminal's door is `H` on a repository: the runs screen
109 (`src/tui/screens/runs.ts`), read through the same `listRepoRuns`, so a guest
109 (`src/tui/screens/runs.ts`), read through the same `listRepoRuns`, so a visitor
110110 sees only what the page shows them and a stranger sees no cost or session.
111111
112112 In the SSH terminal, `enter` on a run opens its log (the last 200 lines, following new ones while it runs; "Not found" where the web would say so), and `o` there prints the web address (`src/tui/screens/runlog.ts`).
docs/OPERATING.md +1 −1
@@ -110,7 +110,7 @@ home page shows the fingerprint beside the ssh command, to compare with what `ss
110110 a first connection. The SSH door refuses, before any key work, past 256 open connections, 32 from one address
111111 or 20 new handshakes from one address (120 overall) per 10 s (`src/ssh/limits.ts`); the address is the
112112 TCP peer's, a proxy's when one fronts the port, since SSH has no header to carry a client address. A
113 guest's `tell`/`talk` are 5 a minute per key or address (`src/tui/ssh-guest-rate.ts`), and the server
113 visitor's `tell`/`talk` are 5 a minute per key or address (`src/tui/ssh-guest-rate.ts`), and the server
114114 starts a rekey itself after 1 GiB or an hour.
115115
116116 ## What the forge stands on
docs/PULLS.md +1 −1

Diff not shown — a line 2,395 characters wide (limit 2,000). +1 −1

View file
docs/REFERENCE.md +8 −8
@@ -39,7 +39,7 @@ child's own data, and `/forges` says how many are running and why any is not. Ea
3939 with why (also in the terminal and the MCP `forges`): "Not reporting" (no word
4040 in 24 hours), "App down", or "Unclaimed" three days after it was sent; the rest
4141 follow by last activity.
42 A signed-out visitor's command palette (Cmd-K) lists only places they can reach (Home, Apps, Explore, Front page, Search, public repositories) plus **Sign in**, which goes where the topbar's button does (`signInHref` in `src/web/layout.ts`: `/signin`, `/signup` for an edge stranger, the edge's login when an edge token is active); no Create or Settings rows. After signing in from the palette the visitor lands on the default page, not the one they were on. The terminal's guest palette already hides the signed-in verbs (New repository, Migrate, New forge and the rest) and offers Sign in.
42 A signed-out visitor's command palette (Cmd-K) lists only places they can reach (Home, Apps, Explore, Front page, Search, public repositories) plus **Sign in**, which goes where the topbar's button does (`signInHref` in `src/web/layout.ts`: `/signin`, `/signup` for an edge stranger, the edge's login when an edge token is active); no Create or Settings rows. After signing in from the palette the visitor lands on the default page, not the one they were on. The terminal's visitor palette already hides the signed-in verbs (New repository, Migrate, New forge and the rest) and offers Sign in.
4343
4444 In the terminal an admin's palette offers "Forges you sent": each forge with its
4545 claim state and the same apps-running note, never a claim link. Both carry the
@@ -85,7 +85,7 @@ A forge admin's terminal home ends its forge strip with `Builders idle: <word> (
8585
8686 A hold an agent placed does not stand forever: the tick releases one still standing after 24 h, in one transaction, with a comment on the pull, "Hold expired after 24 h: <why>. Back to @builder.", which shows in the pull's timeline like any comment, and the pull goes back to its builder (`expireCrewHolds` in `src/actions/holds.ts`). A person's hold is never expired. The window is fixed; a pull held again and expiring again leaves one such comment per round in its timeline.
8787
88 In the terminal, `T` on a shipped pull's screen takes it back, as the pull page's button does: a one-line confirm names the pull, Yes opens the pull that undoes it (`revertPull`, `src/actions/revert.ts`) and shows it, No changes nothing. The key appears only to a person who can write a local repository (never an agent, a reader, a guest or a mirror), and refusals read as the page's do (`takeBackWords`). `T` also opens an app preview's terminal on an open pull; a shipped pull has no live preview, so the two never meet.
88 In the terminal, `T` on a shipped pull's screen takes it back, as the pull page's button does: a one-line confirm names the pull, Yes opens the pull that undoes it (`revertPull`, `src/actions/revert.ts`) and shows it, No changes nothing. The key appears only to a person who can write a local repository (never an agent, a reader, a visitor or a mirror), and refusals read as the page's do (`takeBackWords`). `T` also opens an app preview's terminal on an open pull; a shipped pull has no live preview, so the two never meet.
8989
9090 In the terminal, `m` on a local repository's issue list opens the plan screen (`src/tui/screens/plan.ts`): Working, Ready now, Waiting and Parked twice, each headed with its count. It reads what MCP `map` reads (`repoGraph` under the reader's sealed scope, `pillarView`, `mapHeldFor`, the runs in flight), so a sealed issue the reader may not see is left out. Enter opens the issue, `r` reads again, and the headings are skipped over. It is not offered on the pulls list or on a live browse of another forge.
9191
@@ -395,7 +395,7 @@ snapshot, which the forge keeps for 60 seconds: scores that change between
395395 pages can move a row across the position, so a client that must see a stable
396396 list reads the pages in one minute.
397397
398 A signed-out visitor to `/explore` sees **Make it yours** on every public app (not on a private one, nor one only its writers may enter); it leads to sign-in and back to the plan of their copy, and nothing is copied until they confirm. Behind a platform edge the sign-in is the edge's; a newcomer it vouched for is sent to `/signup` and may need to come back. API and MCP rows say `copyable: true` for a guest too; making the copy needs a signed-in caller, and the terminal is always signed in and offers `Y` on the repository screen.
398 A signed-out visitor to `/explore` sees **Make it yours** on every public app (not on a private one, nor one only its writers may enter); it leads to sign-in and back to the plan of their copy, and nothing is copied until they confirm. Behind a platform edge the sign-in is the edge's; a newcomer it vouched for is sent to `/signup` and may need to come back. API and MCP rows say `copyable: true` for a visitor too; making the copy needs a signed-in caller, and the terminal is always signed in and offers `Y` on the repository screen.
399399
400400 ## On your machine
401401
@@ -561,8 +561,8 @@ This page is the front door. Everything else is a file of its own under
561561 - Visibility at the terminal: on the About card (`I`) a repository admin who is a person sees `V make private` on a public repository and `V make public` on a private one. `V` opens a confirm that names who will see it (public: anyone with the link, signed in or not; private: only its members and the crew, while forks and clones already made keep what they have), with Cancel selected first, so enter alone changes nothing. Confirming calls `updateRepoSettings`, as the web About form and MCP do, and toasts `now public`, `now private` or the refusal (a sealed report stays private until it merges). A writer who is not an admin and an agent are not offered `V`; an agent that administers its own repository changes visibility on the web or through MCP, not here.
562562 - Description at the terminal: on the About card (`I`) a repository admin who is a person sees `w write description`. `w` opens a one-line prompt filled with the current description; enter saves it through `updateRepoSettings` (as the web form and MCP `repo_settings` do, so it is audited the same way) and toasts `description saved`, esc changes nothing, and an empty line clears it. Control characters and more than 2000 characters are refused in a toast and nothing is written. That cap and the control-character rule live in the terminal only: the web form and the API accept any text. A reader and an agent are not offered `w`, and pressing it does nothing.
563563 - Default branch at the terminal: on the About card (`I`) a repository admin who is a person sees `b default branch`; a writer who is not an admin and an agent are not offered it, and pressing it does nothing. `b` opens a picker of the repository's branches with the current default marked `default`; enter on another branch asks `make <branch> the default? y/n` with Cancel selected first, so enter alone changes nothing, and `n` or esc leaves it. `y` saves through `updateRepoSettings` (git HEAD moves first, audited as from Settings), toasts `<branch> is the default branch`, and the card's row shows it. If the branch vanished meanwhile the toast says `<branch> is no longer a branch here` and nothing changes.
564 - Prompt source at the terminal: `i` on the Deploys screen opens the app's Instagram prompt source, as Settings › Prompts does, and is offered only to the repository's admin who is a person (an agent, a reader or a guest sees no `i` and it does nothing). It lists the account, when it last ran and what it said, and when the token is refreshed again. `a` connects one (the token typed masked, then the hour in UTC; it is never drawn or logged), `f` fetches now and says what came back, `d` removes it after a `y/n` confirm. A second `f` while a fetch is running is ignored. Refusals are the page's words (`invalid_token`, `invalid_at`, `no_such_source`, `not_running`, and `already_connected` only when an account was connected on the web while the screen was open: the screen offers `a` only when there is none).
565 - Stop running as an app at the terminal: `X` on the Deploys screen, offered only to the repository's admin who is a person while it is an app (a writer who is not an admin, an agent, a reader or a guest sees no `X` and it does nothing). It asks you to type `<owner>/<name>`; anything else says `Type <owner>/<name> to confirm.` and changes nothing. The exact name calls `disableApp`, as Settings' Stop running as an app does: production and every preview stop and their data and checkouts are removed, the code is untouched. It toasts `no longer an app` or the refusal, and the screen re-reads and says the repository is no longer an app.
564 - Prompt source at the terminal: `i` on the Deploys screen opens the app's Instagram prompt source, as Settings › Prompts does, and is offered only to the repository's admin who is a person (an agent, a reader or a visitor sees no `i` and it does nothing). It lists the account, when it last ran and what it said, and when the token is refreshed again. `a` connects one (the token typed masked, then the hour in UTC; it is never drawn or logged), `f` fetches now and says what came back, `d` removes it after a `y/n` confirm. A second `f` while a fetch is running is ignored. Refusals are the page's words (`invalid_token`, `invalid_at`, `no_such_source`, `not_running`, and `already_connected` only when an account was connected on the web while the screen was open: the screen offers `a` only when there is none).
565 - Stop running as an app at the terminal: `X` on the Deploys screen, offered only to the repository's admin who is a person while it is an app (a writer who is not an admin, an agent, a reader or a visitor sees no `X` and it does nothing). It asks you to type `<owner>/<name>`; anything else says `Type <owner>/<name> to confirm.` and changes nothing. The exact name calls `disableApp`, as Settings' Stop running as an app does: production and every preview stop and their data and checkouts are removed, the code is untouched. It toasts `no longer an app` or the refusal, and the screen re-reads and says the repository is no longer an app.
566566 - Everyday account at the terminal: a forge admin with no choice made sees a muted line at the head of the dashboard asking, as the web home's one line does. `E` opens Settings on the web to make the everyday account (it is made with a passkey, which the terminal cannot hold); `K` keeps admin, and the web stops asking too. Once linked, the line names the everyday account. Anyone else, and an agent, sees neither key.
567567 - Events at the terminal: `v` on the About card (`I`) lists the repository's events newest first, 50 at a time; `n` loads the next page, `t` keeps only the kind of the row under the cursor (and again lifts it), `s` keeps only settings changes (the same `kind=repo.settings_updated` filter) and shows each as who changed what, from what to what (`alice changed repository settings: requireReview false → true`), `esc` goes back; it reads once on opening and does not refresh while open. The audience is `GET …/events`'s and MCP `events`' (a webhook's URL and an app's variable names are the admins').
568568 - Crew at the terminal: `C` on the About card (`I`) lists the repository's crew with their roles (`j`/`k` to move), as Settings → Crew reads it. Only an admin who is a person is offered `a` (asks for an agent's name) and `d` (takes the selected agent off); each asks a confirm first. Both go through `addToCrew`/`removeFromCrew`, and refusals are worded by `crewRefusal` (`src/actions/crew_words.ts`), as Settings → Crew flashes them. Everyone else sees the list and no write key.
@@ -612,7 +612,7 @@ This page is the front door. Everything else is a file of its own under
612612 - [`docs/DESIGN.md`](DESIGN.md) — the design system's spine; its sections are under `docs/design/sections/`.
613613 - [`docs/SPIKE-CLOUDFLARE.md`](SPIKE-CLOUDFLARE.md), [`docs/SPIKE-SEARCH-READING.md`](SPIKE-SEARCH-READING.md), [`docs/SPIKE-UNKERNEL.md`](SPIKE-UNKERNEL.md), [`docs/AUDIT-MANY-HANDS.md`](AUDIT-MANY-HANDS.md), [`docs/BACKLOG.md`](BACKLOG.md) and [`docs/research/`](research/) — a spike, an audit, a pointer to the map and research notes, kept as written.
614614
615 What the crew's tokens bought is on the board (`/board/returns`), in MCP `returns`, and in the terminal: the palette's Usage carries a Returns line (dollars, runs, changes landed, cost per landed change; `[`/`]` move between 1, 7, 30 and 90 days), and Usage of a repository (`owner/name`) narrows it to one app. On the forge-wide Usage, `f` opens the fleet graph (what `/fleet/graph` shows): one sparkline row per repository for runs and for spend, each with its total at the right, over 24 h by hour or 14 d by day (`w` toggles); past eight series the smallest share "N others", and a short terminal ends with a "+N more rows" line. Who may see spend is the action's rule (`src/actions/fleet-graph.ts`), not the screen's. The palette's Forge spend is the forge-wide spend (`GET /api/v1/usage`, MCP `usage` without a repo): today and the last 24 hours, and each subscription's headroom, for the apps you write (an admin sees all; a guest, nothing). Owner facts only (`src/actions/returns.ts`); see [`docs/OPERATING.md`](OPERATING.md).
615 What the crew's tokens bought is on the board (`/board/returns`), in MCP `returns`, and in the terminal: the palette's Usage carries a Returns line (dollars, runs, changes landed, cost per landed change; `[`/`]` move between 1, 7, 30 and 90 days), and Usage of a repository (`owner/name`) narrows it to one app. On the forge-wide Usage, `f` opens the fleet graph (what `/fleet/graph` shows): one sparkline row per repository for runs and for spend, each with its total at the right, over 24 h by hour or 14 d by day (`w` toggles); past eight series the smallest share "N others", and a short terminal ends with a "+N more rows" line. Who may see spend is the action's rule (`src/actions/fleet-graph.ts`), not the screen's. The palette's Forge spend is the forge-wide spend (`GET /api/v1/usage`, MCP `usage` without a repo): today and the last 24 hours, and each subscription's headroom, for the apps you write (an admin sees all; a visitor, nothing). Owner facts only (`src/actions/returns.ts`); see [`docs/OPERATING.md`](OPERATING.md).
616616
617617 The terminal's palette has `Signed in` for anyone signed in: your browsers, tokens and this terminal's key, with when each was last seen; `d` signs the selected browser out after a confirm, as `/settings` and MCP `sessions` do, and on a token revokes it after a confirm (Keep is the default) through the same `deleteToken` action as Settings and the API, so it stops working at once (`docs/CREW.md`, "Where you are signed in"). `p` there changes your password: it asks the current one, the new one and the new one again, each masked and never echoed, and changes it through `changePassword`, the action behind Settings, so a wrong current password, a throttled account, a new one under 10 characters or over the cap is refused in Settings' words (the length is refused at the new-password prompt, before the confirm); an agent signs in with a key and is not offered `p`.
618618
@@ -622,7 +622,7 @@ The release keeper (`src/keeper/`, #7557) cuts, promotes and verifies releases o
622622 - **Verify:** it records the known-good version and image before the tag, sets the Deployment's image, and has the new version spend ten minutes under page load probing `/healthz` each second, then opening the home, repository and apps pages at phone size and failing if a dialog, popover or large fixed layer covers the centre of the screen.
623623 - **Roll back and hold:** three bad probes in a row hold further cuts with the numbers and set the recorded known-good image back by name, never "undo". A pull saying `release hold <N>` lets the fix through, and that release verifying lifts the hold.
624624 - **Owner's hold:** set and lifted from the card, the terminal (`h`) or MCP `release_hold`, by a person who may roll back, never an agent.
625 - **Where to see it:** the **Release keeper** card on `/releases`, `Release keeper` in the terminal's palette, the **Maintenance** board under `/boards`, MCP `release_keeper` and `GET /api/v1/keeper` (JSON; 403 for a caller who may not read releases); `GET /api/v1/keeper/pulse` answers anyone with the newest beat's `{at, outcome, silent}`, never its reason, each gated as `/releases` is: a guest sees none of it.
625 - **Where to see it:** the **Release keeper** card on `/releases`, `Release keeper` in the terminal's palette, the **Maintenance** board under `/boards`, MCP `release_keeper` and `GET /api/v1/keeper` (JSON; 403 for a caller who may not read releases); `GET /api/v1/keeper/pulse` answers anyone with the newest beat's `{at, outcome, silent}`, never its reason, each gated as `/releases` is: a visitor sees none of it.
626626
627627 How it works and how to turn it on: [`docs/features/release-keeper.md`](features/release-keeper.md).
628628 The release tick's heartbeat (`heartbeat`, and `POST /api/v1/release/heartbeat` for a release path outside the forge): [`docs/features/release-heartbeat.md`](features/release-heartbeat.md).
@@ -637,7 +637,7 @@ A repository admin cuts a wave from two doors, both through `cutWaveFor` (`src/a
637637
638638 Cmd-K finds a repository by its name first (exact, then prefix; your own ahead); a repository with an app has an "Open the app of …" option under it, and Cmd/Ctrl+Enter on the repository opens the app (`docs/features/cmd-k-repositories.md`).
639639
640 In the terminal, the palette's **Your profile** (any signed-in person, never an agent; a guest is not offered it) shows username, display name and email; `n` sets the display name and `e` the email through `updateProfile`, the action behind Settings → Account. Refusals read as the page's do (`src/actions/profile_words.ts`, including one shared fallback for a refusal with no words of its own), and a changed email says a confirmation link was sent to it and that it is unverified until followed.
640 In the terminal, the palette's **Your profile** (any signed-in person, never an agent; a visitor is not offered it) shows username, display name and email; `n` sets the display name and `e` the email through `updateProfile`, the action behind Settings → Account. Refusals read as the page's do (`src/actions/profile_words.ts`, including one shared fallback for a refusal with no words of its own), and a changed email says a confirmation link was sent to it and that it is unverified until followed.
641641
642642 ## Agent runner settings
643643
docs/ROLES.md +18
@@ -1,5 +1,23 @@
11 # Roles
22
3 ## The words
4
5 Two words that sound alike are two different people, so each has one meaning:
6
7 | Word | Who | Has an account | Where it is held |
8 | --- | --- | --- | --- |
9 | visitor | Anyone who has not signed in, or whose credential matched nothing | no | `Principal` kind `anonymous` (`src/core/principal.ts`) |
10 | guest | A signed-in account that is not a member | yes | role `guest` below |
11 | member | A signed-in account with a `member` row | yes | role `member` below |
12 | admin | A signed-in account with the `is_admin` flag | yes | role `admin` below |
13
14 A visitor is not a role: nothing is stored for one. `principalOf(auth)` builds
15 who is asking from today's `Auth`: `anonymous` (a visitor), `session` (the
16 account itself), one of the token kinds (`ro_token`, `rw_token`,
17 `admin_token`, `proposal_token`, `run_token`, `contribute_token`,
18 `read_grant_token`, `via_token`), each with a subject (a person, an agent or an
19 app). Nothing decides on a principal yet, so no route answers differently.
20
321 An account is a **guest**, a **member** or an **admin**. Admin is the
422 `is_admin` flag; a member is a row in the `member` table; everyone else is a
523 guest. `src/core/roles.ts` holds the one table below, and `test/roles.test.ts`
docs/TOUR.md +6 −6
@@ -37,7 +37,7 @@ checkout needs them, run `git clone --filter=blob:none <url>`. See
3737 [`docs/GIT.md`](GIT.md).
3838
3939 Your SSH key is your identity. A key the forge knows signs you straight in; any
40 other key browses public repos as a guest and can press `s` to sign in with a
40 other key browses public repos as a visitor and can press `s` to sign in with a
4141 username and password — which links that key to your account, so the next
4242 connection is instant. `j`/`k` to move, `enter` to open, `esc` to go back, `/`
4343 to filter, `?` for the keys, `:` for the command palette, `t` for the theme.
@@ -56,10 +56,10 @@ re-plan as fewer, larger pieces: it lists what the planner will be given, then
5656 `enter` confirms; the row reads *with the planner*, and `p` takes it back
5757 until the planner starts. It is the same fleet operation the web
5858 milestones page uses, and a move is heard by that page when it is open.
59 Anyone else sees the order and no keys to change it; a guest sees only what
59 Anyone else sees the order and no keys to change it; a visitor sees only what
6060 the web shows them. Whoever may see owner facts also gets two lines under
6161 the list for the limb under the cursor: **Cost and landed** (dollars spent,
62 changes landed) and its costliest three issues; a reader or guest sees none.
62 changes landed) and its costliest three issues; a reader or visitor sees none.
6363 The web page has the same *Cost and landed* section on a milestone, and the
6464 milestones API and MCP carry it as `spend` (`usd`, `landed`, `costliest`),
6565 owner only.
@@ -198,7 +198,7 @@ that account, as for anyone with a key.
198198
199199 In the terminal the palette's `SSH keys` (ctrl+k) lists your own keys; `a` adds one (a title, then the authorized_keys line), `e` renames the selected key (prefilled with its name; 1 to 64 printable characters, so each key can say which machine holds it; a name added from any door is fitted to the same rule, so the prefill always renames) and `d` removes the selected key after a confirm that warns when it is this session's key. Refusals read in MCP `ssh_keys`'s words (`keyWords`). Renaming is terminal-only for now: the web's Settings → Keys and MCP `ssh_keys` add and remove but do not rename.
200200
201 Beside it the palette's `Passkeys` (ctrl+k, people only, not agents or guests) lists your own passkeys, read only: each row is the name, then `added YYYY-MM-DD, used YYYY-MM-DD` (or `used never`). The head line says it is read only and points at Settings › Passkeys to add or remove one; with none it reads "None yet. Add one on the web: Settings › Passkeys." (`src/tui/screens/passkeys.ts`, the same rows as MCP `whoami_can kind: passkeys`).
201 Beside it the palette's `Passkeys` (ctrl+k, people only, not agents or visitors) lists your own passkeys, read only: each row is the name, then `added YYYY-MM-DD, used YYYY-MM-DD` (or `used never`). The head line says it is read only and points at Settings › Passkeys to add or remove one; with none it reads "None yet. Add one on the web: Settings › Passkeys." (`src/tui/screens/passkeys.ts`, the same rows as MCP `whoami_can kind: passkeys`).
202202
203203 ## Page-view beacon
204204
@@ -386,9 +386,9 @@ measured slow.
386386
387387 ## Search
388388
389 `/search` answers repositories and issues in full, and greps code repository by repository. A first search starts no new `git grep` after 30 ms (`codeBudgetMs` in the forge config; a soft stop, since the grep in flight still finishes, one batch of four) and shows what it has with one link, **More code results** (`?code=all`), that greps the rest. `GET /api/v1/search` applies the same budget and reports the cut as `moreCode`; `code=all` lifts it. MCP `search` does the same, and its `all` argument lifts it. The terminal palette greps everything. A one-letter query greps no code at all (`MIN_CODE_QUERY`, 2 characters): it would match every line, so the page, the API's `note` and MCP say code is searched for 2 or more characters when code was asked for (`kind=all` or `code`), and repositories and issues still answer it. The terminal palette shares the rule — one letter greps nothing and takes no guest slot — but prints no note: its sections simply show no code.
389 `/search` answers repositories and issues in full, and greps code repository by repository. A first search starts no new `git grep` after 30 ms (`codeBudgetMs` in the forge config; a soft stop, since the grep in flight still finishes, one batch of four) and shows what it has with one link, **More code results** (`?code=all`), that greps the rest. `GET /api/v1/search` applies the same budget and reports the cut as `moreCode`; `code=all` lifts it. MCP `search` does the same, and its `all` argument lifts it. The terminal palette greps everything. A one-letter query greps no code at all (`MIN_CODE_QUERY`, 2 characters): it would match every line, so the page, the API's `note` and MCP say code is searched for 2 or more characters when code was asked for (`kind=all` or `code`), and repositories and issues still answer it. The terminal palette shares the rule — one letter greps nothing and takes no visitor slot — but prints no note: its sections simply show no code.
390390
391 The here-manifest (`GET /api/v1/here?path=…`) reads the same for guests and
391 The here-manifest (`GET /api/v1/here?path=…`) reads the same for visitors and
392392 members. On `/explore` and `/search` it names the page's own read, `?q=` carried
393393 over and encoded: `GET /api/v1/explore?q=…` (MCP tool `explore`) or
394394 `GET /api/v1/search?q=…` (MCP tool `search`), listed once.
docs/features/agents-md.md +1 −1
@@ -9,7 +9,7 @@ Any repository you may read answers `/<owner>/<name>/AGENTS.md`, as plain text.
99 - If the repository has an `AGENTS.md` in its root on the default branch, that file is the answer, word for word.
1010 - If it has none, the forge writes one: how to install, how to run the tests, how commits and pulls are expected, and the contribute flow in five lines, with the exact clone URL and the one host a sandbox must allow (this forge's own).
1111 - A file over 200 KB is not served; the generated text answers and says so.
12 - A private repository answers 404 to anyone who may not read it, a guest included.
12 - A private repository answers 404 to anyone who may not read it, a visitor included.
1313
1414 `/llms.txt` opens with the same doors (git, MCP, the web) and the egress host, and points at this route per repository.
1515
docs/features/bugs.md +1 −1
@@ -9,7 +9,7 @@ An open issue labelled `bug` is answered, fixed or closed as won't fix within a
99 - **Which labels count.** `bug` makes an issue a bug. Also `high`, `priority: high` or `priority:high` (any case) makes it high priority. Pull requests are not bugs.
1010 - **Clocks.** 4 h from the issue's creation when high, 48 h otherwise (`src/flow/bugs.ts`).
1111 - **Pickup order.** Queued agent runs about an open bug start before every other run (`startOrder` in `src/crew/dispatch.ts`). This is policy: bugs also outrank the team dials, which then order the rest. Within each side the queue keeps its order.
12 - **Alarm.** One `bug_clock` alarm names the bug that has gone longest past its clock, and how many more there are. It appears wherever alarms do (home, `/boards`, MCP and API telemetry). For a guest or an agent it counts public repositories only.
12 - **Alarm.** One `bug_clock` alarm names the bug that has gone longest past its clock, and how many more there are. It appears wherever alarms do (home, `/boards`, MCP and API telemetry). For a visitor or an agent it counts public repositories only.
1313 - **Tile.** Home's **Open bugs** tile (admins only) shows the open count and how many are past their clock; it links to `/boards`.
1414 - **Terminal.** The **Bugs** palette entry shows the same count (admins who are people) and the alarm (cut to public for everyone else).
1515 - **Closing.** Closing a bug needs a reason: see `bug-close.md`.
docs/features/changelog.md +2 −2
@@ -6,7 +6,7 @@ row: Changelog
66
77 `GET /changelog` is public. It lists the last 30 `Release <version>: …` commits on the default branch of the forge's own repository (`FORGE_REPO`), newest first. Each has a heading anchored `#<version>`, its date, and one link per pull named in the subject (`title (#N);title (#N)`). When `FORGE_REPO` is unset or its repository is private, the page answers 200 with "No releases yet". The footer links to it.
88
9 The terminal's palette has `Changelog`, the same read for anyone, a guest included. `/` takes a word and keeps only releases whose version or carried pull titles contain it, ignoring case; the header says how many match, and `esc` clears it. Enter on a release lists its pulls (`#N title`); a release whose subject names none shows "No pulls". Enter on a pull opens it, as Enter does on any pull. `w` reads the changelog by wave, as the page's "Read it by wave" link does: Enter on a wave opens its changes, Enter on a change opens its pull, and `esc` goes back to the row you left. It goes through `sourceFor`, so a repository the reader may not open stays closed. Tested in `test/tui-changelog-waves.test.ts`.
9 The terminal's palette has `Changelog`, the same read for anyone, a visitor included. `/` takes a word and keeps only releases whose version or carried pull titles contain it, ignoring case; the header says how many match, and `esc` clears it. Enter on a release lists its pulls (`#N title`); a release whose subject names none shows "No pulls". Enter on a pull opens it, as Enter does on any pull. `w` reads the changelog by wave, as the page's "Read it by wave" link does: Enter on a wave opens its changes, Enter on a change opens its pull, and `esc` goes back to the row you left. It goes through `sourceFor`, so a repository the reader may not open stays closed. Tested in `test/tui-changelog-waves.test.ts`.
1010
1111 One bounded `git log` read, cached per head oid; Server-Timing names `releases` and `render`.
1212
@@ -16,7 +16,7 @@ A pull on the page that a release carried says which: `in 0.3.0 a1b2c3d…e4f5a6
1616
1717 ## How close each open milestone is (#11409)
1818
19 `/changelog` opens with one line per open milestone of the forge's own repository: its name (linked to its milestone page), `N of M done` and a progress bar. A deferred or closed milestone is left out, and the block is absent when none is open or when the reader may not open the repository (a guest on a private one). The terminal's Changelog screen shows the same lines above the releases (name, `N of M done`, at most five), under the same read check. Both read `nearMilestones` in `web/pages/milestones_near.ts`; the page's `ETag` includes them.
19 `/changelog` opens with one line per open milestone of the forge's own repository: its name (linked to its milestone page), `N of M done` and a progress bar. A deferred or closed milestone is left out, and the block is absent when none is open or when the reader may not open the repository (a visitor on a private one). The terminal's Changelog screen shows the same lines above the releases (name, `N of M done`, at most five), under the same read check. Both read `nearMilestones` in `web/pages/milestones_near.ts`; the page's `ETag` includes them.
2020
2121 ## What went live (#7672)
2222
docs/features/claim-own-name.md +1 −1
@@ -16,7 +16,7 @@ or passkey given), so the apps already under the name stay where they are.
1616 claim works with JavaScript off. The fragment script fills it from `#…` and
1717 then hides it.
1818 - **Terminal.** The terminal does not take the name: it ends at a link to finish
19 in the browser. Its guest menu's Start my forge gives that link, and a closed
19 in the browser. Its visitor menu's Start my forge gives that link, and a closed
2020 sign-up there says to choose it.
2121 - **Credit.** A run on the host's included credit is budgeted at most what is
2222 left of it (`cappedByLent`), and the host is asked at the run's end
docs/features/claimed-forge-door.md +1 −1
@@ -9,6 +9,6 @@ On a hosted forge someone has claimed, `/` for a signed-out visitor says "This i
99 - **Who the owner is:** read from the record, not guessed. `parent.json` names the organisation the forge was spawned as (`org`). If a person took that name (`becomeOrg`), they are the owner; otherwise the organisation's Owners team: its one person, or, with several, the forge's own name. Code: `src/spawn/forge_owner.ts`.
1010 - **When it applies:** `parent.json` exists, an admin exists, and the visitor is signed out on `/`. A signed-in viewer keeps the studio.
1111 - **Sign in:** `/signin` (with `?next=` for shared words in the query), or the platform edge's login when an edge token is set.
12 - **The terminal:** unchanged. A guest's key that no account holds is refused at the door (`Permission denied (publickey)`, `src/ssh/keys.ts`), so a guest sees nothing of a claimed forge there.
12 - **The terminal:** unchanged. A visitor's key that no account holds is refused at the door (`Permission denied (publickey)`, `src/ssh/keys.ts`), so a visitor sees nothing of a claimed forge there.
1313 - Page: `src/web/studio/door_claimed.ts`, using only the front page's classes; test: `test/home-claimed-forge.test.ts`.
1414 - **Why now:** a stranger on a claimed forge was shown a sales page for a product they are already inside; it is a one-page change with no pipeline dependency.
docs/features/client-last-activity.md +1 −1
@@ -8,6 +8,6 @@ Each made forge's row on `/forges` says when a person last did anything in it: *
88
99 - One phrase per row: when the row already carries the seen line (sent · opened · last seen), that line says it and these words are left out, on the page and in the terminal (`rowActivityWords`).
1010 - Days are whole UTC days (23:59 yesterday is yesterday, 00:01 today is today). A time in the future reads as today; a value that is not a time reads as never opened.
11 - The terminal client list (`/forges` screen) shows the same words to the sender, and only to the sender, as the page does (the page is the sender's own list). They replace the older "a person last did something …" line, which a guest in the terminal still gets; the exact time is the span's `title` on the page.
11 - The terminal client list (`/forges` screen) shows the same words to the sender, and only to the sender, as the page does (the page is the sender's own list). They replace the older "a person last did something …" line, which a visitor in the terminal still gets; the exact time is the span's `title` on the page.
1212
1313 Tests: `test/client-seen.test.ts`.
docs/features/clog-watch.md +1 −1
@@ -6,7 +6,7 @@ row: Clog watch
66
77 Once a minute the forge reads its flow (open pulls that conflict, pulls opened and landed over 2 h, the oldest approved wait) and declares a clog on the thresholds in `src/flow/clog.ts`. A clog clears after two quiet readings.
88
9 - **Where to see it (admin only):** home shows one muted line while a clog stands (`Clogged for 30 h (noticed 30 h in): <cause>.`) and, for a day after, the last cleared note (cause, time to detect, time to clear). The terminal's Flow dialog shows the same lines. A guest and an agent see neither.
9 - **Where to see it (admin only):** home shows one muted line while a clog stands (`Clogged for 30 h (noticed 30 h in): <cause>.`) and, for a day after, the last cleared note (cause, time to detect, time to clear). The terminal's Flow dialog shows the same lines. A visitor and an agent see neither.
1010 - **Time to detect** is declared-minus-started. The start is the oldest approved pull's wait when that is what clogs; for any other reason it is the reading itself, so the note leaves the line out.
1111 - **State:** `clog_state` (the standing clog) (with `started_at`, when it really began); the last cleared note is the `clog.cleared` event. Events `clog.started` and `clog.cleared` go to the outbox for admins.
1212 - **Code:** `flow/clog_tick.ts` (the tick), `flow/clog_read.ts` (the reader), `flow/clog_watch.ts` and `flow/clog_note.ts` (the pure steps).
docs/features/code-scanning.md +1 −1
@@ -44,7 +44,7 @@ the findings page says so: "partial: N files not read".
4444 `src/tui/screens/findings.ts`) lists the same findings from the same reads.
4545 On an open finding, `a` asks why it may stand and accepts it through the
4646 same action as the page's form (`src/actions/scan_accept.ts`): a reader,
47 an agent or a guest is refused, a guest sees nothing of a private
47 an agent or a visitor is refused, a visitor sees nothing of a private
4848 repository, and an acceptance made there shows on the web page.
4949
5050 ## Holding a release
docs/features/data-browser.md +2 −2
@@ -4,7 +4,7 @@ row: Data browser (core)
44 ---
55 # Data browser (core)
66
7 `src/data/` reads SQLite files a viewer may see. Reach it at `/data` (the Data button on Apps, for an admin or an app's writer), in the terminal as the palette command Data, or through the MCP tool `data`. An admin or a writer of an app gets the page (an empty state until a database exists); a guest or a reader gets a 404, no palette entry, and nothing from the tool.
7 `src/data/` reads SQLite files a viewer may see. Reach it at `/data` (the Data button on Apps, for an admin or an app's writer), in the terminal as the palette command Data, or through the MCP tool `data`. An admin or a writer of an app gets the page (an empty state until a database exists); a visitor or a reader gets a 404, no palette entry, and nothing from the tool.
88
99 - `listSources(db, dataDir, viewer)` — `forge.db` for admins; for each app the viewer can write, every `.db` under each environment's data dir. `findSource` resolves an id only through that list, so a reader gets `undefined` (a 404), and no input becomes a path.
1010 - `tables(source)`, `rows(source, table, {filter, order, page})` — 50 rows a page; table and column names are checked against the schema.
@@ -32,4 +32,4 @@ Cost of a query: `query` also returns `rowsRead` (rows the query produced, the o
3232
3333 MCP `data` with `spec: true` lists operations (`area`, `method`, `path`, `summary`; 300 at most, with `total` saying how many matched) for what the forge's contract says as your role may call it; add `q` to narrow by words, or `repo` for that app's own OpenAPI document (docs/features/api-reference.md; the same door as its API tab: a 404 where you may not enter the app, and a plain answer that it serves none when it has none). `src/data/spec_scope.ts` reads it through `reference` (`src/contract/reference.ts`), the reading the web `/api` page and the terminal API screen (`src/tui/screens/api.ts`) already use.
3434
35 Three doors, one reading. In the data tree the spec is a file named `openapi.json`: the forge's own at the bottom of `/data` and of the terminal's Data screen (only for someone who sees any file there), and each app's after its environments (the app's Data tab on the web, the app node in the terminal; Enter or `l` opens it, `y` yanks `METHOD /path`). On the web it is `?spec=1` on `/data` and on `/:owner/:name/data`; a reader and a guest get the same 404 or sign-in as for the databases, and an app's document is asked through `appSpec`, which still checks `canEnterApp`. It reads the app's production environment only; a preview's document is not read here. The canonical place to read and try operations stays `/api` and `/:owner/:name/api` (and the terminal's API screen): the `openapi.json` nodes and the MCP tool link to them and add no second listing, only the same `reference` rows.
35 Three doors, one reading. In the data tree the spec is a file named `openapi.json`: the forge's own at the bottom of `/data` and of the terminal's Data screen (only for someone who sees any file there), and each app's after its environments (the app's Data tab on the web, the app node in the terminal; Enter or `l` opens it, `y` yanks `METHOD /path`). On the web it is `?spec=1` on `/data` and on `/:owner/:name/data`; a reader and a visitor get the same 404 or sign-in as for the databases, and an app's document is asked through `appSpec`, which still checks `canEnterApp`. It reads the app's production environment only; a preview's document is not read here. The canonical place to read and try operations stays `/api` and `/:owner/:name/api` (and the terminal's API screen): the `openapi.json` nodes and the MCP tool link to them and add no second listing, only the same `reference` rows.
docs/features/events.md +1 −1
@@ -8,7 +8,7 @@ row: Events in the browser
88
99 `?kind=` narrows to one event kind (`?kind=pull.merged`), the same `kind` MCP `events` and `GET …/events` take; one that is not a kind (`validEventsKind`) answers 404. Each row has a button beside it in a person's words ("Merged pulls", from `eventKindLabel`) that links to its kind, 44px tall on a thumb; the raw kind appears only in the URL. A narrowed page says "Showing: Merged pulls" with an **All events** button beside the heading, and the next-page link keeps `kind`. A kind with no events says "No <kind> events" and offers All events.
1010
11 The audience is the same as MCP `events` and `GET …/events`, because the page reads the same `eventsPage`: a webhook's URL and an app's variable names are the admins'. A public repository answers a guest with 200; a private one answers 404 to anyone who cannot read it. A row links to its page when the event has one (an issue, a push's commits) and is a plain row otherwise.
11 The audience is the same as MCP `events` and `GET …/events`, because the page reads the same `eventsPage`: a webhook's URL and an app's variable names are the admins'. A public repository answers a visitor with 200; a private one answers 404 to anyone who cannot read it. A row links to its page when the event has one (an issue, a push's commits) and is a plain row otherwise.
1212
1313 The terminal's version is `v` on the About card (see the README). `enter` on a row opens the issue or pull the event names (a `pull.*` event opens the pull, any other the issue); the issue and pull screens check access themselves, and `esc` returns to the list at the same row. A push or a settings row names no number and opens nothing, and the key bar shows `enter open` only when the selected row can open something. `t` keeps only the kind of the row under the cursor and `t` again lifts it; `s` keeps only settings changes.
1414
docs/features/explore.md +1 −1
@@ -81,7 +81,7 @@ One rule for what `/explore` does not take (#14392): an unknown sort, kind in `q
8181
8282 ## Mine (#13161)
8383
84 `mine=yes` (or `mine:yes` in a line) keeps the viewer's own apps and the viewer's own person row: the owner is the viewer's name. Signed out it matches nothing, never everyone. Filters live in the URL, so `/explore?kind=app&mine=yes&sort=fresh` reloads and sends as the same view, and equals choosing Apps, Mine and Fresh by hand, row for row (`test/explore-url-filters.test.ts`). The terminal's search line takes `mine:yes` the same way (`mine:yes` after `/`): a guest sees no rows, the signed-in viewer sees their own (`test/tui-dashboard-explore.test.ts`). A `mine:` value other than yes or no is an unknown word like the others.
84 `mine=yes` (or `mine:yes` in a line) keeps the viewer's own apps and the viewer's own person row: the owner is the viewer's name. Signed out it matches nothing, never everyone. Filters live in the URL, so `/explore?kind=app&mine=yes&sort=fresh` reloads and sends as the same view, and equals choosing Apps, Mine and Fresh by hand, row for row (`test/explore-url-filters.test.ts`). The terminal's search line takes `mine:yes` the same way (`mine:yes` after `/`): a visitor sees no rows, the signed-in viewer sees their own (`test/tui-dashboard-explore.test.ts`). A `mine:` value other than yes or no is an unknown word like the others.
8585
8686 `template=<name>` (or `template:<name>` in a line) keeps the forges whose spawn record names that template, a built-in id or `owner/name`: `/explore?template=trevato/shop`. It lists forges only, and only admins see forge rows, so anyone else gets an empty list worded "No forges to show for <name>". The value is checked against the template name shapes and matched by equality, never in SQL; one that is no template name is an unknown word, refused like the others. A chip `template:<name>` clears it. The terminal's search line takes `template:<id>` the same way (`readExploreLine`). Covered by `test/explore-template.test.ts`.
8787
docs/features/first-wrong.md +1 −1
@@ -11,7 +11,7 @@ When something needs you, home says so in one calm line under the title, with th
1111 3. **A pull whose check is stuck** (anyone who can write to its repository).
1212 4. **The crew past its share of the week** (admins).
1313
14 When all is well there is no line, and a guest never sees one.
14 When all is well there is no line, and a visitor never sees one.
1515
1616 The terminal home shows the same line, read by the same function, with the web path to fix it at the end. The allowance line waits until the week has a share above zero.
1717
docs/features/flow-declines.md +1 −1
@@ -16,4 +16,4 @@ Reasons: *already on main*, *not on main yet*, *off direction*, *other*. Each sh
1616 - **Terminal:** the Flow command (palette), the same line under the review latency.
1717 - **Agents:** the `flow` MCP tool with no arguments returns `declines` (`says`, `groups`, `runs`).
1818
19 One reader serves all three (`readDeclines` in `src/flow/declines.ts`). A site admin sees every repository; an agent or guest reader sees public repositories only. The figure is cached with the rest of the panel for 30 seconds.
19 One reader serves all three (`readDeclines` in `src/flow/declines.ts`). A site admin sees every repository; an agent or visitor reader sees public repositories only. The figure is cached with the rest of the panel for 30 seconds.
docs/features/flows.md +1 −1
@@ -15,7 +15,7 @@ row: Flows
1515 - **Link health (#9561).** Every line carries a health badge: healthy, news, diverged, unreadable, not read lately (no comparison in 90 minutes) or paused (`followHealth`, `src/flows/view.ts`). A mirror's own origin shows as a line from the head reading in `origin-ahead.md`.
1616 - **Probe.** The clock already compares heads (`checkDue` for the upstream and sources, `runAheadReads` for an origin); an admin's *Compare heads now* (`POST /:owner/:name/flows/probe`, `src/flows/probe.ts`) runs the same reads on ask: admin only, never an agent, one at a time, four a minute.
1717 - **Bounded.** A probe reads at most 8 enabled sources, four at a time, and answers within 30 s; it announces itself (`repo.links_probed`, readers of the repository) so an open page offers the refresh. An origin line is stale on the same 90-minute rule; every origin reading records when it was taken.
18 - **Terminal.** The Flows screen shows the same lines with health tones and the same gates: `c` compares heads (admin), `p` pulls in what's new (writer, `takeFromOrigin`), `o` names the page that offers a pull to the parent. A guest sees only what they may read.
18 - **Terminal.** The Flows screen shows the same lines with health tones and the same gates: `c` compares heads (admin), `p` pulls in what's new (writer, `takeFromOrigin`), `o` names the page that offers a pull to the parent. A visitor sees only what they may read.
1919 - **Actions.** A writer of a mirror with news sees *Pull in what's new* (the existing `sync/take`, which refuses a diverged mirror); a writer of a fork sees *Offer what's useful* (the existing pull-to-parent page).
2020
2121 - **Advisories.** The same *Read upstream releases now* also asks the npm registry's bulk advisory endpoint about each exact pin and stores a one-line answer (severity, title, `(+N more)` when there are several) in `dep_latest.advisory`. A package with one shows an *advisory* badge and the text on the page and in the terminal (`depState`, `src/flows/radar.ts`, words both). They refresh only on that button: the page never calls the registry. The advisory ask is a second request per package inside the same 30 s run deadline.
docs/features/growth.md +1 −1
@@ -26,7 +26,7 @@ is paused, and what the caller may see.
2626 issues opened and closed this week and how many issues and pulls are open now. The MCP `system` tool with
2727 `{ kind: "growth", repo }` answers `{openIssues, openPulls, openedToday, closedToday, openedWeek, closedWeek}`
2828 (today is the UTC day; the week is seven UTC days) from the same read, for a reader of the repository only; a
29 guest or a non-reader of a private repository gets a refusal, and sealed issues are left out for anyone who may
29 visitor or a non-reader of a private repository gets a refusal, and sealed issues are left out for anyone who may
3030 not see them. Today's numbers are in that answer only; the page and terminal show the week.
3131
3232 Closed-per-day has no index of its own: it walks the repository's rows through the existing `repo_id` index
docs/features/home-plans.md +1 −1
@@ -9,7 +9,7 @@ Where a visitor sees what a hosted forge is and how to get one (#11139).
99 ## Where
1010
1111 - Web: the signed-out home, section **Get your own forge** (`/#yours`): one line per plan, then one **Get a forge** button to `/forges/new`, then the free, open-source way to run it yourself (the guide link and the clone commands).
12 - Terminal: the palette's **Get your own forge** (`src/tui/screens/getforge.ts`), offered to everyone, guests included: the same plans, `Get a forge: <origin>/forges/new`, and the clone commands.
12 - Terminal: the palette's **Get your own forge** (`src/tui/screens/getforge.ts`), offered to everyone, visitors included: the same plans, `Get a forge: <origin>/forges/new`, and the clone commands.
1313 - `/llms.txt`: the "Get your own forge" line points at the plans on the home and at `/forges/new`.
1414
1515 ## What a plan line says
docs/features/issue-cost.md +2 −2
@@ -36,11 +36,11 @@ to know what a piece of work cost before they look at the whole ledger.
3636 `src/core/issue_cost.ts`): the viewer must read the repository's runs, see
3737 the owner's facts (as the runs list hides cost from other readers), and be
3838 allowed to see the issue. A sealed pull the viewer may not see is left out
39 of the sum. A guest sees nothing.
39 of the sum. A visitor sees nothing.
4040
4141 ## API and MCP
4242
4343 `GET /api/v1/repos/:owner/:name/issues/:n` and the MCP `issue` tool carry
4444 `cost: {usd, own, runs, pulls: [{number, usd}]}`, the number the page prints, from
45 `issueCostFor`. The field is absent when nothing was spent, for a guest, and
45 `issueCostFor`. The field is absent when nothing was spent, for a visitor, and
4646 for a viewer who may not read the runs or see the owner's facts.
docs/features/keeper.md +1 −1
@@ -23,4 +23,4 @@ Two DORA numbers (`keeper_measures.ts`, #13110), over the last 7 days, each with
2323
2424 Still unmeasured: queue-wait p95 and rework per agent from the issue discussion. The two rates are approximations: "next check" is the first main check created within 24 hours after the landing (a release likewise: cut within 24 hours), so a red that one of several batched landings caused is counted against each; a pull landed in the last seven days may yet be reverted, so the revert rate can only rise; a release proof is matched by time, not by the commits it carried, and only for the forge's own repository; the week is rolling, not a calendar week, and no history of past weeks is kept.
2525
26 Who reads what: a site admin reads the sentence with repository names and the question with its button. Everyone else, guests and agents included, reads the cause with no repository in it (`readKeeper(db, full)`). The Flow only switch is retired (#7771), so no act asks a question today; one already on the books is answered with its button, and the answer is a `keeper.answered` event carrying the owner's id.
26 Who reads what: a site admin reads the sentence with repository names and the question with its button. Everyone else, visitors and agents included, reads the cause with no repository in it (`readKeeper(db, full)`). The Flow only switch is retired (#7771), so no act asks a question today; one already on the books is answered with its button, and the answer is a `keeper.answered` event carrying the owner's id.
docs/features/made-from.md +1 −1
@@ -7,7 +7,7 @@ row: Made from: the template a forge came from
77 A forge made from a template repository remembers which one and at what commit. The record is the `template` entry of its `parent.json` (`{ id, repo, tip }`, written when it is made); a forge made without a template repository, or before this was kept, has none and says nothing.
88
99 - **Settings:** `/settings` has a `Started from` row, `<owner>/<name> at <short sha>`, in the same list as the Plan row. The name links to `/templates/<owner>/<name>` only while that repository is still marked as a template and the viewer can read it; otherwise it is plain text.
10 - **Terminal:** the palette entry *Started from* (`src/tui/screens/madefrom.ts`, offered only to a signed-in person and only when the record exists; a guest is told nothing) prints `Started from <template> at <short sha>`.
10 - **Terminal:** the palette entry *Started from* (`src/tui/screens/madefrom.ts`, offered only to a signed-in person and only when the record exists; a visitor is told nothing) prints `Started from <template> at <short sha>`.
1111 - **Parent's read:** `GET /api/v1/forge` returns `madeFrom: { template, at }` (the full commit) only when the caller shows the parent's secret; anyone else, or a wrong secret, gets no `madeFrom`.
1212 - **MCP:** the `forges` tool's rows (admin) carry `madeFrom` (`{ template, at }` or null), read from the record the parent wrote; no new tool.
1313 - **Try it:** make a forge from a template repository, open `/settings`.
docs/features/map-held.md +1 −1
@@ -6,4 +6,4 @@ row: What holds a ready issue
66
77 `GET /api/v1/repos/:owner/:name/map` and the MCP `map` tool give each `ready` entry `held`: `null`, or `{ by, detail }` with `by` one of the names in `src/crew/held.ts` (`open_pull`, `hot_file`, `run_cap`, …). For `hot_file`, `detail` names the file and its count of open pulls. `startable` lists the ready numbers nothing holds.
88
9 Holds are worked out for the viewer: a pull they may not see (a sealed one) neither counts toward a hot file nor holds an issue as `open_pull`. So a guest's `startable` can list an issue the crew will not start; read it as what the viewer can see is free, not as the crew's queue. The direction issue is never in `startable` but shows `held: null`. Hot-file counts come from memory, so a cached map can lag them by up to a minute.
9 Holds are worked out for the viewer: a pull they may not see (a sealed one) neither counts toward a hot file nor holds an issue as `open_pull`. So a visitor's `startable` can list an issue the crew will not start; read it as what the viewer can see is free, not as the crew's queue. The direction issue is never in `startable` but shows `held: null`. Hot-file counts come from memory, so a cached map can lag them by up to a minute.
docs/features/new-forge-template.md +1 −1
@@ -26,7 +26,7 @@ Code: `src/cli/new_template.ts`, the two calls in `src/cli/api.ts` (`templates`,
2626
2727 `/templates` lists what a new forge can start from: the built-in templates, then the template repositories you can read. Each row has one sentence and one secondary button, "Start a forge", which opens `/forges/new?template=<id>` with that template chosen. Signed out works too: a stranger lands on the same form with the template kept. `?template=` is accepted only when spawn accepts it (`parseTemplate`); anything else leaves Blank chosen, and it is never echoed. The plan (`do=plan`) shows "It starts from the <b>…</b> template".
2828
29 The terminal has the same list: the "Templates" command (`src/tui/screens/templates.ts`) shows the same rows; Enter on a row opens New forge with that template chosen, for people signed in, and a guest is told to sign in. Both read `templateList` (`src/spawn/template_list.ts`), so a private template repository is listed only to people who can read it, on the page and in the terminal alike.
29 The terminal has the same list: the "Templates" command (`src/tui/screens/templates.ts`) shows the same rows; Enter on a row opens New forge with that template chosen, for people signed in, and a visitor is told to sign in. Both read `templateList` (`src/spawn/template_list.ts`), so a private template repository is listed only to people who can read it, on the page and in the terminal alike.
3030
3131 ### Filtering the list
3232
docs/features/origin-ahead.md +1 −1
@@ -15,7 +15,7 @@ with **Take them** (`POST /:owner/:name/sync/take`).
1515 started from the same minute tick as `runSync`), never inside the sweep's:
1616 a reading stuck on a slow origin holds only the next reading, never a sync.
1717 - Only a person who may write the repository sees **Take them**; everyone who
18 may read it sees the count, and a guest sees nothing on a private one.
18 may read it sees the count, and a visitor sees nothing on a private one.
1919 - At the terminal: the palette's "New commits upstream" lists the mirrors you
2020 can read that are behind (one query over the readings, not one per
2121 repository); `t` takes them under the page's own check, `requireWriter`
docs/features/report-status.md +1 −1
@@ -35,6 +35,6 @@ The answer to a report or an offer (`…/offers`, the MCP `offer` tool) also car
3535 - **Shows:** `kind`, `state` (received, read, planned, landed or declined), its words, and the dates it arrived, last changed and expires. Never the title, the words, a name or an id.
3636 - **States:** a report is received until a person decides; accepting makes it planned, closing that issue makes it landed (done) or declined (dropped); dismissing declines it. An offer is received, then read once a reviewer reviews, then landed or declined. So a report is never `read` (a person's decision is its first change) and an offer is never `planned`; each shows only the states its own steps can reach.
3737 - **The token:** 192 random bits, read-only, good 90 days; a wrong, malformed or expired one is a 404 (`src/core/outsider_status.ts`, `src/http/offer_routes.ts`). The status routes answer 429 past 60 reads a minute per client, and links past their day are deleted hourly. Pinned by `test/outsider-status.test.ts`.
38 - **Where the owner finds an offer's link (#15988):** on that pull's page, one line with Copy, and on the terminal's pull screen as a `status link:` row. Both ask `offerStatusLinkFor` (`src/core/outsider_status.ts`): writers only, because the link is a capability, and only on a pull an offer opened. A pull the owner opened, or a reader or guest looking, shows no such line. Pinned by `test/outsider-status.test.ts` (page) and `test/pull-next-tui.test.ts` (terminal).
38 - **Where the owner finds an offer's link (#15988):** on that pull's page, one line with Copy, and on the terminal's pull screen as a `status link:` row. Both ask `offerStatusLinkFor` (`src/core/outsider_status.ts`): writers only, because the link is a capability, and only on a pull an offer opened. A pull the owner opened, or a reader or visitor looking, shows no such line. Pinned by `test/outsider-status.test.ts` (page) and `test/pull-next-tui.test.ts` (terminal).
3939
4040 Pinned by `test/report-status.test.ts`.
docs/features/space.md +2 −2
@@ -6,7 +6,7 @@ row: The space
66
77 `/:owner/:name/space` is the map as a plane you move through (#10444). It is
88 linked from the map page ("The same work as a space to move through"). Its data
9 is `/:owner/:name/space.json`, the same plane for an agent. In the terminal it is the `space` entry in the palette (`src/tui/screens/space.ts`): pillars with their counts, issues by state, who of the crew is on what, and the week's landings, under the wave line (below), from the same `spaceOf` and so the same gate as the page (a guest sees what is public, an admin everything).
9 is `/:owner/:name/space.json`, the same plane for an agent. In the terminal it is the `space` entry in the palette (`src/tui/screens/space.ts`): pillars with their counts, issues by state, who of the crew is on what, and the week's landings, under the wave line (below), from the same `spaceOf` and so the same gate as the page (a visitor sees what is public, an admin everything).
1010
1111 ## Use
1212
@@ -16,7 +16,7 @@ is `/:owner/:name/space.json`, the same plane for an agent. In the terminal it i
1616 - **Time.** The scrubber replays the last 7 days: issues appear when opened, slide from "in review" to "landed" when they close, and crew members sit on what they were running then. **Play** runs the week in 20 seconds. At **Now** the view is live: any run, issue or pull event of the repository fetches the plane again.
1717 - **Crew.** Their avatars sit on the issue they are working; tap one (or its name in the bar) to see what they are on.
1818 - **Legend.** **Legend**, above the scrubber, says what size, ink and distance mean and gives each state one line. It starts closed; on a wide screen it opens once, on a first visit, and stays closed after. It is real HTML from `space_model.ts`, so it reads without the script.
19 - **The wave line.** Under the repository's name the page says which wave is in flight and how many of its issues landed (a pull merged) in the last 24 hours, or that the crew is resting when none is open (`src/story/wave_today.ts`). The terminal screen opens with the same line. Sealed work is counted only for a reader who may see it: its author, or one who sees sealed work; a guest's count leaves it out.
19 - **The wave line.** Under the repository's name the page says which wave is in flight and how many of its issues landed (a pull merged) in the last 24 hours, or that the crew is resting when none is open (`src/story/wave_today.ts`). The terminal screen opens with the same line. Sealed work is counted only for a reader who may see it: its author, or one who sees sealed work; a visitor's count leaves it out.
2020 - **One line and `?q=`.** Above the fold, one line says size, colour and distance. The Find box is a plain GET form: `/:owner/:name/space?q=login` lists the matching issues as links (or says "No issue matches") without script; with script the view also flies to the first. In the terminal the same one line opens the screen.
2121 - **Share.** The view is in the address hash: `#x=…&y=…&z=…` (centre in world units, zoom relative to Fit) and `&t=` (minutes since the epoch) when scrubbed back.
2222
docs/features/start-my-forge.md +1 −1
@@ -15,7 +15,7 @@ A signed-out visitor starts their own forge from the home page, with no account
1515
1616 The field is a slug, so it turns off autocomplete and capitalisation on phones. The form is in `src/web/studio/home.ts`; its test is `test/home-start-forge.test.ts`.
1717
18 In the terminal, a guest's "Start my forge" command (`src/tui/screens/startforge.ts`) asks for the name, goes through the same `spawnDoor` as a stranger (counted under the SSH client's address), shows a refusal in the same fixed sentences as the home page, and shows the claim link once. Signed in, "New forge" is the fuller form. Test: `test/tui-startforge.test.ts`.
18 In the terminal, a visitor's "Start my forge" command (`src/tui/screens/startforge.ts`) asks for the name, goes through the same `spawnDoor` as a stranger (counted under the SSH client's address), shows a refusal in the same fixed sentences as the home page, and shows the claim link once. Signed in, "New forge" is the fuller form. Test: `test/tui-startforge.test.ts`.
1919
2020 ## When the door refuses
2121
docs/features/subtitle-shift.md +1 −1
@@ -4,7 +4,7 @@ row: Shift a subtitle file
44 ---
55 # Shift a subtitle file
66
7 A `.srt` or `.vtt` file's page has a "Shift every cue by (seconds)" field for writers. Type `2.5` or `-1`, press "Shift and save": every cue's start and end move by that much and the result is saved as one commit, "Shift subtitles by +2.5 s". Readers and guests see no field.
7 A `.srt` or `.vtt` file's page has a "Shift every cue by (seconds)" field for writers. Type `2.5` or `-1`, press "Shift and save": every cue's start and end move by that much and the result is saved as one commit, "Shift subtitles by +2.5 s". Readers and visitors see no field.
88
99 - The offset is a signed decimal in seconds, at most 3600 either way; anything else is refused on a page that says why and writes nothing. A time never goes below zero.
1010 - Only the two timestamps of each timing line change. Numbers, ids, cue settings, notes, text and line endings (LF or CRLF) are kept byte for byte. A timestamp is written as `MM:SS.mmm` with three millisecond digits (`1,5` becomes `1,500`); an hour field keeps the digits it had (`1:02:03,004` stays `1:02:03,004`), and a WebVTT stamp without hours grows one only when the shift carries it past an hour.
docs/features/traffic-sources.md +1 −1
@@ -59,6 +59,6 @@ seconds, dropped when views are written, so a page and its probe calls share it.
5959
6060 **Terminal.** Palette "Traffic sources" (`src/tui/screens/trafficview.ts`) is the
6161 forge's view for an admin; with a repository open, "<owner>/<name> — Traffic
62 sources" is that app's view for those who administer it. A guest is offered
62 sources" is that app's view for those who administer it. A visitor is offered
6363 neither. `w` window, `s` people/scrapers, Enter narrows, `c` clears, `t` types
6464 the path steps. It does not call the probe; use the web page for that.
docs/features/week-pace.md +1 −1
@@ -21,4 +21,4 @@ Bets are not in the forge yet, so the release above falls back to the lowest-num
2121
2222 ## In the terminal (#15853)
2323
24 The terminal's week screen ends its facts with the allowance line: pulls landed in the last seven days, the percent of the weekly allowance used, and what the rest buys at that pace. The words come from `allowanceLine` in `src/actions/usage.ts`, written there for the `/week` page and MCP tool of #15818 to import; today the terminal is its only caller. The percent is the crew's own, `crewWeekFor(...).usedPct` (the figure the handover reports), so no surface computes a second one. Spend is the owner's fact: `allowanceLine` returns null for anyone `canSeeOwnerFacts` refuses, so a guest on a public repo sees the retrospective without the line, whichever surface asks. Tested in `test/tui-week-line.test.ts`.
24 The terminal's week screen ends its facts with the allowance line: pulls landed in the last seven days, the percent of the weekly allowance used, and what the rest buys at that pace. The words come from `allowanceLine` in `src/actions/usage.ts`, written there for the `/week` page and MCP tool of #15818 to import; today the terminal is its only caller. The percent is the crew's own, `crewWeekFor(...).usedPct` (the figure the handover reports), so no surface computes a second one. Spend is the owner's fact: `allowanceLine` returns null for anyone `canSeeOwnerFacts` refuses, so a visitor on a public repo sees the retrospective without the line, whichever surface asks. Tested in `test/tui-week-line.test.ts`.
src/core/principal.ts added +101
@@ -0,0 +1,101 @@
1 /**
2 * Principal: who is asking, as one value. `Auth` (`http/context.ts`) is a bag
3 * of optional fields; this names what the bag means. Anonymous is a value, not
4 * `undefined`. A principal has a `kind` (how it arrives: no credential, the
5 * session itself, or one of the token kinds) and, when someone is behind it, a
6 * `subject` (what is asking: a person, an agent or an app). Additive: nothing decides on it yet,
7 * so no route's answer changes (docs/ROLES.md, "The words").
8 */
9
10 import type { Auth } from "../http/context.ts";
11 import type { ContributeScope } from "./contribute_token.ts";
12 import type { Proposal } from "./proposal_token.ts";
13 import type { RunScope } from "./run_token.ts";
14 import type { TokenScope } from "./tokens.ts";
15 import type { User } from "./users.ts";
16
17 /** What is asking, read from an account. */
18 export type Subject =
19 | { readonly kind: "person"; readonly user: User }
20 | { readonly kind: "agent"; readonly user: User }
21 | { readonly kind: "app"; readonly user: User; readonly appId: string };
22
23 /** Who is asking and nothing else is known; a credential sent and refused still lands here. */
24 export interface Anonymous {
25 readonly kind: "anonymous";
26 /** A credential was sent and matched nothing. */
outdated

runner, device and game_box are never produced by principalOf: remove until the slice that creates them, with a test.

27 readonly refused: boolean;
28 /** Seconds to wait when a password was turned away by the sign-in windows. */
29 readonly retryAfter?: number;
30 }
31
32 /** The account itself: a session cookie, the platform edge or the password. */
33 export interface SessionPrincipal {
34 readonly kind: "session";
35 readonly subject: Subject;
36 /** `none`: a terminal screen acting for the signed-in person it belongs to. */
37 readonly via: "session" | "edge" | "password" | "none";
38 readonly sessionId?: string;
39 }
40
41 interface TokenBase {
42 readonly subject: Subject;
43 readonly tokenId: string | undefined;
44 readonly tokenName: string | undefined;
45 }
46
47 export type TokenPrincipal =
48 | (TokenBase & { readonly kind: "ro_token" | "rw_token" | "admin_token" })
49 | (TokenBase & { readonly kind: "proposal_token"; readonly proposal: Proposal })
50 | (TokenBase & { readonly kind: "run_token"; readonly run: RunScope })
51 | (TokenBase & { readonly kind: "contribute_token"; readonly contribute: ContributeScope })
52 | (TokenBase & { readonly kind: "read_grant_token"; readonly appId: string })
53 /** The forge's own agent speaking for this person in one conversation. */
54 | (TokenBase & { readonly kind: "via_token"; readonly through: string });
55
56 export type Principal = Anonymous | SessionPrincipal | TokenPrincipal;
57 export type PrincipalKind = Principal["kind"];
58
59 function subjectOf(user: User, appId: string | undefined): Subject {
60 if (appId !== undefined) return { kind: "app", user, appId };
61 return user.kind === "agent" ? { kind: "agent", user } : { kind: "person", user };
62 }
63
64 /**
65 * The principal for today's `Auth`. A token that carries several scopes is the
66 * narrowest: proposal, then run, contribute, an app's read grant, a via token,
67 * then its plain `ro`/`rw`/`admin` scope — the order the gates meet them in.
68 */
69 export function principalOf(auth: Auth): Principal {
70 const user = auth.user;
71 if (user === undefined) {
72 return {
73 kind: "anonymous",
74 refused: auth.refused === true,
75 ...(auth.retryAfter !== undefined ? { retryAfter: auth.retryAfter } : {}),
76 };
77 }
78 const subject = subjectOf(user, auth.appId);
79 if (auth.via === "token") {
80 const base: TokenBase = { subject, tokenId: auth.tokenId, tokenName: auth.tokenName };
81 if (auth.proposal) return { ...base, kind: "proposal_token", proposal: auth.proposal };
82 if (auth.run) return { ...base, kind: "run_token", run: auth.run };
83 if (auth.contribute) return { ...base, kind: "contribute_token", contribute: auth.contribute };
84 if (auth.appId !== undefined) return { ...base, kind: "read_grant_token", appId: auth.appId };
85 if (auth.through !== undefined) return { ...base, kind: "via_token", through: auth.through };
86 const scope: TokenScope = auth.scope ?? "ro";
87 return { ...base, kind: `${scope}_token` };
88 }
89 return {
90 kind: "session",
91 subject,
92 via: auth.via,
93 ...(auth.sessionId !== undefined ? { sessionId: auth.sessionId } : {}),
94 };
95 }
96
97 /** The account behind a principal, when there is one: none for anonymous. */
98 export function userOf(principal: Principal): User | undefined {
99 if (principal.kind === "anonymous") return undefined;
100 return principal.subject.user;
101 }
src/http/server.ts +1 −1
@@ -124,7 +124,7 @@ const NO_AUTH: Auth = { user: undefined, scope: undefined, via: "none" };
124124 /** A credential was sent and matched nothing: still no one, but `here` says so. */
125125 const NO_MATCH: Auth = { ...NO_AUTH, refused: true };
126126
127 async function resolveAuth(app: App, request: Request): Promise<Auth> {
127 export async function resolveAuth(app: App, request: Request): Promise<Auth> {
128128 // A read-only standby knows no one: a session or token of the main forge
129129 // must not show its private pages on a copy (#9657).
130130 if (app.config.readOnly === true) return NO_AUTH;
src/http/usage_tag.ts +2 −1
@@ -7,6 +7,7 @@
77 * whatever strangers type, so the table never grows with their input.
88 */
99
10 import { principalOf, userOf } from "../core/principal.ts";
1011 import type { Auth } from "./context.ts";
1112 import { METHODS, type UsageRole, type UsageSurface } from "../core/usage_count.ts";
1213
@@ -33,7 +34,7 @@ const doors = new WeakMap<Request, Door>();
3334
3435 /** The viewer's role: a token for an agent account is `agent`. */
3536 export function roleOf(auth: Auth): UsageRole {
36 const user = auth.user;
37 const user = userOf(principalOf(auth));
3738 if (user === undefined) return "anon";
3839 if (user.kind === "agent") return "agent";
3940 return user.isAdmin ? "admin" : "user";
src/tui/forge_parts.ts +1 −1
@@ -848,7 +848,7 @@ export function forgeCommands(session: Session): (ctx: Ctx) => Command[] {
848848 */
849849 export function forgeSearch(session: Session): (ctx: Ctx) => PaletteSearch {
850850 return (ctx) => async (query, live, signal) => {
851 // A guest is a stranger with a key: its search greps code under the same
851 // A visitor is a stranger with a key: its search greps code under the same
852852 // limits as the page's and the API's (`http/strangers.ts`), counted
853853 // under its peer address. Refused, everything but the code is searched.
854854 // A one-letter query greps nothing (#11120), so it takes no slot either.
src/tui/main.ts +1 −1
@@ -2,7 +2,7 @@
22 * The local dev runner: the same terminal UI, over stdio, against a data
33 * directory on this machine.
44 *
5 * bun run src/tui/main.ts # as a guest
5 * bun run src/tui/main.ts # as a visitor
66 * bun run src/tui/main.ts --user alice # as alice
77 * FORGE_DATA=./data bun run src/tui/main.ts
88 *
src/tui/screens/api.ts +3 −2
@@ -40,7 +40,7 @@ export interface Answer {
4040 readonly body: string;
4141 }
4242
43 /** GET `path` through the forge's router as this session's person (a guest: anonymously). */
43 /** GET `path` through the forge's router as this session's person (a visitor: anonymously). */
4444 export async function runGet(f: Session, path: string): Promise<Answer> {
4545 const { forgeHttp } = await import("../../http/server.ts");
4646 const http = forgeHttp(f.app);
@@ -94,7 +94,8 @@ function answerScreen(ctx: Ctx, op: Operation, answer: Answer): Screen {
9494 export function apiScreen(f: Session, ctx: Ctx): Screen {
9595 const state = new ListState();
9696 const filter = new Filter();
97 // The rows this person may call, as the page cuts them: a guest reads the anonymous ones (#11286).
97 // The rows this person may call, as the page cuts them: a visitor reads the anonymous ones
98 // (#11286).
9899 const doc = openapiText(f.app.config.url ?? "http://localhost", announcedOr(), roleOf(f));
99100 const all = apiOperations(reference(JSON.parse(doc.text)));
100101 const shown = (): Operation[] => apiOperations(narrow([{ name: "", operations: all }], filter.query)).slice(0, MAX_SHOWN);
src/tui/screens/bets.ts +2 −2
@@ -5,7 +5,7 @@
55 * `c` cuts, `e` ends a stopped bet as done, `l` writes what is left, `d` says
66 * it feels done and `n` not yet. All of it goes through `actions/bets.ts`, so
77 * who may act, the rules and the events web pages follow are the same; an
8 * agent, a guest or a reader without admin sees nothing and does nothing.
8 * agent, a visitor or a reader without admin sees nothing and does nothing.
99 */
1010
1111 import { backBet, betEstimate, capBet, endBet, giveVerdict, proposeBets, stopBet, writeLeft, type BetError } from "../../actions/bets.ts";
@@ -30,7 +30,7 @@ interface Line {
3030 readonly bet: Bet;
3131 }
3232
33 /** The repositories this session's person administers; none for a guest or an agent. */
33 /** The repositories this session's person administers; none for a visitor or an agent. */
3434 function administered(f: Session): Repo[] {
3535 const user = f.user;
3636 if (user === undefined || user.kind === "agent") return [];
src/tui/screens/bugs.ts +1 −1
@@ -2,7 +2,7 @@
22 * Bugs on a clock in the terminal (#8709): the figure home's Open bugs tile
33 * shows and the bug_clock alarm, from `flow/bugs.ts`. Gated as the page is:
44 * the count is a person-admin's (the tile counts every repository), and any
5 * other reader, an agent or a guest included, sees only the alarm cut to
5 * other reader, an agent or a visitor included, sees only the alarm cut to
66 * public repositories (`publicOnly`). Read-only; Esc closes it.
77 */
88
src/tui/screens/changelog.ts +1 −1
@@ -1,6 +1,6 @@
11 /**
22 * The changelog, the terminal's /changelog: the same `forgeChangelog` read the
3 * page makes, for anyone, a guest included. Each release is a row: version,
3 * page makes, for anyone, a visitor included. Each release is a row: version,
44 * date and the pulls it carried. `/` narrows them by a word of the version or a
55 * pull title; Enter lists a release's pulls, and Enter on a pull opens it. `w` reads it by wave, as
66 * the page's link does: Enter on a wave opens its changes, Enter on a change opens its pull, and
src/tui/screens/dashboard.ts +4 −4
@@ -1,11 +1,11 @@
11 /**
22 * The first thing a session shows, a short launcher: your repositories (and,
33 * as you type, every repository you can see), what is on you, what is on
4 * your machine, and — for a guest — the way in. Enter opens one in the
4 * your machine, and — for a visitor — the way in. Enter opens one in the
55 * workspace or the review; what happened, and other people's pages, are the
66 * web's feed and explorer (#636).
77 *
8 * A guest is not a degraded user. They get the same list, filtered to what is
8 * A visitor is not a degraded user. They get the same list, filtered to what is
99 * public by exactly the helpers the web and the API use, plus one extra row
1010 * telling them how to become someone.
1111 *
@@ -313,7 +313,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
313313 let firstTell = false;
314314 /**
315315 * "Started from <template>", the web home's muted line (#13322); null for a forge with no
316 * template or a guest.
316 * template or a visitor.
317317 */
318318 let startedFrom: string | null = null;
319319 /** The first week's three steps as one line (`core/first_week.ts`); null when none are due. */
@@ -1262,7 +1262,7 @@ export function dashboardScreen(f: Session, ctx: Ctx): Screen {
12621262 };
12631263
12641264 const screen: Screen = {
1265 title: f.user ? f.user.username : "Guest",
1265 title: f.user ? f.user.username : "Visitor",
12661266 get keys() {
12671267 return [
12681268 binding(["tab"], "next pane", { disabled: panes().length < 2 }),
src/tui/screens/data.ts +1 −1
@@ -370,7 +370,7 @@ export function dataScreen(session: Session, ctx: Ctx): Screen {
370370 };
371371 }
372372
373 /** Offered to an admin and to an app's writers; a reader and a guest see nothing. */
373 /** Offered to an admin and to an app's writers; a reader and a visitor see nothing. */
374374 export const dataCommand = (session: Session, ctx: Ctx) =>
375375 maySeeData(session.app.db, session.user)
376376 ? [
src/tui/screens/decider.ts +1 −1
@@ -2,7 +2,7 @@
22 * What the decider did today, in the terminal: the board's Today line and the
33 * rows behind each count, from the same `deciderCounts` and `listDeciderPile`
44 * reads. Only repositories this person holds owner facts for are counted —
5 * the board's own gate — so a guest or a reader sees nothing.
5 * the board's own gate — so a visitor or a reader sees nothing.
66 */
77
88 import type { Database } from "bun:sqlite";
src/tui/screens/deploys.ts +1 −1
@@ -15,7 +15,7 @@
1515 * preview opens that pull's screen. An app with none says `No previews.`.
1616 *
1717 * Below those, a signed-in viewer sees the app's open pulls, one line
18 * each: `#N title · check <word> · <preview address or none>`. A guest sees
18 * each: `#N title · check <word> · <preview address or none>`. A visitor sees
1919 * none.
2020 *
2121 * Until production first runs, the head carries one line of where the app
src/tui/screens/docs.ts +1 −1
@@ -1,7 +1,7 @@
11 /**
22 * The forge's documentation, the terminal's /docs: what the page does. The
33 * guide first, in its order, then the reference; "Search the docs" first of
4 * all, which also reaches the notes under features/. For anyone, a guest
4 * all, which also reaches the notes under features/. For anyone, a visitor
55 * included. Enter reads a document, rendered as markdown, scrolled with j and k.
66 */
77
src/tui/screens/family.ts +1 −1
@@ -1,6 +1,6 @@
11 /**
22 * The family across forges (#425) in a card: the same lines as /family, from
3 * the same view, so the gate (guests see the parent, admins also the
3 * the same view, so the gate (visitors see the parent, admins also the
44 * children) is `spawn/family.ts`'s and not this screen's.
55 */
66
src/tui/screens/featurefeed.ts +1 −1
@@ -24,7 +24,7 @@ import type { PaletteEntry } from "./entries.ts";
2424
2525 const oneLine = (text: string): string => text.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ");
2626
27 /** One feature's items. A feature that cannot be read, or a guest, has none. */
27 /** One feature's items. A feature that cannot be read, or a visitor, has none. */
2828 export function featureFeedScreen(f: Session, ctx: Ctx, feature: NavFeature): Screen {
2929 const state = new ListState();
3030 let items: readonly FeedItem[] = [];
src/tui/screens/findings.ts +1 −1
@@ -3,7 +3,7 @@
33 * reads — `listFindings`, `lastScan` — newest open first, never the matched
44 * text. `a` on an open finding asks why it may stand and accepts it through
55 * `acceptFinding`, the action the page's form calls, so the same people are
6 * refused (agents, readers, guests) and the acceptance shows on the page.
6 * refused (agents, readers, visitors) and the acceptance shows on the page.
77 * Access is read at every draw: a person who cannot read sees nothing.
88 */
99
src/tui/screens/fleet.ts +1 −1
@@ -103,7 +103,7 @@ export function planLines(plan: Plan, width: number, most = 12): string[] {
103103 return plan.rows.length > most ? [...rows, `and ${plan.rows.length - most} more`] : rows;
104104 }
105105
106 /** A person (not a guest, not an agent) may act, as on the page. */
106 /** A person (not a visitor, not an agent) may act, as on the page. */
107107 export const mayAct = (user: Session["user"]): boolean => user !== undefined && user.kind !== "agent";
108108
109109 /** The screen, and the prompt that writes its query line. */
src/tui/screens/forge_usage.ts +1 −1
@@ -2,7 +2,7 @@
22 * Forge-wide spend in the terminal, as `GET /api/v1/usage` and MCP `usage`
33 * without a repo answer it (`readForgeUsage`): today (since 00:00 UTC) and
44 * the rolling last 24 hours named apart, then one row per subscription with
5 * each window's headroom. The gate is theirs: a guest sees nothing, a writer
5 * each window's headroom. The gate is theirs: a visitor sees nothing, a writer
66 * their own apps, an admin all. Read once when the screen opens.
77 */
88
src/tui/screens/forgename.ts +1 −1
@@ -1,7 +1,7 @@
11 /**
22 * "Is a forge name free?" in the terminal: type a name and be told whether
33 * Start my forge would take it, by the same `forgeNameVerdict` as
4 * `GET /forges/name/<name>`. Offered to a guest, beside Start my forge.
4 * `GET /forges/name/<name>`. Offered to a visitor, beside Start my forge.
55 */
66
77 import { forgeNameVerdict } from "../../actions/spawn.ts";
src/tui/screens/forges.ts +1 −1
@@ -55,7 +55,7 @@ export function forgeLines(rows: readonly ClientRow[], sender = false, now = Dat
5555
5656 /**
5757 * The row's one last-activity phrase: the sender reads the page's words unless the seen line
58 * already says it; a guest, who never gets the seen line, keeps the older "a person last did
58 * already says it; a visitor, who never gets the seen line, keeps the older "a person last did
5959 * something".
6060 */
6161 function activityPiece(r: ClientRow, sender: boolean, now: number): string | null {
src/tui/screens/frontms.ts +1 −1
@@ -3,7 +3,7 @@
33 * milestones, each with how far it is, what landed in 7 days and its
44 * estimate. The same read as the home's lines (`biggestMilestones` over
55 * `frontApps`): a signed-in person's own apps', and no spend, which is the
6 * owner's and has its own page. A guest is not offered it, as a signed-out
6 * owner's and has its own page. A visitor is not offered it, as a signed-out
77 * visitor's home has no milestone lines. Enter opens the milestone on the web.
88 */
99
src/tui/screens/getforge.ts +2 −2
@@ -1,6 +1,6 @@
11 /**
22 * "Get your own forge" in the terminal: the home page's `#yours` for anyone,
3 * guests included. Every plan with its price, what it is, its buy link when
3 * visitors included. Every plan with its price, what it is, its buy link when
44 * one is set, then where to get a hosted forge and how to run one yourself.
55 * The words are `billing/plan_words.ts`, the same the web row prints; the
66 * settings are read in one statement as the home reads them.
@@ -71,7 +71,7 @@ export function getForgeScreen(session: Session, ctx: Ctx): Screen {
7171 };
7272 }
7373
74 /** Offered to everyone, guests included, as the packs command is. */
74 /** Offered to everyone, visitors included, as the packs command is. */
7575 export const getForgeCommand = (session: Session, ctx: Ctx) => ({
7676 id: "get-a-forge",
7777 title: "Get your own forge",
src/tui/screens/health_voice.ts +1 −1
@@ -29,7 +29,7 @@ export function healthVoiceScreen(f: Session, ctx: Ctx): Screen {
2929 };
3030 }
3131
32 /** The palette entry: offered to every reader, guests too. */
32 /** The palette entry: offered to every reader, visitors too. */
3333 export const entry: PaletteEntry = {
3434 rank: 120,
3535 id: "health-voice",
src/tui/screens/iterations.ts +1 −1
@@ -3,7 +3,7 @@
33 * web page draws them (`iterationsOf`, `lanesOf`), as an indented list — a run
44 * under the build it grew from, its builds beneath. Read-only. Offered to, and
55 * read for, only someone who may read the repository; the family is what that
6 * viewer may read of it (`canRead`, `visibleForks`), so a guest sees nothing
6 * viewer may read of it (`canRead`, `visibleForks`), so a visitor sees nothing
77 * private.
88 */
99
src/tui/screens/limbs.ts +1 −1
@@ -7,7 +7,7 @@
77 * regretted) `undoFleetOp` — the fleet operation the page and the API use,
88 * verb `place`. What the screen decides is only what to draw and which keys
99 * exist; the action decides who may. A reader sees the order and no keys to
10 * change it, an agent likewise, and a guest sees what `canRead` lets the web
10 * change it, an agent likewise, and a visitor sees what `canRead` lets the web
1111 * show — the plan is read without the owner's spend. Whoever may see owner
1212 * facts (`canSeeOwnerFacts`, as on the page) also gets, under the list, what
1313 * the limb under the cursor cost and landed, and its costliest issues.
src/tui/screens/madefrom.ts +1 −1
@@ -23,7 +23,7 @@ export function madeFromScreen(f: Session, ctx: Ctx): Screen {
2323 title: "Started from",
2424 keys: [],
2525 render(area, s) {
26 // The settings page's identity: a guest is told nothing (a template may be private).
26 // The settings page's identity: a visitor is told nothing (a template may be private).
2727 const text = !f.signedIn
2828 ? "Sign in to see what this forge was made from."
2929 : (madeFromScreenLine(f.app.config.dataDir) ?? "This forge was made from no template repository.");
src/tui/screens/mesh_edit.ts +3 −3
@@ -1,8 +1,8 @@
11 /**
22 * Scale, move or turn an STL, in the terminal: the same action as the file page's form
3 * (`actions/mesh_edit.ts`), so the same gate (a writer only; a reader or guest is offered nothing),
4 * the same bounds, the same commit message and the same protected-branch rule. The write goes
5 * through `editFiles`, which announces a push, so an open web page of the file follows.
3 * (`actions/mesh_edit.ts`), so the same gate (a writer only; a reader or visitor is offered
4 * nothing), the same bounds, the same commit message and the same protected-branch rule. The write
5 * goes through `editFiles`, which announces a push, so an open web page of the file follows.
66 */
77
88 import { requireWriter } from "../../actions/access.ts";
src/tui/screens/next.ts +1 −1
@@ -3,7 +3,7 @@
33 * door and not a second implementation. A move is `rankIssue`, the action the
44 * page and MCP `next_up` reach, so who may move what is decided there: a
55 * reader sees the order and no keys to change it, an agent likewise, and a
6 * guest sees what `canRead` lets the web show, sealed issues left to the same
6 * visitor sees what `canRead` lets the web show, sealed issues left to the same
77 * scope the page uses. `t` puts the issue under the cursor on top, `u` and
88 * `d` move it a place, `x` ticks a row, `s` snoozes the ticked rows a day and `z` takes
99 * that batch back (the page's tick boxes and Undo, #15835), `n` puts it behind the Later gate; each
src/tui/screens/notes.ts +2 −2
@@ -3,8 +3,8 @@
33 * the terminal's door to what the button does on an app's page, with the
44 * page's gating. A signed-in person who reads the repository may send a note
55 * and see their own with its status; the repository's admin sees every
6 * sender's and may hide a note or ban its sender, see the banned senders and unban them. A repository that is not
7 * an app, or a guest, gets no rows.
6 * sender's and may hide a note or ban its sender, see the banned senders and unban them. A
7 * repository that is not an app, or a visitor, gets no rows.
88 */
99
1010 import { moderateNote, notesFor, ownerNotes, sendNote, unbanSender, type Sender } from "../../actions/app_notes.ts";
src/tui/screens/oauthgrants.ts +1 −1
@@ -3,7 +3,7 @@
33 * gave, with its client, scopes, when it was granted and last used, as the
44 * page lists it. `x` revokes the selected one after a confirm, through
55 * `revokeOAuthGrant` (the page's action and gate: your own grants only) and
6 * says the page's receipt. An agent and a guest see nothing to revoke.
6 * says the page's receipt. An agent and a visitor see nothing to revoke.
77 */
88 import { myOAuthGrants, myReusedGrants, revokeOAuthGrant, revokedWords } from "../../actions/oauth_grants.ts";
99 import type { OAuthGrant } from "../../core/oauth_grants.ts";
src/tui/screens/originahead.ts +1 −1
@@ -2,7 +2,7 @@
22 * New commits upstream, in the terminal: the mirrors whose origin has moved
33 * on, as the repository head shows them on the web ("N new commits upstream").
44 * `t` takes them through `takeFromOrigin`, the page's own action, offered only
5 * to a person who may write the repository. A reader sees the count; a guest
5 * to a person who may write the repository. A reader sees the count; a visitor
66 * sees only what is public.
77 */
88
src/tui/screens/payments.ts +2 −2
@@ -1,7 +1,7 @@
11 /**
22 * The owner's payments in the terminal (#13093): the same rows as `/settings/payments`, from the
3 * same `paymentsFor`, so the gate is the page's: only the forges this person claimed, a guest sees
4 * nothing. Status word first, then date, amount and the forge's plan now.
3 * same `paymentsFor`, so the gate is the page's: only the forges this person claimed, a visitor
4 * sees nothing. Status word first, then date, amount and the forge's plan now.
55 */
66
77 import { paymentsFor, PAYMENTS_CAP } from "../../actions/forge_bill.ts";
src/tui/screens/pricing.ts +2 −1
@@ -237,7 +237,8 @@ export function pricingScreen(f: Session, ctx: Ctx): Screen {
237237 }
238238
239239 /**
240 * Offered to everyone: the sale is open to a guest and to a signed-in person alike, as on the web.
240 * Offered to everyone: the sale is open to a visitor and to a signed-in person alike, as on the
241 * web.
241242 */
242243 export const pricingCommand = (session: Session, ctx: Ctx) => ({
243244 id: "pricing",
src/tui/screens/roadmap.ts +1 −1
@@ -1,7 +1,7 @@
11 /**
22 * The roadmap in the terminal (#10303): the same model the map page, the API
33 * and the MCP read (`web/roadmap.ts`), as scrolling text lines. The reader is
4 * the session's person, so a guest sees what is public and only a writer
4 * the session's person, so a visitor sees what is public and only a writer
55 * gets Needs you.
66 */
77
src/tui/screens/signin.ts +2 −2
@@ -1,5 +1,5 @@
11 /**
2 * Becoming someone. A guest is already connected — this screen proves a
2 * Becoming someone. A visitor is already connected — this screen proves a
33 * password and links the key they arrived on to the account, after which the
44 * same connection is that user. No reconnect, and no impersonation: the only
55 * account a session can take on is one whose password was just verified.
@@ -59,7 +59,7 @@ const edgeSignupMessage = (f: Session): string =>
5959 ? "Sign up on the web page only."
6060 : `Sign up on the web page only: ${f.app.config.url}/signup`;
6161
62 /** Where a stranger who cannot sign up here goes: the guest menu's own command. */
62 /** Where a stranger who cannot sign up here goes: the visitor menu's own command. */
6363 const GET_FORGE_HINT = "To get a forge of your own, press Esc and choose Start my forge.";
6464
6565 /** What a closed sign-up says outside an edge: the refusal, then where to go instead. */
src/tui/screens/signins.ts +3 −3
@@ -60,7 +60,7 @@ interface SignIn {
6060 /** The tail of an id: two browsers signed in the same day still read apart. */
6161 const shortId = (id: string): string => id.slice(-6).toLowerCase();
6262
63 /** The rows, this terminal first; empty for a guest. */
63 /** The rows, this terminal first; empty for a visitor. */
6464 export function signInsOf(f: Session): SignIn[] {
6565 const user = f.user;
6666 if (user === undefined) return [];
@@ -297,7 +297,7 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
297297
298298 const make = (): void => {
299299 const user = f.user;
300 // An agent holds no keys to mint with; a guest has no account.
300 // An agent holds no keys to mint with; a visitor has no account.
301301 if (user === undefined || user.kind === "agent") return;
302302 ctx.push(askName(user.isAdmin));
303303 };
@@ -346,7 +346,7 @@ export function signInsScreen(f: Session, ctx: Ctx): Screen {
346346
347347 const rotate = (): void => {
348348 const user = f.user;
349 // An agent signs in with a key, not a password; a guest has no account.
349 // An agent signs in with a key, not a password; a visitor has no account.
350350 if (user === undefined || user.kind === "agent") return;
351351 ctx.push(askCurrent());
352352 };
src/tui/screens/space.ts +1 −1
@@ -1,6 +1,6 @@
11 /**
22 * The space in the terminal (#10444): the plane the page draws, as text. The
3 * same `spaceOf` the page and `space.json` read, so a guest sees what is
3 * same `spaceOf` the page and `space.json` read, so a visitor sees what is
44 * public and an admin everything. Per pillar: its counts, its issues by state,
55 * then who of the crew is on what, and the week's landings.
66 */
src/tui/screens/startforge.ts +3 −3
@@ -1,11 +1,11 @@
11 /**
2 * "Start my forge" in the terminal: the home page's start form for a guest.
2 * "Start my forge" in the terminal: the home page's start form for a visitor.
33 * One field, the name; **Enter** goes through `spawnDoor` as a stranger, as
44 * `POST /forges/start` does, so the free plan, the name rules and the visitor
55 * limits are the door's (counted under the SSH client's address). A refusal is
66 * one of the fixed sentences the home page shows (`web/start_refusal.ts`); a
77 * made forge's claim link is shown once and kept nowhere. Signed in, "New
8 * forge" is the fuller form, so this command is a guest's.
8 * forge" is the fuller form, so this command is a visitor's.
99 * Each name is sent with a resume key this SSH session keeps (#15126), so a
1010 * start cut off before the forge is made is finished by pressing Enter again
1111 * in the same session, and by nobody else. The key is never shown; a session
@@ -139,7 +139,7 @@ export function startForgeScreen(f: Session, ctx: Ctx): Screen {
139139 };
140140 }
141141
142 /** A guest's: a signed-in person has "New forge". */
142 /** A visitor's: a signed-in person has "New forge". */
143143 export const startForgeCommand = (session: Session, ctx: Ctx) =>
144144 session.signedIn
145145 ? []
src/tui/screens/subtitle_shift.ts +1 −1
@@ -1,7 +1,7 @@
11 /**
22 * Shift a subtitle file's cues, in the terminal: the same action as the file
33 * page's form (`actions/subtitle_shift.ts`), so the same gate (a writer only;
4 * a reader or guest is offered nothing), the same range and the same commit
4 * a reader or visitor is offered nothing), the same range and the same commit
55 * message. The action writes through `editFiles`, which announces a push on
66 * the bus, so an open web page of the file follows.
77 */
src/tui/screens/templates.ts +1 −1
@@ -1,6 +1,6 @@
11 /**
22 * `/templates` in the terminal: what a new forge starts from, from the page's own list
3 * (`templateList`). Enter on a row opens New forge with that template chosen; a guest reads
3 * (`templateList`). Enter on a row opens New forge with that template chosen; a visitor reads
44 * the list and is told the form is for people signed in.
55 */
66
src/tui/screens/thoughtnotes.ts +2 −2
@@ -4,7 +4,7 @@
44 * the list is the signed-in person's own `thoughtStream` with `noteLine`'s
55 * one-line state, and `b` takes the tap the line offers (`overruleNote`, which
66 * refuses what the line does not offer). Everything is the person's own: a
7 * guest has nothing, and the palette offers the screen only when signed in.
7 * visitor has nothing, and the palette offers the screen only when signed in.
88 * A note written here shows live on the page, being the same row.
99 */
1010
@@ -39,7 +39,7 @@ export interface NoteRow extends ListRow {
3939 readonly overrule: "build" | "decline" | null;
4040 }
4141
42 /** The viewer's notes as rows; a guest has none. */
42 /** The viewer's notes as rows; a visitor has none. */
4343 export function noteRows(db: Database, viewer: User | undefined): NoteRow[] {
4444 if (viewer === undefined) return [];
4545 return thoughtStream(db, viewer, { limit: SHOWN }).map((n) => {
src/tui/session.ts +3 −3
@@ -3,7 +3,7 @@
33 * every screen needs from the forge.
44 *
55 * The identity rule: a session acts as the account its *key* maps to, and
6 * nothing else. `authorize` lets every well-formed key in — a guest browses
6 * nothing else. `authorize` lets every well-formed key in — a visitor browses
77 * public repos exactly as an anonymous web visitor does — and signing in is
88 * the act of proving a password and *linking* this key to that account, after
99 * which the same connection is that user. There is no impersonation path
@@ -34,7 +34,7 @@ export interface TuiIdentity {
3434 readonly publicKey?: string | undefined;
3535 /** The registered key row this session matched, when it matched one. */
3636 readonly keyId?: string | undefined;
37 /** The account the key resolved to. Absent means a guest. */
37 /** The account the key resolved to. Absent means a visitor. */
3838 readonly user?: User | undefined;
3939 }
4040
@@ -95,7 +95,7 @@ export class Session {
9595 }
9696
9797 /**
98 * The two terminal preferences, as stored. A guest has none and gets
98 * The two terminal preferences, as stored. A visitor has none and gets
9999 * `auto` for both — the settings exist to override a guess, never to
100100 * enable the feature.
101101 */
src/tui/ssh-guest-rate.ts +4 −4
@@ -1,7 +1,7 @@
11 /**
2 * A rate on what a guest (a key with no account) may say over ssh: `tell` and
3 * `talk` each start work, and a key costs a guest nothing to make, so the
4 * limit is on the address beside the key, with a cap on all guests together.
2 * A rate on what a visitor (a key with no account) may say over ssh: `tell` and
3 * `talk` each start work, and a key costs a visitor nothing to make, so the
4 * limit is on the address beside the key, with a cap on all visitors together.
55 * The address is the TCP peer's (a proxy's, when one fronts the port).
66 * Pure: the clock is passed in.
77 */
@@ -10,7 +10,7 @@ export const GUEST_SAYS_PER_WINDOW = 5;
1010 export const GUEST_SAYS_ALL_PER_WINDOW = 60;
1111 export const GUEST_WINDOW_MS = 60_000;
1212
13 export const GUEST_RATE_WORDS = "slow down — a guest may tell or talk only a few times a minute; sign in to lift that";
13 export const GUEST_RATE_WORDS = "slow down — a visitor may tell or talk only a few times a minute; sign in to lift that";
1414
1515 export class GuestRate {
1616 private all: number[] = [];
src/tui/ssh-tell.ts +1 −1
@@ -25,7 +25,7 @@ import { crewCanRun } from "../web/studio/crew_key.ts";
2525
2626 const CRLF = "\r\n";
2727
28 /** What an unknown key is told: it is a guest, and a guest tells nothing. */
28 /** What an unknown key is told: it is a visitor, and a visitor tells nothing. */
2929 export const ACCOUNT_NEEDED_WORDS =
3030 "telling the crew needs an account — sign in on the web and add this key under Settings → Keys";
3131
src/tui/ssh.ts +6 −6
@@ -5,7 +5,7 @@
55 *
66 * The identity rule (see `session.ts`): `authorize` admits every well-formed
77 * key, and what that key *is* decides who the session acts as. An unknown key
8 * is a guest — public repos only, and a "Sign in" screen that links the key
8 * is a visitor — public repos only, and a "Sign in" screen that links the key
99 * on success. Nothing here can act as a user the presented key does not map
1010 * to.
1111 */
@@ -187,12 +187,12 @@ export async function attachTui(
187187 asPerson(() => app.start());
188188 }
189189
190 /** Resolve the account a presented key belongs to, or a guest. */
190 /** Resolve the account a presented key belongs to, or a visitor. */
191191 export function identityFor(forge: Forge, session: SshSession): TuiIdentity {
192192 const match = findKeyByFingerprint(forge.db, session.key.fingerprint);
193193 const found =
194194 match === undefined ? undefined : getUserById(forge.db, match.userId);
195 // A suspended or removed account's key opens nothing: it is a guest.
195 // A suspended or removed account's key opens nothing: it is a visitor.
196196 const user = found !== undefined && isActive(found) ? found : undefined;
197197 if (match !== undefined && user !== undefined)
198198 touchKey(forge.db, match.keyId);
@@ -261,7 +261,7 @@ export function forgeSshSession(
261261 ): (session: SshSession) => void {
262262 let guests = guestRates.get(forge);
263263 if (guests === undefined) guestRates.set(forge, (guests = new GuestRate()));
264 // A guest's tell and talk start work; they share one rate (see ssh-guest-rate.ts).
264 // A visitor's tell and talk start work; they share one rate (see ssh-guest-rate.ts).
265265 const guestLimited = (session: SshSession, user: unknown): boolean => {
266266 if (user !== undefined) return false;
267267 if (guests.allow([`key:${session.key.fingerprint}`, `addr:${session.remoteAddress}`], Date.now())) return false;
@@ -349,7 +349,7 @@ export function forgeSshSession(
349349
350350 /**
351351 * Git over an exec channel. The access matrix is exactly the HTTP one:
352 * upload-pack → `canRead`; a guest may read a public repo.
352 * upload-pack → `canRead`; a visitor may read a public repo.
353353 * receive-pack → a signed-in user with `canWrite`; push-to-create makes a
354354 * private repo when the target does not exist yet.
355355 * A repo you cannot see is "not found", the same answer a missing one gets.
@@ -509,7 +509,7 @@ export async function serveForgeSsh(
509509 ...(forge.config.selfSwap === true ? { reusePort: true } : {}),
510510 hostKeyDir: options.hostKeyDir ?? join(forge.config.dataDir, "ssh"),
511511 log: forge.log,
512 // Guests are welcome: the key is an identity, not a permit.
512 // Visitors are welcome: the key is an identity, not a permit.
513513 authorize: () => true,
514514 onSession: forgeSshSession(forge),
515515 });
src/tui/ui/image.ts +1 −1
@@ -376,7 +376,7 @@ export interface GraphicsPrefs {
376376 }
377377
378378 /**
379 * The two stored preferences, read-only. A guest has none and gets `auto`,
379 * The two stored preferences, read-only. A visitor has none and gets `auto`,
380380 * which is the same answer a signed-in user who never touched settings gets —
381381 * the setting exists to override a guess, not to enable the feature.
382382 */
src/web/pages/milestones_near.ts +1 −1
@@ -14,7 +14,7 @@ import { planFor } from "./milestones.ts";
1414 export type Near = { number: number; name: string; done: number; total: number };
1515
1616 /**
17 * The open milestones of `slug` ("owner/name"), for `user` (undefined is a guest), with the
17 * The open milestones of `slug` ("owner/name"), for `user` (undefined is a visitor), with the
1818 * repository read for them.
1919 */
2020 export function nearMilestones(app: App, slug: string | undefined, user: User | undefined): { repo: Repo; near: Near[] } | undefined {
test/principal.test.ts added +131
@@ -0,0 +1,131 @@
1 /**
2 * Principal: every way of arriving maps to exactly one kind, and no route's answer depends on it
3 * yet.
4 */
5
6 import { describe, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { createApp } from "../src/app.ts";
11 import { principalOf, userOf, type Principal, type Subject } from "../src/core/principal.ts";
12 import { createSession } from "../src/core/sessions.ts";
13 import { createToken } from "../src/core/tokens.ts";
14 import { createUser } from "../src/core/users.ts";
15 import { resolveAuth } from "../src/http/server.ts";
16 import type { Auth } from "../src/http/context.ts";
17 import type { User } from "../src/core/users.ts";
18
19 const person = { id: "u1", username: "ada", kind: "user", isAdmin: false } as User;
20 const agent = { id: "u2", username: "mason", kind: "agent", isAdmin: false } as User;
21 const token = { user: person, via: "token" as const, tokenId: "t1", tokenName: "ci" };
22
23 const PRINCIPAL_KINDS = [
24 "anonymous", "session", "ro_token", "rw_token", "admin_token",
25 "proposal_token", "run_token", "contribute_token", "read_grant_token", "via_token",
26 ] as const satisfies readonly Principal["kind"][];
27
28 const ARRIVALS: Record<string, { auth: Auth; kind: Principal["kind"]; subject?: Subject["kind"] }> = {
29 "no credential": { auth: { user: undefined, scope: undefined, via: "none" }, kind: "anonymous" },
30 "a credential nothing matched": { auth: { user: undefined, scope: undefined, via: "none", refused: true }, kind: "anonymous" },
31 "a password turned away": { auth: { user: undefined, scope: undefined, via: "none", retryAfter: 30 }, kind: "anonymous" },
32 "a session cookie": { auth: { user: person, scope: "admin", via: "session", sessionId: "s1" }, kind: "session", subject: "person" },
33 "the platform edge": { auth: { user: person, scope: "admin", via: "edge" }, kind: "session", subject: "person" },
34 "the password": { auth: { user: person, scope: "admin", via: "password" }, kind: "session", subject: "person" },
35 "a terminal screen": { auth: { user: person, scope: undefined, via: "none" }, kind: "session", subject: "person" },
36 "an ro token": { auth: { ...token, scope: "ro" }, kind: "ro_token", subject: "person" },
37 "an rw token": { auth: { ...token, scope: "rw" }, kind: "rw_token", subject: "person" },
38 "an admin token": { auth: { ...token, scope: "admin" }, kind: "admin_token", subject: "person" },
outdated

Add a case where one Auth carries several scopes (for example proposal and run) to pin the precedence the doc comment claims.

39 "a proposal token": {
40 auth: { ...token, scope: "rw", proposal: { tokenId: "t1", repoId: "r1", child: "kid", origin: "https://x.test" } },
41 kind: "proposal_token",
42 subject: "person",
43 },
44 "a run token": { auth: { ...token, user: agent, scope: "rw", run: { repoId: "r1", forkId: "f1" } }, kind: "run_token", subject: "agent" },
45 "a contribute token": { auth: { ...token, scope: "rw", contribute: { tokenId: "t1", repoId: "r1", agent: "mason", namespace: "mason/abc" } }, kind: "contribute_token", subject: "person" },
46 "an app's read grant": { auth: { ...token, scope: "ro", appId: "app1" }, kind: "read_grant_token", subject: "app" },
47 "a via token": { auth: { ...token, user: agent, scope: "rw", through: "conversation:c1" }, kind: "via_token", subject: "agent" },
48 };
49
50 describe("principalOf", () => {
51 for (const [name, a] of Object.entries(ARRIVALS))
52 test(`${name} is ${a.kind}`, () => {
53 const p = principalOf(a.auth);
54 expect(p.kind).toBe(a.kind);
55 if (a.subject !== undefined) expect("subject" in p ? p.subject.kind : undefined).toBe(a.subject);
56 else expect("subject" in p).toBe(false);
57 });
58
59 test("every kind is reached by some arrival, and no arrival is outside the list", () => {
60 const seen = new Set(Object.values(ARRIVALS).map((a) => principalOf(a.auth).kind));
61 expect([...seen].sort()).toEqual([...PRINCIPAL_KINDS].sort());
62 });
63
64 test("anonymous is a value that remembers a refusal and a wait", () => {
65 expect(principalOf(ARRIVALS["no credential"]!.auth)).toEqual({ kind: "anonymous", refused: false });
66 expect(principalOf(ARRIVALS["a credential nothing matched"]!.auth)).toEqual({ kind: "anonymous", refused: true });
67 expect(principalOf(ARRIVALS["a password turned away"]!.auth)).toMatchObject({ kind: "anonymous", retryAfter: 30 });
68 });
69
70 test("a token keeps its id and name; a session its id", () => {
71 expect(principalOf(ARRIVALS["an rw token"]!.auth)).toMatchObject({ tokenId: "t1", tokenName: "ci" });
72 expect(principalOf(ARRIVALS["a session cookie"]!.auth)).toMatchObject({ sessionId: "s1", via: "session" });
73 });
74
75 test("the account behind each arrival is the one Auth held", () => {
76 for (const a of Object.values(ARRIVALS)) expect(userOf(principalOf(a.auth))).toBe(a.auth.user);
77 });
78
79 test("one Auth with several scopes is the narrowest: proposal, run, contribute, read grant, via, plain", () => {
80 const scopes = {
81 proposal: { tokenId: "t1", repoId: "r1", child: "kid", origin: "https://x.test" },
82 run: { repoId: "r1", forkId: "f1" },
83 contribute: { tokenId: "t1", repoId: "r1", agent: "mason", namespace: "mason/abc" },
84 appId: "app1",
85 through: "conversation:c1",
86 };
87 const all = { ...token, scope: "admin" as const, ...scopes };
88 expect(principalOf(all).kind).toBe("proposal_token");
89 const { proposal: _p, ...noProposal } = all;
90 expect(principalOf(noProposal).kind).toBe("run_token");
91 const { run: _r, ...noRun } = noProposal;
92 expect(principalOf(noRun).kind).toBe("contribute_token");
93 const { contribute: _c, ...noContribute } = noRun;
94 expect(principalOf(noContribute).kind).toBe("read_grant_token");
95 const { appId: _a, ...noApp } = noContribute;
96 expect(principalOf(noApp).kind).toBe("via_token");
97 const { through: _t, ...plain } = noApp;
98 expect(principalOf(plain).kind).toBe("admin_token");
99 });
100 });
101
102 describe("principalOf on what the server builds", () => {
103 test("a session, an ro token and no credential", async () => {
104 const dir = await mkdtemp(join(tmpdir(), "forge-principal-"));
105 const app = createApp({ dataDir: dir, port: 0, url: "https://forge.example" });
106 try {
107 const made = await createUser(app.db, { origin: "edge", username: "ada", email: "[email protected]" });
108 if (!made.ok) throw new Error("no user");
109 const ask = (headers: Record<string, string>) =>
110 resolveAuth(app, new Request("https://forge.example/", { headers })).then(principalOf);
111
112 const none = await ask({});
113 expect(none).toEqual({ kind: "anonymous", refused: false });
114
115 const session = createSession(app.db, made.value.id);
116 const viaSession = await ask({ cookie: `forge_session=${session.token}` });
117 expect(viaSession.kind).toBe("session");
118 expect(userOf(viaSession)?.id).toBe(made.value.id);
119
120 const ro = createToken(app.db, made.value.id, "ci", "ro");
121 const viaToken = await ask({ authorization: `Bearer ${ro.token}` });
122 expect(viaToken).toMatchObject({ kind: "ro_token", tokenId: ro.id, tokenName: "ci" });
123 expect(userOf(viaToken)?.id).toBe(made.value.id);
124
125 expect(await ask({ authorization: "Bearer forge_nothing" })).toEqual({ kind: "anonymous", refused: true });
126 } finally {
127 app.db.close();
128 await rm(dir, { recursive: true, force: true });
129 }
130 });
131 });
test/ssh-app.test.ts +4 −4
@@ -145,12 +145,12 @@ describe.skipIf(NO_OPENSSH)("ssh into the forge", () => {
145145 expect(out).toContain("alice/vault");
146146 });
147147
148 test("an unknown key is a guest, with a way to sign in", async () => {
148 test("an unknown key is a visitor, with a way to sign in", async () => {
149149 const { out } = await connect(server.port, strangerKey);
150 // The breadcrumb names the session, and a guest is a guest.
151 expect(out).toContain("Guest");
150 // The breadcrumb names the session, and a signed-out key is a visitor.
151 expect(out).toContain("Visitor");
152152 expect(out).toContain("alice/lighthouse");
153 // A private repo is not in the list a guest was handed.
153 // A private repo is not in the list a visitor was handed.
154154 expect(out).not.toContain("vault");
155155 });
156156 });
test/tui-changelog-waves.test.ts +2 −2
@@ -76,8 +76,8 @@ test("w opens the waves, Enter a wave's changes, Enter a change's pull; Esc walk
7676 expect(pull).toContain("Changelog › Waves › 0.2.0 › #1");
7777 await settleUntil(tui, "Newer thing");
7878 const head = (t: string): string => t.split("\n")[1] ?? "";
79 expect(head(await step("\x1b"))).toBe("Guest › Changelog › Waves › 0.2.0");
80 expect(head(await step("\x1b"))).toBe("Guest › Changelog › Waves");
79 expect(head(await step("\x1b"))).toBe("Visitor › Changelog › Waves › 0.2.0");
80 expect(head(await step("\x1b"))).toBe("Visitor › Changelog › Waves");
8181 const back = await step("\x1b");
8282 tui.stop?.();
8383 expect(back).toBe(list);
test/tui-screens.test.ts +1 −1
@@ -654,7 +654,7 @@ describe("a forge with no accounts", () => {
654654 publicKey: KEY_LINE,
655655 });
656656 await h.settle();
657 expect(h.text()).toContain("Guest");
657 expect(h.text()).toContain("Visitor");
658658
659659 await h.press("s");
660660 expect(h.text()).toContain("no accounts yet");
test/turnstile.test.ts +2 −2
@@ -212,11 +212,11 @@ describe("turnstile doors", () => {
212212 await settleApp(tui);
213213 };
214214 await settleApp(tui);
215 if (!tui.screen.toText().includes("Guest ›")) {
215 if (!tui.screen.toText().includes("Visitor ›")) {
216216 key("s");
217217 await settleApp(tui);
218218 }
219 if (tui.screen.toText().includes("Guest › Sign in")) {
219 if (tui.screen.toText().includes("Visitor › Sign in")) {
220220 key("t", true);
221221 await settleApp(tui);
222222 }

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs