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

Pinned forges live on /infra: /pinned folds in and redirects #17497

opened this

Merged 20h 39m ago, live in production

scout/forge:scout/17372-pinned-forges-live-on-infra-pinned-folds → main 0 commits fork 3 threads · 3 unresolved

  • Merged. scout/17372-pinned-forges-live-on-infra-pinned-folds was merged into main as 59cf897.

Review

Sign in to review this change.
24 files changed +118 −75
docs/features/experiments.md +1 −1
@@ -9,7 +9,7 @@ Every cloud dollar answers a question. An experiment is that question, the pinne
99
1010 ## Where
1111
12 - **Web:** the top of `/pinned` (`src/web/pages/pinned.ts`). One row per experiment: its question, the machines it runs on, what they cost a month now, what it has cost, and its result, with Record result under it while it runs. It is a live region on `/events`: it updates in place when anyone changes an experiment, from any door.
12 - **Web:** the Pinned forges block of `/infra` (`src/web/pages/pinned.ts`; `/pinned` answers 301 to `/infra`). One row per experiment: its question, the machines it runs on, what they cost a month now, what it has cost, and its result, with Record result under it while it runs. It is a live region on `/events`: it updates in place when anyone changes an experiment, from any door.
1313 - **Terminal:** the Experiments screen (`src/tui/screens/experiments.ts`, after Pinned forges in the palette). `b` begins one, `a` attaches machines to the selected one, `r` records its result.
1414 - **Agents:** the `infra` MCP tool, which took the place of `experiments` ([Infrastructure](infra.md)): `list` (and `idle`), `show` by id or words of the question, `begin`, `attach`, `record_result`.
1515
docs/features/infra.md +1 −1
@@ -9,7 +9,7 @@ What runs on your own cloud, what it's for, what it costs, and when it ends; and
99
1010 ## Where
1111
12 - **Web:** `/infra` (`src/web/pages/infra.ts`, routes in `src/http/infra_routes.ts`). Each account's month against its ceiling, one sentence a line ("$13.00 of $50 a month on DigitalOcean"); a line for anything the hourly watch found at a provider that the forge did not make, linking that account's row on Cloud accounts; then each machine that bills, grouped by its experiment's question or by its app, with where it runs in plain words, its monthly cost and when it ends, Keep 7 more days and End now beside it; End now shows only where something exists at the provider (`existsAtProvider` in `src/cloud/billing.ts`, the same test /pinned's Retire uses), so a first deploy that made nothing offers none. What ended in the last 30 days, and anything retired that still bills, stays under a quiet **Ended** disclosure, each in the shared billing sentence with its day: "retired Mon 30 Nov; nothing bills", or "…; its kept disk still bills $1.00 a month" with a link to delete it on Pinned forges; older ones that bill nothing are one line with their count. A dead row (a first deploy that failed and left nothing at its provider) says "nothing exists at DigitalOcean; clear this row", with Clear this row through the confirm (`clearPinned`, event `pinned.cleared`). Build something opens the compose form: an app, a place (the cheapest two in each city, each a row of at least 44px; a filter of city, provider or size words narrows the whole catalog on the server, `/infra/live?part=places`, so the page never carries it; one that cannot be ordered is listed, dimmed, with why), what it is for (a new question, a running experiment, or running the app itself), and when it ends (1, 3, 7 or 30 days; no end only for an app). The plan tray sits at the foot of the form.
12 - **Web:** `/infra` (`src/web/pages/infra.ts`, routes in `src/http/infra_routes.ts`). Each account's month against its ceiling, one sentence a line ("$13.00 of $50 a month on DigitalOcean"); a line for anything the hourly watch found at a provider that the forge did not make, linking that account's row on Cloud accounts; then each machine that bills, grouped by its experiment's question or by its app, with where it runs in plain words, its monthly cost and when it ends, Keep 7 more days and End now beside it; End now shows only where something exists at the provider (`existsAtProvider` in `src/cloud/billing.ts`, the same test Retire on Pinned forges uses), so a first deploy that made nothing offers none. What ended in the last 30 days, and anything retired that still bills, stays under a quiet **Ended** disclosure, each in the shared billing sentence with its day: "retired Mon 30 Nov; nothing bills", or "…; its kept disk still bills $1.00 a month" with a link to delete it on Pinned forges; older ones that bill nothing are one line with their count. A dead row (a first deploy that failed and left nothing at its provider) says "nothing exists at DigitalOcean; clear this row", with Clear this row through the confirm (`clearPinned`, event `pinned.cleared`). Build something opens the compose form: an app, a place (the cheapest two in each city, each a row of at least 44px; a filter of city, provider or size words narrows the whole catalog on the server, `/infra/live?part=places`, so the page never carries it; one that cannot be ordered is listed, dimmed, with why), what it is for (a new question, a running experiment, or running the app itself), and when it ends (1, 3, 7 or 30 days; no end only for an app). The plan tray sits at the foot of the form.
1313 - **Terminal:** the Infrastructure screen (`src/tui/screens/infra.ts`, after Cloud accounts in the palette, and `I` on the Cloud accounts screen). What ended is listed after what runs, each in its billing sentence. `n` composes one question at a time and shows the plan with Build; `l` looks at the DNS records against Cloudflare now; `m` makes one (type, name, host, what it points to, a port for SRV, then the plan with Make the record); `u` removes the selected record after a confirm; `+` keeps the selected machine 7 more days; `x` ends it now after a confirm (only where something exists at its provider), and `c` clears a dead row after a confirm. A build's steps lead the list as they happen.
1414 - **API:** `GET /api/v1/admin/infra` (`?plan=<id>` adds a build's steps), `POST /api/v1/admin/infra/plan`, `POST /api/v1/admin/infra/apply` (202). Keep is `POST /api/v1/admin/pinned/:name/keep`.
1515 - **Agents:** the `infra` MCP tool, in Talk's slot where `experiments` was: `list` (first `says`: one paragraph naming what runs, the dead rows, what ended in the last 30 days with each one's billing sentence, and the total, at most ten names a group then "and N more", so a reader of `says` alone misses no machine; then everything `experiments` listed, plus each machine's end and what it bills for, and `ended`: what retired in the last 30 days or still bills, so a question about one is answered from its row; a dead row's `clear` sentence), `show` (an experiment, a plan id's build, or a machine by name, running or ended, with its billing sentence; a name with no row says "nothing called … has existed here" only when no event ever named it), `plan` a `want`, `check` (looks at the DNS records against Cloudflare now), `apply` a plan id (a plan of dead row `names` clears them; Talk offers it, the person allows it), `keep`, `begin`, `attach`, `record_result`. Only `apply` spends money, so the forge asks the person first.
docs/features/pinned-forge.md +7 −7
@@ -12,9 +12,9 @@ A pinned forge is a forge the owner put on their own cloud. The forge that deplo
1212
1313 - HTTP: `GET /api/v1/admin/pinned` (forges, their changes, the targets), `POST /api/v1/admin/pinned` (deploy; the answer holds `claim.link`), `POST /api/v1/admin/pinned/:name/update`, `POST /api/v1/admin/pinned/:name/rollback`, `POST /api/v1/admin/pinned/:name/claim` (a new claim link).
1414 - Terminal: palette → **Pinned forges** (forge admin): `d` deploy, `u` update, `r` roll back, `f` files the forge's machine and volume in its account's cloud project, `n` a new claim link (asked first); a deploy and `n` show the link in a dialog to copy; it follows the bus, so a change made at any door shows at once (`src/tui/screens/pinned.ts`).
15 - File in a project (#16340): an account's project (set on Settings → Cloud accounts, `P` in the terminal, `set_project` over MCP; DigitalOcean only, since a Hetzner token already belongs to one project) is where a deploy files the machine and volume it makes, both tagged with the forge. A forge made before the project was set is filed by `file`: the **File in project** button on `/pinned`, `f` on the terminal screen, or the MCP `pinned_forge` verb `file`, all through `fileForge` in `src/actions/pinned.ts`; it is safe to repeat. A deploy into a project that does not exist is refused before anything is made. If the cloud refuses the filing after the machine exists, the machine is kept and a `pinned.unfiled` event says the forge stayed in the default project; run `file` to file it.
15 - File in a project (#16340): an account's project (set on Settings → Cloud accounts, `P` in the terminal, `set_project` over MCP; DigitalOcean only, since a Hetzner token already belongs to one project) is where a deploy files the machine and volume it makes, both tagged with the forge. A forge made before the project was set is filed by `file`: the **File in project** button in the Pinned forges block of `/infra`, `f` on the terminal screen, or the MCP `pinned_forge` verb `file`, all through `fileForge` in `src/actions/pinned.ts`; it is safe to repeat. A deploy into a project that does not exist is refused before anything is made. If the cloud refuses the filing after the machine exists, the machine is kept and a `pinned.unfiled` event says the forge stayed in the default project; run `file` to file it.
outdated

Box 3: 'the File in project button on /pinned' should say the Pinned forges block of /infra.

1616 - Web: `/deploy-to` (forge admin; linked from Cloud accounts) is a server-rendered form for cloud account, app, source, version, name and hostname. Its answer is a page with the claim link, sent `no-store`, not a redirect. The link `/deploy-to?app=owner/name&source=https://…&version=v1.2.3` (`deployToHref` in `src/web/pinned.ts`) lands on it with those filled in after one sign-in; nothing deploys until the button is pressed. The POST is same-origin checked and calls the same `deployPinned` (`src/http/pinned_routes.ts`).
17 - Web list: `/pinned` (forge admin; 404 otherwise) is server-rendered, with actions; one block of plain rows per forge: name, app, version, address (a link), health (the state), when the last check ran (the newest `pinned.check` event; `never checked` before the first), and the last change with who and when, from the same `pinnedForges` read as the API (`src/web/pages/pinned.ts`). The intro links `/deploy-to`; an empty list says so. A person can update, roll back and check a forge from `/pinned`, as the terminal's `u`, `r` and `c` do: each row has four buttons (Update, Roll back, Check, New claim link), and each goes through the confirm page before it runs (Update also asks for the version). The row also shows the DNS record and when the claim link runs out. They post to `POST /pinned/:name/:act` (`act` is `update`, `rollback`, `check` or `claim`; admin only, same-origin, 404 for non-admins and unknown acts); the result, or the sentence that refuses it, is shown as a flash on `/pinned` (`src/http/pinned_routes.ts`).
17 - Web list: the Pinned forges block of `/infra` (forge admin; 404 otherwise; `GET /pinned` is a 301 to it, `/pinned#forge-<name>` lands on the forge's block, #17372; the POST routes under `/pinned/` are unchanged) is server-rendered, with actions; one block of plain rows per forge: name, app, version, address (a link), health (the state), when the last check ran (the newest `pinned.check` event; `never checked` before the first), and the last change with who and when, from the same `pinnedForges` read as the API (`src/web/pages/pinned.ts`). The intro links `/deploy-to`; an empty list says so. A person can update, roll back and check a forge from the Pinned forges block of `/infra`, as the terminal's `u`, `r` and `c` do: each row has four buttons (Update, Roll back, Check, New claim link), and each goes through the confirm page before it runs (Update also asks for the version). The row also shows the DNS record and when the claim link runs out. They post to `POST /pinned/:name/:act` (`act` is `update`, `rollback`, `check` or `claim`; admin only, same-origin, 404 for non-admins and unknown acts); the result, or the sentence that refuses it, is shown as a flash on `/infra` (`src/http/pinned_routes.ts`).
outdated

Box 3: this line still says 'update, roll back and check a forge from /pinned' and 'a flash on /pinned'. The page is /infra now. Lines 15, 84, 104 and 116 of this file have the same problem. Reword each to the Pinned forges block of /infra.

1818 - MCP: `pinned_forge` with `verb` `list`, `deploy`, `claim`, `update`, `rollback` (and `check`) — the same words and the same checks (`src/actions/pinned.ts`).
1919
2020 A deploy names a cloud account (Settings → Cloud accounts, **writes allowed**), the app (`owner/name`), a git `source` (https), a `version` (a 40-character commit id or a tag like `v1.2.3` — never a branch, so nothing moves under it) and a `host`: the DNS name the forge is served on. Left empty, `source` is this forge's own repository at its public address (`<FORGE_URL>/<forgeRepo>.git`, which must be public) and `version` the commit this forge runs (`FORGE_COMMIT`); either refusal says which is missing (`ownCode` in `src/actions/pinned.ts`).
@@ -81,17 +81,17 @@ A deploy is made at a place from the Places catalog (`GET /api/v1/places`): `pro
8181 The row records its place (`datacenter` and `size`, in `pinned_size`); the volume and the machine are made in that datacenter, and every replace (Update, Roll back, a new claim link) orders the row's own place, never today's default, because the volume lives there. The ceiling prices that place. A forge deployed before places were kept has none recorded and is read as the place the drivers once hard-coded (DigitalOcean `nyc3` `s-1vcpu-2gb`, Hetzner `nbg1`).
8282
8383 ## The forge waits for its own forges (#16372)
84 After a deploy, an Update, a Roll back and a new claim link the forge itself looks every 5 seconds (`src/actions/pinned_watch.ts`): it reads the machine's address while there is none, writes the DNS record at once, and goes on until the forge answers over HTTPS, for 5 minutes at most. Nobody has to press Check. The time of each step (address, record, answer, giving up) is kept in `pinned_watch` (`src/core/pinned_watch.ts`) and each is one `pinned.watch` event. One loop a forge, held in memory, and `main.ts` starts it again at boot for every forge still waiting. At the bound it says so once: a `pinned.waiting_long` event for admins and a sentence on the forge's row on `/pinned` (and in the terminal screen, `src/tui/screens/pinned.ts`) saying what is missing and what to try. Check still works and reads the same things by hand.
84 After a deploy, an Update, a Roll back and a new claim link the forge itself looks every 5 seconds (`src/actions/pinned_watch.ts`): it reads the machine's address while there is none, writes the DNS record at once, and goes on until the forge answers over HTTPS, for 5 minutes at most. Nobody has to press Check. The time of each step (address, record, answer, giving up) is kept in `pinned_watch` (`src/core/pinned_watch.ts`) and each is one `pinned.watch` event. One loop a forge, held in memory, and `main.ts` starts it again at boot for every forge still waiting. At the bound it says so once: a `pinned.waiting_long` event for admins and a sentence on the forge's row on `/infra` (and in the terminal screen, `src/tui/screens/pinned.ts`) saying what is missing and what to try. Check still works and reads the same things by hand.
8585
8686 ## Pay and go: no DNS work for the buyer (#16205)
8787
88 An admin names the **domain for deployed forges** (`forges.example.com`) on Pinned forges (`/pinned`; the terminal's `b`; `PATCH /api/v1/admin/settings` with `{"pinnedDomain": "forges.example.com"}`, `null` to clear; the MCP tool's `domain` verb). It is a forge setting (`settings/pinned_domain.ts`, `pinned.base_domain`, every change kept with who and when). With one set, a deploy needs no hostname: the forge is served on `<name>.<domain>`; a full hostname may still be given (the terminal's `-` takes the default).
88 An admin names the **domain for deployed forges** (`forges.example.com`) on Infrastructure (`/infra`, under Pinned forges; the terminal's `b`; `PATCH /api/v1/admin/settings` with `{"pinnedDomain": "forges.example.com"}`, `null` to clear; the MCP tool's `domain` verb). It is a forge setting (`settings/pinned_domain.ts`, `pinned.base_domain`, every change kept with who and when). With one set, a deploy needs no hostname: the forge is served on `<name>.<domain>`; a full hostname may still be given (the terminal's `-` takes the default).
8989
9090 With a **Cloudflare** cloud account attached and writes allowed, the forge then writes the record itself: after the machine has an address (the deploy, and every Update, Roll back and new claim link), and again on Check, it upserts `<host> A <address>` in the zone that holds the name, through the first such account whose token can edit that zone: found by name and updated, or made, so a replaced machine's new address changes the record and never adds one; DNS only (not proxied, so the machine gets its own certificate), TTL 60. The calls go to `api.cloudflare.com` only (`upsertARecord`, `src/cloud/providers.ts`), the token in the Authorization header alone, each call audited as `pinned:dns` like the other cloud calls; the record's id and zone are kept (`pinned_dns`) with the account that wrote it. A zone the token cannot see or edit, a CNAME already at the name, or any refusal leaves the record for a person to make, and the deploy answer and Check say that instead (`dnsWrittenBy` is empty). The token needs DNS edit on the zone; the cloud account's check cannot tell that, so the first write is the proof.
9191
9292 ## Paid forges on a cloud machine (#16205)
9393
94 An admin chooses where **paid forges run** on Pinned forges (`/pinned`; the terminal's `p`; `PATCH /api/v1/admin/settings` with `{"paidPlacement": "digitalocean/main"}`, `"hosted"` or `null` for the default; `GET` answers it as `paidPlacement`). It is a forge setting (`settings/paid_placement.ts`, `paid.placement`, every change kept with who and when). `hosted`, the default, is today's: a bought forge runs inside this one. A cloud account (one a pinned forge can be deployed to, with writes allowed) makes each paid order a pinned forge of its own (`src/spawn/cloud_placement.ts`). Free forges always stay hosted.
94 An admin chooses where **paid forges run** on Infrastructure (`/infra`, under Pinned forges; the terminal's `p`; `PATCH /api/v1/admin/settings` with `{"paidPlacement": "digitalocean/main"}`, `"hosted"` or `null` for the default; `GET` answers it as `paidPlacement`). It is a forge setting (`settings/paid_placement.ts`, `paid.placement`, every change kept with who and when). `hosted`, the default, is today's: a bought forge runs inside this one. A cloud account (one a pinned forge can be deployed to, with writes allowed) makes each paid order a pinned forge of its own (`src/spawn/cloud_placement.ts`). Free forges always stay hosted.
9595
9696 - **Told before paying.** `/pricing` (and the terminal's pricing screen) asks the cloud placement's `room` before the checkout is made: no domain for deployed forges, a catalog never read, a default place that cannot be ordered, or a deploy the account's ceiling would refuse, each is said in the deploy's own sentence, and nothing is held or charged.
9797 - **Deployed as the order.** Once paid, the forge is deployed at the catalog's default place for the plan, with no hostname (it is served on `<name>.<domain>`), running the forge's own source repository (public) at the commit this forge runs (`FORGE_COMMIT`; a forge run from source refuses, and so does one that knows only a release tag: a sale takes a commit). The source is where the owner says (see *Money and trust* below), never this forge's own address. The deploy acts as the order, never a borrowed admin: the row's history says `order:<id>`, its events carry `order` and no actor, and the token reads name the order in their run. Every refusal an admin's deploy has (target, catalog, place, ceiling) applies.
@@ -101,7 +101,7 @@ An admin chooses where **paid forges run** on Pinned forges (`/pinned`; the term
101101
102102 ## Retiring a forge (#16219)
103103
104 A test forge, or one whose buyer left, would bill forever without a way out. **Retire** (`POST /api/v1/admin/pinned/:name/retire`, the `pinned_forge` tool's `retire` verb, Retire on `/pinned`, `x` in the terminal) deletes the forge's machine and the DNS record the forge wrote for it (job above), and keeps its data volume: the answer says what keeping it costs a month at list price. The row ends `retired`, and the account's ceiling counts it at that volume's price alone. The volume is deleted only by the second word: `withData` on the API and the tool, **Retire and delete its data** on the page (which asks for the forge's name), and a second choice and the name in the terminal. That call is the data-destroying one under the delete tier (`tier: "delete"` on the tool, `test/delete-tier.test.ts`): the forge's own agent is refused it with the page to use. A **retired forge** can be retired again with its data, and nothing else: Update, Roll back, a new claim link and Check refuse it. It is idempotent: a machine or volume already gone at the cloud (a 404) is done, so asking again finishes a retire whose volume the cloud would not delete (the machine is gone and the forge `retired` by then, its data kept). A forge its buyer has claimed, as the forge itself says when asked (or as recorded), is refused with the sentence that its data is on that volume, unless `despiteClaim` says the owner means it (the page's form for a claimed forge carries it; the terminal asks in its question). One event, `pinned.retired`, says who, whether the data went, and what became of the record.
104 A test forge, or one whose buyer left, would bill forever without a way out. **Retire** (`POST /api/v1/admin/pinned/:name/retire`, the `pinned_forge` tool's `retire` verb, Retire in the Pinned forges block of `/infra`, `x` in the terminal) deletes the forge's machine and the DNS record the forge wrote for it (job above), and keeps its data volume: the answer says what keeping it costs a month at list price. The row ends `retired`, and the account's ceiling counts it at that volume's price alone. The volume is deleted only by the second word: `withData` on the API and the tool, **Retire and delete its data** on the page (which asks for the forge's name), and a second choice and the name in the terminal. That call is the data-destroying one under the delete tier (`tier: "delete"` on the tool, `test/delete-tier.test.ts`): the forge's own agent is refused it with the page to use. A **retired forge** can be retired again with its data, and nothing else: Update, Roll back, a new claim link and Check refuse it. It is idempotent: a machine or volume already gone at the cloud (a 404) is done, so asking again finishes a retire whose volume the cloud would not delete (the machine is gone and the forge `retired` by then, its data kept). A forge its buyer has claimed, as the forge itself says when asked (or as recorded), is refused with the sentence that its data is on that volume, unless `despiteClaim` says the owner means it (the page's form for a claimed forge carries it; the terminal asks in its question). One event, `pinned.retired`, says who, whether the data went, and what became of the record.
105105
106106 ## Experiments
107107
@@ -113,7 +113,7 @@ A forge can end on its own. `lifetimeDays` at deploy (1 to 90) sets when, and a
113113
114114 ## After the claim: what the host can still do (#16204)
115115
116 Nobody marks a forge claimed by hand: the deployed forge says so. Check, and every Update, Roll back and request for a new claim link, asks it first; when one hears `claimed` (The claim, above), the selling forge records it once (`pinned_forge.claimed_at`, event `pinned.claimed`). From then it refuses `update`, `rollback` and a new claim link for that forge, each with the same sentence (`CLAIMED_REFUSAL`): updates are the buyer's to take, and no machine of theirs is replaced from here. A forge that cannot be asked is never recorded as claimed, and is not taken as unclaimed either: once its current machine has answered about its claim (`pinned_forge.reached`), silence from it (a broken DNS record, a forge that is down) refuses Update, Roll back and a new claim link, with a sentence saying the forge could not be reached to confirm nobody claimed it and to run Check until it answers. A forge whose current machine has never answered (still booting, DNS not pointed yet, a first boot that failed) may still be replaced, or it could never be recovered. The question starts with a read of the machine at its cloud: when the cloud refuses that read the change is refused with the cloud's answer, before anything is recorded; a machine that is gone (404) has nobody to ask and is replaced. `/pinned` (once, when any forge is claimed) and `/deploy-to` say what the host still can while the machine is in the host's cloud account (`HOST_CAN` in `src/core/pinned.ts`): open its console, boot it into rescue, snapshot its disk, read its boot data. It never says "no access". The path that gives the host none is the buyer's own cloud account: deploy there (the account picker on `/deploy-to`; choosing it at purchase is #16203).
116 Nobody marks a forge claimed by hand: the deployed forge says so. Check, and every Update, Roll back and request for a new claim link, asks it first; when one hears `claimed` (The claim, above), the selling forge records it once (`pinned_forge.claimed_at`, event `pinned.claimed`). From then it refuses `update`, `rollback` and a new claim link for that forge, each with the same sentence (`CLAIMED_REFUSAL`): updates are the buyer's to take, and no machine of theirs is replaced from here. A forge that cannot be asked is never recorded as claimed, and is not taken as unclaimed either: once its current machine has answered about its claim (`pinned_forge.reached`), silence from it (a broken DNS record, a forge that is down) refuses Update, Roll back and a new claim link, with a sentence saying the forge could not be reached to confirm nobody claimed it and to run Check until it answers. A forge whose current machine has never answered (still booting, DNS not pointed yet, a first boot that failed) may still be replaced, or it could never be recovered. The question starts with a read of the machine at its cloud: when the cloud refuses that read the change is refused with the cloud's answer, before anything is recorded; a machine that is gone (404) has nobody to ask and is replaced. The Pinned forges block of `/infra` (once, when any forge is claimed) and `/deploy-to` say what the host still can while the machine is in the host's cloud account (`HOST_CAN` in `src/core/pinned.ts`): open its console, boot it into rescue, snapshot its disk, read its boot data. It never says "no access". The path that gives the host none is the buyer's own cloud account: deploy there (the account picker on `/deploy-to`; choosing it at purchase is #16203).
117117
118118 ## Targets: what runs, what it costs, what is refused
119119
docs/features/pricing.md +1 −1
@@ -29,7 +29,7 @@ as what will happen; the terminal screen hides them.
2929
3030 ## Price follows the place, and at-cost codes (#16205)
3131
32 When paid forges run on a cloud account (Pinned forges → "paid forges run on"), the buyer may pick where it runs. The plan's price is for the plan's default place. A dearer place adds the difference to the monthly price, rounded up to the next dollar: "Show the price" renders the plans with the chosen place and says on each plan what the place adds, and the checkout line says it too ("Small forge (digitalocean:nyc3:s-2vcpu-4gb: +$12 a month)"). The amount is fixed when the order is placed and kept on the order, and the checkout charges exactly it (inline `price_data`, no dashboard setup).
32 When paid forges run on a cloud account (Infrastructure → Pinned forges → "paid forges run on"), the buyer may pick where it runs. The plan's price is for the plan's default place. A dearer place adds the difference to the monthly price, rounded up to the next dollar: "Show the price" renders the plans with the chosen place and says on each plan what the place adds, and the checkout line says it too ("Small forge (digitalocean:nyc3:s-2vcpu-4gb: +$12 a month)"). The amount is fixed when the order is placed and kept on the order, and the checkout charges exactly it (inline `price_data`, no dashboard setup).
3333
3434 An **at-cost code** is made where a gift code is (Settings → Billing → Codes, `POST /api/v1/codes` with `kind: "at_cost"`, the terminal's codes screen with `c`), with uses and an expiry as now; the link it gives is `/pricing?code=…`. A buyer with one pays the place's monthly cost plus the payment fee (`src/billing/at_cost.ts`: 2.9% and 30 cents, grossed up so the forge keeps the cost), rounded up to the next dollar: the plan row shows "was" the normal price and "at cost" with the amount. A code is for one plan and never gives a plan free: the gift door refuses it (`wrong_kind`), and a gift code is refused here. A use is held by each open checkout (name held for 30 minutes) and spent when it is paid, so one use cannot fund many pending orders; a checkout that lapses gives its use back. Revoking stops new checkouts; one already open and paid is honoured at the price it quoted. Every look at a code, by the link or by Show the price, counts a try for the client, as a gift code's does.
3535
src/actions/infra.ts +1 −1
@@ -651,7 +651,7 @@ function fixOf(r: Refusal, wants: readonly Want[]): { why: string; href: string;
651651 const provider = account.split("/")[0] ?? "";
652652 const label = isProvider(provider) ? LABEL[provider] : account;
653653 if (r.why === READ_ONLY) return { why: r.why, href: accountHref(account), label: `Allow writes on ${label}` };
654 if (r.why === HOST_NEEDED) return { why: r.why, href: "/pinned#domain", label: "Set a domain for deployed forges" };
654 if (r.why === HOST_NEEDED) return { why: r.why, href: "/infra#domain", label: "Set a domain for deployed forges" };
655655 if (/ is held to \$\d+ a month/.test(r.why)) return { why: r.why, href: accountHref(account), label: `Raise the ceiling on ${label}` };
656656 if (/ shows (an orphan|\d+ orphans) /.test(r.why))
657657 return { why: r.why, href: accountHref(account), label: `See what the watch found at ${label}` };
src/http/infra_routes.ts +3 −1
@@ -19,6 +19,7 @@ import { html } from "../web/html.ts";
1919 import { flashTo, fragment, page } from "../web/layout.ts";
2020 import { machineView } from "../actions/machine_view.ts";
2121 import { INFRA_CSS, cloudPage, consolePage, endingPage, buildTray, placesRegion, composeForm, infraJs, infraPage, planTray, recordForm, runningRegion, type ComposeState } from "../web/pages/infra.ts";
22 import { pinnedBlock } from "./pinned_routes.ts";
2223 import type { Ctx, Handler } from "./context.ts";
2324 import type { Router } from "./router.ts";
2425
@@ -73,7 +74,8 @@ async function render(
7374 const projects = timePhase(ctx.request, "projects", () => projectsView(ctx.app, user));
7475 // What each provider says, as kept: no page waits on a provider; a fresh reading redraws the live region.
7576 const cloud = cloudFactsAll(ctx.app, view.value.groups.flatMap((g) => g.machines.map((m) => m.name)));
76 const body = infraPage(view.value, compose, build, { composing: o.composing, code: code.ok ? code.value : [], records: recordForm(recordAccounts(ctx.app)), projects: projects.ok ? projects.value : [], cloud });
77 const pinned = pinnedBlock(ctx);
78 const body = infraPage(view.value, compose, build, { composing: o.composing, code: code.ok ? code.value : [], records: recordForm(recordAccounts(ctx.app)), projects: projects.ok ? projects.value : [], cloud, ...(pinned ? { pinned } : {}) });
7779 return page({ ctx, title: "Infrastructure", scriptJs: SCRIPT, styleCss: INFRA_CSS, body, ...(o.flash ? { flash: o.flash } : {}) }, status);
7880 }
7981
src/http/mcp/tools/pinned_forge.ts +1 −1
@@ -10,7 +10,7 @@ export const tool: Tool = {
1010 description: "Pinned forges on your cloud: list, deploy, claim, update, rollback, check, retire (admin).",
1111 tier: "delete",
1212 deletes: (args) => args["verb"] === "retire" && args["withData"] === true,
13 where: "on the Pinned forges page (/pinned), where Retire and delete its data asks for the forge's name",
13 where: "on the Infrastructure page (/infra), where Retire and delete its data asks for the forge's name",
1414 inputSchema: {
1515 type: "object",
1616 properties: {
src/http/pinned_routes.ts +19 −17
@@ -17,9 +17,8 @@ import { getUsersByIds } from "../core/users.ts";
1717 import { notFoundPage, signInFirst } from "../web/chrome.ts";
1818 import { field, readForm } from "../web/form.ts";
1919 import { flashTo, page } from "../web/layout.ts";
20 import { liveRegionsJs } from "../web/client.ts";
21 import { behaviorsJs } from "../web/behaviors.ts";
22 import { pinnedListPage } from "../web/pages/pinned.ts";
20 import { pinnedRegion } from "../web/pages/pinned.ts";
21 import type { Html } from "../web/html.ts";
2322 import { deployPage, issuedPage, nameFor, type DeployForm } from "../web/pinned.ts";
2423 import type { Handler, Ctx } from "./context.ts";
2524 import type { Router } from "./router.ts";
@@ -78,10 +77,13 @@ async function deployToSubmit(ctx: Ctx): Promise<Response> {
7877 return shown(ctx, `Deployed ${made.value.name}`, made.value);
7978 }
8079
81 function listPage(ctx: Ctx): Response {
82 if (!ctx.auth.user) return signInFirst(ctx);
80 /** `/pinned` is folded into /infra: forever (301); the browser keeps `#forge-<name>`. */
81 const listPage = (): Response => new Response(null, { status: 301, headers: { location: "/infra" } });
82
83 /** The pinned forges' block of /infra, for a forge admin; nothing for anyone else. */
84 export function pinnedBlock(ctx: Ctx): Html | undefined {
8385 const forges = pinnedForges(ctx.app, ctx.auth.user);
84 if (!forges.ok) return notFoundPage(ctx);
86 if (!forges.ok) return undefined;
8587 const users = getUsersByIds(ctx.app.db, forges.value.flatMap((p) => p.changes.slice(0, 1).map((c) => c.by)));
8688 const names = new Map([...users].map(([id, u]) => [id, u.username]));
8789 const checks = new Map<string, string>();
@@ -89,7 +91,7 @@ function listPage(ctx: Ctx): Response {
8991 const at = lastCheckOf(ctx.app.db, p.name);
9092 if (at) checks.set(p.name, at);
9193 }
92 return page({ ctx, title: "Pinned forges", scriptJs: `${liveRegionsJs}\n${behaviorsJs}`, body: pinnedListPage(forges.value, { names, checks, domain: getBaseDomain(ctx.app.db), paid: paidOf(ctx), experiments: experiments(ctx.app.db) }) });
94 return pinnedRegion(forges.value, { names, checks, domain: getBaseDomain(ctx.app.db), paid: paidOf(ctx), experiments: experiments(ctx.app.db) });
9395 }
9496
9597 /**
@@ -109,26 +111,26 @@ async function pinnedAct(ctx: Ctx): Promise<Response> {
109111 else if (act === "rollback") done = await rollbackPinned(ctx.app, user, name);
110112 else if (act === "check") {
111113 const seen = await checkPinned(ctx.app, user, name);
112 return flashTo(ctx, "/pinned", seen.ok ? { tone: seen.value.healthy ? "success" : "attn", message: checkWords(seen.value) } : { tone: "danger", message: seen.error });
114 return flashTo(ctx, "/infra", seen.ok ? { tone: seen.value.healthy ? "success" : "attn", message: checkWords(seen.value) } : { tone: "danger", message: seen.error });
113115 } else if (act === "retire" || act === "retire-data") {
114116 // Retire keeps the data; Retire and delete its data is its own act, behind the name typed on
115117 // the confirm page. A claimed forge is retired only when the form says the owner means it.
116118 const gone = await retirePinned(ctx.app, user, name, { withData: act === "retire-data", despiteClaim: field(form, "despite_claim") === "1" });
117 return flashTo(ctx, "/pinned", gone.ok ? { tone: "success", message: retireWords(gone.value) } : { tone: "danger", message: gone.error });
119 return flashTo(ctx, "/infra", gone.ok ? { tone: "success", message: retireWords(gone.value) } : { tone: "danger", message: gone.error });
118120 } else if (act === "keep") {
119121 const kept = keepPinned(ctx.app, user, name);
120 return flashTo(ctx, "/pinned", kept.ok ? { tone: "success", message: `${name} now ends ${endsWords(kept.value.endsAt!)}.` } : { tone: "danger", message: kept.error });
122 return flashTo(ctx, "/infra", kept.ok ? { tone: "success", message: `${name} now ends ${endsWords(kept.value.endsAt!)}.` } : { tone: "danger", message: kept.error });
121123 } else if (act === "file") {
122124 const filed = await fileForge(ctx.app, user, name);
123 return flashTo(ctx, "/pinned", filed.ok ? { tone: "success", message: filed.value } : { tone: "danger", message: filed.error });
125 return flashTo(ctx, "/infra", filed.ok ? { tone: "success", message: filed.value } : { tone: "danger", message: filed.error });
124126 } else if (act === "claim") {
125127 const made = await claimPinned(ctx.app, user, name, { host: field(form, "host") });
126 return made.ok ? shown(ctx, `A new claim link for ${name}`, made.value) : flashTo(ctx, "/pinned", { tone: "danger", message: made.error });
128 return made.ok ? shown(ctx, `A new claim link for ${name}`, made.value) : flashTo(ctx, "/infra", { tone: "danger", message: made.error });
127129 } else return notFoundPage(ctx);
128 if (!done.ok) return flashTo(ctx, "/pinned", { tone: "danger", message: done.error });
130 if (!done.ok) return flashTo(ctx, "/infra", { tone: "danger", message: done.error });
129131 const at = done.value.version.slice(0, 12);
130132 const message = act === "update" ? `Updated ${name} to ${at}.` : `Rolled ${name} back to ${at}.`;
131 return flashTo(ctx, "/pinned", { tone: "success", message });
133 return flashTo(ctx, "/infra", { tone: "success", message });
132134 }
133135
134136 /**
@@ -151,7 +153,7 @@ async function experimentAct(ctx: Ctx): Promise<Response> {
151153 ? attachMachine(ctx.app, who, field(form, "id"), field(form, "name"))
152154 : recordResult(ctx.app, who, field(form, "id"), field(form, "result"));
153155 const said = act === "begin" ? "Experiment begun." : act === "attach" ? `Attached ${field(form, "name")}.` : "Result recorded: the experiment is done.";
154 return flashTo(ctx, "/pinned", done.ok ? { tone: "success", message: said } : { tone: "danger", message: EXPERIMENT_WORDS[done.error] });
156 return flashTo(ctx, "/infra", done.ok ? { tone: "success", message: said } : { tone: "danger", message: EXPERIMENT_WORDS[done.error] });
155157 }
156158
157159 /** Save the domain deployed forges are served on: the same change the API, MCP and terminal make. */
@@ -162,7 +164,7 @@ async function domainSubmit(ctx: Ctx): Promise<Response> {
162164 if (form instanceof Response) return form;
163165 const set = changeBaseDomain(ctx.app, ctx.auth.user, field(form, "domain"));
164166 if (!set.ok && set.error === "not_found") return notFoundPage(ctx);
165 return flashTo(ctx, "/pinned", set.ok ? { message: set.value === "" ? "Domain for deployed forges cleared." : `Deployed forges are served on <name>.${set.value}.` } : { tone: "danger", message: `${DOMAIN_WORDS}. Nothing was saved.` });
167 return flashTo(ctx, "/infra", set.ok ? { message: set.value === "" ? "Domain for deployed forges cleared." : `Deployed forges are served on <name>.${set.value}.` } : { tone: "danger", message: `${DOMAIN_WORDS}. Nothing was saved.` });
166168 }
167169
168170 const paidOf = (ctx: Ctx): string => {
@@ -178,7 +180,7 @@ async function paidSubmit(ctx: Ctx): Promise<Response> {
178180 if (form instanceof Response) return form;
179181 const set = changePaidPlacement(ctx.app, ctx.auth.user, field(form, "paid"));
180182 if (!set.ok && set.error === "not_found") return notFoundPage(ctx);
181 return flashTo(ctx, "/pinned", set.ok ? { message: set.value === "hosted" ? "Paid forges run hosted, inside this forge." : `Paid forges are deployed on ${set.value}.` } : { tone: "danger", message: `${PAID_PLACEMENT_WORDS}. Nothing was saved.` });
183 return flashTo(ctx, "/infra", set.ok ? { message: set.value === "hosted" ? "Paid forges run hosted, inside this forge." : `Paid forges are deployed on ${set.value}.` } : { tone: "danger", message: `${PAID_PLACEMENT_WORDS}. Nothing was saved.` });
182184 }
183185
184186 export function pinnedRoutes(router: Router<Handler>): void {
src/maintain/duties/pinned_lifetimes.ts +1 −1
@@ -55,7 +55,7 @@ export async function tickLifetimes(
5555 if (ends - now.getTime() <= WARN_MS && markWarned(app.db, p.id, now.toISOString())) {
5656 app.bus.append({ kind: "pinned.ending_soon", payload: { name: p.name, endsAt: l.endsAt } });
5757 findings.push({
58 summary: `${p.name} ends ${endsWords(l.endsAt, now)}: Keep it on /pinned for ${LIFETIME_DAYS} more days, or let it retire with its data kept`,
58 summary: `${p.name} ends ${endsWords(l.endsAt, now)}: Keep it on /infra for ${LIFETIME_DAYS} more days, or let it retire with its data kept`,
5959 });
6060 }
6161 }
src/tui/screens/experiments.ts +3 −3
@@ -1,10 +1,10 @@
11 /**
2 * Experiments in the terminal, a forge admin's (#16583): the same read as the /pinned page, each
2 * Experiments in the terminal, a forge admin's (#16583): the same read as the /infra page, each
33 * experiment with its machines, what it costs a month now, what it has cost and its result, then
44 * every machine that costs money on no experiment as idle spend. `b` begins one (a question, then
55 * the machines it runs on), `a` attaches machines to the selected experiment, `r` records its
66 * result, each through `cloud/experiments.ts`, so the event every write appends updates the page
7 * of anyone watching /pinned. Retiring stays on the pinned forges screen. Anyone else sees nothing.
7 * of anyone watching /infra. Retiring stays on the pinned forges screen. Anyone else sees nothing.
88 */
99
1010 import {
@@ -144,7 +144,7 @@ export function experimentsScreen(f: Session, ctx: Ctx): Screen {
144144 return screen;
145145 }
146146
147 /** Experiments, as the /pinned page and the MCP have them: a forge admin. */
147 /** Experiments, as the /infra page and the MCP have them: a forge admin. */
148148 export const entry: PaletteEntry = {
149149 rank: 871,
150150 id: "experiments",
src/tui/screens/infra.ts +1 −1
@@ -633,7 +633,7 @@ export function infraScreen(f: Session, ctx: Ctx): Screen {
633633 confirmScreen(ctx, screen, {
634634 title: `End ${picked.name} now?`,
635635 body: [
636 "Its machine is deleted and stops billing. Its disk is kept, and keeps costing what a disk costs, until you delete it on Pinned forges.",
636 "Its machine is deleted and stops billing. Its disk is kept, and keeps costing what a disk costs, until you delete it on the Pinned forges screen.",
637637 ...(offered ? [picked.offer] : []),
638638 ],
639639 actions: offered
src/web/pages/cloud.ts +1 −1
@@ -210,7 +210,7 @@ export async function cloudPage(ctx: Ctx): Promise<Response> {
210210 ${settingsLayout(
211211 accountSections("cloud", { admin: true, ssh: sshOn(ctx.app.db) }),
212212 html`${accountsCard(ctx.app.db, accounts, reads, uses)}${readsCard(reads)}
213 <p class="muted small"><a href="/settings/cloud/audit">Every vendor call today</a> · <a href="/infra">Infrastructure</a> · <a href="/pinned">Pinned forges</a> · <a href="/deploy-to">Deploy a pinned forge</a></p>`,
213 <p class="muted small"><a href="/settings/cloud/audit">Every vendor call today</a> · <a href="/infra">Infrastructure</a> · <a href="/deploy-to">Deploy a pinned forge</a></p>`,
214214 "Account settings",
215215 )}`,
216216 });
src/web/pages/infra.ts +4 −3
@@ -225,7 +225,7 @@ export function runningRegion(v: InfraView, cloud: ReadonlyMap<string, { label:
225225 v.ended.map((r) =>
226226 row({
227227 title: html`<span class="mono">${r.name}</span>`,
228 meta: html`${r.billing}${r.bills === "disk" ? html` · <a href="/pinned#forge-${r.name}">delete it on Pinned forges</a>` : null}`,
228 meta: html`${r.billing}${r.bills === "disk" ? html` · <a href="#forge-${r.name}">delete its disk below</a>` : null}`,
229229 ...(r.monthlyCents > 0 ? { trail: html`<span>${money(r.monthlyCents)}<span class="muted"> a month</span></span>` } : {}),
230230 data: { bills: r.bills },
231231 }),
@@ -618,7 +618,7 @@ export function infraPage(
618618 v: InfraView,
619619 compose: Html,
620620 build: Build | undefined,
621 s: { composing: boolean; records?: Html; code?: readonly CodeFile[]; projects?: readonly ProjectView[]; cloud?: ReadonlyMap<string, { label: string; value: string }> },
621 s: { composing: boolean; records?: Html; code?: readonly CodeFile[]; projects?: readonly ProjectView[]; cloud?: ReadonlyMap<string, { label: string; value: string }>; pinned?: Html },
622622 ): Html {
623623 const open = s.composing || v.groups.length === 0;
624624 return html`${pageHead("Infrastructure", { sub: "What runs on your own cloud, what it's for, what it costs, and when it ends." })}
@@ -632,7 +632,8 @@ export function infraPage(
632632 ${disclosure("Build something", compose, { id: "compose-open", open })}
633633 </section>`}
634634 ${s.records === undefined ? null : html`<section class="settings-block" data-record-block>${disclosure("Make a DNS record", s.records, { id: "record-open", open: false })}</section>`}
635 <p class="muted small"><a href="/pinned">Pinned forges</a> · <a href="/settings/cloud">Cloud accounts</a></p>
635 ${s.pinned ?? null}
636 <p class="muted small"><a href="/settings/cloud">Cloud accounts</a></p>
636637 </div>`;
637638 }
638639
src/web/pages/pinned.ts +16 −10
@@ -1,7 +1,7 @@
11 /**
2 * `/pinned` (#10106): the pinned forges, one block of plain rows each, read
3 * from the same `pinnedForges` the API, MCP and terminal use. The last check
4 * is when the newest `pinned.check` event for the forge was written.
2 * The pinned forges' part of `/infra` (#10106, folded in by #17372; `/pinned` redirects): one block
3 * of plain rows each, read from the same `pinnedForges` the API, MCP and terminal use. The last
4 * check is when the newest `pinned.check` event for the forge was written.
55 */
66
77 import { LIFETIME_DAYS, endsWords, type PinnedView } from "../../actions/pinned.ts";
@@ -9,7 +9,6 @@ import type { Experiment, Experiments, Machine } from "../../cloud/experiments.t
99 import { dollars } from "../../cloud/prices.ts";
1010 import { billsWords, existsAtProvider } from "../../cloud/billing.ts";
1111 import { HOST_CAN } from "../../core/pinned.ts";
12 import { pageHead } from "../chrome.ts";
1312 import { html, type Html } from "../html.ts";
1413 import { badge, btn, field, row, rowList, time, type Tone } from "../ui.ts";
1514
@@ -32,8 +31,9 @@ const none = (text: string): Html => html`<span class="muted">${text}</span>`;
3231
3332 /**
3433 * Retire, or delete what a retired forge kept (`act`), through the confirm page, which posts to
35 * `/pinned/<name>/<act>`; a claimed forge's form says the owner means it (`despite_claim`). The
36 * forge's own block and its idle spend row both call this, so the two never drift.
34 * `/pinned/<name>/<act>` (the routes keep that path; the pages that show them are /infra); a
35 * claimed forge's form says the owner means it (`despite_claim`). The forge's own block and its
36 * idle spend row both call this, so the two never drift.
3737 */
3838 const retireForm = (name: string, act: "retire" | "retire-data", label: string, claimed: boolean): Html => html`<form method="get" action="/-/confirm">
3939 <input type="hidden" name="to" value="/pinned/${name}/${act}" />
@@ -205,9 +205,14 @@ function forge(p: PinnedView, f: PinnedFacts): Html {
205205 </section>`;
206206 }
207207
208 export function pinnedListPage(forges: PinnedView[], f: PinnedFacts): Html {
209 return html`${pageHead("Pinned forges", { sub: "The forges you run on your own cloud, and the question each one's spend answers." })}
210 <p><a href="/infra">Infrastructure</a>: what runs on your cloud, by what it is for · <a href="/deploy-to">Deploy a pinned forge</a></p>
208 /**
209 * The pinned forges' part of /infra: experiments, the domain and paid settings, then each forge's
210 * block.
211 */
212 export function pinnedRegion(forges: PinnedView[], f: PinnedFacts): Html {
213 return html`<div id="pinned-forges">
214 <h2>Pinned forges</h2>

Principle 1: the page head on /infra already says what the page is for. This block's h2 plus a second muted sentence explains itself twice. Keep one short sentence and the Deploy link.

215 <p class="muted small"><a href="/deploy-to">Deploy a pinned forge</a> to one of your cloud accounts.</p>
211216 ${f.experiments === undefined ? null : experimentsSection(f.experiments, forges)}
212217 <form method="post" action="/pinned/domain" class="stack" id="domain">
213218 ${field({ name: "domain", label: "Domain for deployed forges", value: f.domain, placeholder: "forges.example.com", mono: true, maxlength: 253, spellcheck: false, hint: "A forge deployed with no hostname is served on <name>.<domain>, so its buyer configures no DNS. With a Cloudflare account that allows writes and a token that can edit the zone, the forge writes the record itself, after every replace too. Empty for none." })}
@@ -218,5 +223,6 @@ export function pinnedListPage(forges: PinnedView[], f: PinnedFacts): Html {
218223 ${btn("Save", { variant: "secondary", label: "Save where paid forges run" })}
219224 </form>
220225 ${forges.some((p) => p.claimedAt !== "") ? html`<p class="muted small">${HOST_CAN}</p>` : null}
221 ${forges.length === 0 ? html`<p role="status">No pinned forge yet. Deploy one to a cloud account that allows writes.</p>` : forges.map((p) => forge(p, f))}`;
226 ${forges.length === 0 ? html`<p role="status">No pinned forge yet. Deploy one to a cloud account that allows writes.</p>` : forges.map((p) => forge(p, f))}
227 </div>`;
222228 }
src/web/pinned.ts +1 −1
@@ -52,7 +52,7 @@ export function issuedPage(title: string, v: Issued): Html {
5252 ${copyField("pinned-claim-link", v.claim.link, `Claim link for ${v.name}`, "Copy the link")}
5353 <p class="muted small">
5454 Hand it to the person the forge is for, by a channel you trust. This forge keeps only its hash: if the
55 link is lost or runs out, issue a new one from <a href="/pinned">Pinned forges</a>, and this one stops working.
55 link is lost or runs out, issue a new one from <a href="/infra">Infrastructure</a>, and this one stops working.
5656 </p>`,
5757 )}`;
5858 }
test/experiments-routes.test.ts +5 −5
@@ -33,7 +33,7 @@ describe("experiment routes", () => {
3333 /** The flash a redirect to /pinned carries in its cookie (`web/flash.ts`). */
3434 const landed = async (r: Response, _tok: string): Promise<string> => {
3535 expect(r.status).toBe(303);
36 expect(r.headers.get("location") ?? "").toStartWith("/pinned");
36 expect(r.headers.get("location") ?? "").toStartWith("/infra");
3737 return decodeURIComponent(r.headers.get("set-cookie") ?? "");
3838 };
3939
@@ -64,14 +64,14 @@ describe("experiment routes", () => {
6464 // As pinned-page.test.ts has it: signed out, /pinned sends to sign-in; a non-admin's admin-scope
6565 // token is refused (403) before any form route runs; a signed-out POST changes nothing.
6666 test("a guest is sent to sign in, and anyone but an admin is refused", async () => {
67 const page = await fetch(`${servers.url}/pinned`, { redirect: "manual" });
68 expect(page.status, "a guest reading /pinned").toBe(303);
67 const page = await fetch(`${servers.url}/infra`, { redirect: "manual" });
68 expect(page.status, "a guest reading /infra").toBe(303);
6969 expect(page.headers.get("location") ?? "", "where a guest is sent").toContain("/signin");
7070 const guest = await post("/pinned/experiment/begin", { question: "q" });
7171 expect([303, 401, 403], `a guest's POST answered ${guest.status}`).toContain(guest.status);
72 expect(guest.headers.get("location") ?? "", "a guest's POST never lands on /pinned").not.toStartWith("/pinned");
72 expect(guest.headers.get("location") ?? "", "a guest's POST never lands on /infra").not.toStartWith("/infra");
7373 expect((await post("/pinned/experiment/begin", { question: "q" }, bobTok)).status, "a non-admin's POST").toBe(403);
74 expect((await fetch(`${servers.url}/pinned`, { redirect: "manual", headers: { authorization: `Bearer ${bobTok}` } })).status, "a non-admin reading /pinned").not.toBe(200);
74 expect((await fetch(`${servers.url}/infra`, { redirect: "manual", headers: { authorization: `Bearer ${bobTok}` } })).status, "a non-admin reading /infra").not.toBe(200);
7575 expect(experiments(app.db).items, "nothing was begun").toEqual([]);
7676 });
7777
test/experiments.test.ts +3 −3
@@ -20,7 +20,7 @@ import { tool } from "../src/http/mcp/tools/infra.ts";
2020 import { createForgeApp } from "../src/tui/forge.ts";
2121 import { experimentsScreen } from "../src/tui/screens/experiments.ts";
2222 import { headlessTerminal } from "../src/tui/term/terminal.ts";
23 import { pinnedListPage } from "../src/web/pages/pinned.ts";
23 import { pinnedRegion } from "../src/web/pages/pinned.ts";
2424 import { quietLogs } from "./helpers/globals.ts";
2525 import { seedPlaces } from "./helpers/places-fixture.ts";
2626 import { settleApp } from "./helpers/tui.ts";
@@ -35,7 +35,7 @@ describe("experiments", () => {
3535 const render = (): string => {
3636 const forges = pinnedForges(app, admin);
3737 if (!forges.ok) throw new Error("not admin");
38 return String(pinnedListPage(forges.value, { names: new Map(), checks: new Map(), domain: "", experiments: experiments(app.db) }));
38 return String(pinnedRegion(forges.value, { names: new Map(), checks: new Map(), domain: "", experiments: experiments(app.db) }));
3939 };
4040 const call = async (args: Record<string, unknown>): Promise<any> =>
4141 tool.run({ app, auth: { user: admin, scope: "admin" } } as any, admin, args);
@@ -128,7 +128,7 @@ describe("experiments", () => {
128128 expect(x.idle.map((m) => m.name)).toEqual(["spare", "test1"]);
129129
130130 const page = render();
131 expect(page).toContain("the question each one&#39;s spend answers");
131 expect(page).toContain("Deploy a pinned forge");
132132 expect(page).toContain(`data-experiment="${e.id}"`);
133133 expect(page).toContain(`${dollars(e.monthlyCents)} a month`);
134134 const region = page.slice(page.indexOf('id="experiments"'), page.indexOf("</section>", page.indexOf('id="experiments"')));
test/infra-page.test.ts +35 −3
@@ -12,7 +12,8 @@ import { createApp, type App } from "../src/app.ts";
1212 import { addAccount, allowWrite, net as cloudNet } from "../src/actions/cloud.ts";
1313 import { buildOf, composeChoices, infraOf, nameFor, planCompose, type Compose } from "../src/actions/infra.ts";
1414 import { placesShown } from "../src/web/pages/infra.ts";
15 import { dayWords, deployPinned, net } from "../src/actions/pinned.ts";
15 import { dayWords, deployPinned, net, pinnedForges } from "../src/actions/pinned.ts";
16 import { issuedPage } from "../src/web/pinned.ts";
1617 import { WATCH } from "../src/actions/pinned_watch.ts";
1718 import { commitToBranch } from "../src/actions/repos.ts";
1819 import { beginExperiment } from "../src/cloud/experiments.ts";
@@ -362,7 +363,7 @@ describe("infrastructure", () => {
362363 expect(listed.value.ended.find((m) => m.name === "plain")!.billing).toBe(gone.billing);
363364 });
364365
365 test("a machine with nothing at its provider offers no End, here or on /pinned", async () => {
366 test("a machine with nothing at its provider offers no End, here or on /infra", async () => {
366367 const d = await deployPinned(app, admin, { name: "canary", host: "", target: "digitalocean", account: "main", app: "ada/shop", source: "https://forge.example.net/ada/shop.git", version: "a".repeat(40), place: "digitalocean:nyc3:s-1vcpu-2gb" });
367368 if (!d.ok) throw new Error(d.error);
368369 setRemote(app.db, "canary", { remote: "", volume: "", address: "", state: "failed" });
@@ -370,11 +371,42 @@ describe("infrastructure", () => {
370371 expect(running).toContain('id="machine-canary"');
371372 expect(running).not.toContain('value="/infra/canary/end"');
372373 expect(running).toContain(`href="/infra/shop-test/ending"`);
373 const pinned = await (await get("/pinned")).text();
374 const pinned = await (await get("/infra")).text();
374375 expect(pinned).not.toContain('value="/pinned/canary/retire"');
375376 expect(pinned).not.toContain('value="/pinned/canary/retire-data"');
376377 });
377378
379 test("/pinned folds into /infra: a 301, each forge's row there, its disk deleted from it, and no page links back (#17372)", async () => {
380 const moved = await get("/pinned");
381 expect(moved.status).toBe(301);
382 expect(moved.headers.get("location")).toBe("/infra");
383 setRemote(app.db, "plain", { remote: "", address: "", state: "retired", volume: "vol-plain" });
384 const page = await (await get("/infra")).text();
385 // Its row is here, with the ended list's link to it and the typed-name confirm for its disk.
386 expect(page).toContain('id="forge-plain"');
387 expect(page).toContain('href="#forge-plain"');
388 expect(page).toContain('name="to" value="/pinned/plain/retire-data"');
389 expect(page).toContain('action="/pinned/domain"');
390 expect(page).toContain('action="/pinned/paid"');
391 const confirm = await (await get("/-/confirm?to=/pinned/plain/retire-data")).text();
392 expect(confirm).toContain("Type plain to continue");
393 // The POST deletes the disk and lands back on /infra.
394 const gone = await post("/pinned/plain/retire-data", {});
395 expect(gone.status).toBe(303);
396 expect(gone.headers.get("location")).toBe("/infra");
397 expect(getPinned(app.db, "plain")!.volume).toBe("");
398 // No page the forge serves to its admin links to /pinned: the claim page and the confirm page too.
399 const bodies = new Map<string, string>();
400 for (const path of ["/infra", "/infra/live?part=running", "/settings/cloud", "/deploy-to", "/", "/-/confirm?to=/pinned/plain/check"]) {
401 bodies.set(path, await (await get(path)).text());
402 }
403 const forges = pinnedForges(app, admin);
404 if (!forges.ok) throw new Error(forges.error);
405 const claim = { link: "https://plain.example.com/first-admin#code", expiresAt: "2026-12-09T00:00:00Z" };
406 bodies.set("claim issued", issuedPage("Claim link", { ...forges.value[0]!, claim }).toString());
407 for (const [path, body] of bodies) expect(body, path).not.toMatch(/href="\/pinned(["#?])/);
408 });
409
378410 test("places: the cheapest few in each city, and a filter narrows the catalog on the server", async () => {
379411 const c = composeChoices(app);
380412 const first = placesShown(c, "", "");
test/pinned-claim.test.ts +3 −3
@@ -56,7 +56,7 @@ import { serve, type Servers } from "../src/http/server.ts";
5656 import { sha256 } from "../src/kernel/hash.ts";
5757 import type { Ctx, Screen } from "../src/tui/app/app.ts";
5858 import { pinnedScreen } from "../src/tui/screens/pinned.ts";
59 import { pinnedListPage } from "../src/web/pages/pinned.ts";
59 import { pinnedRegion } from "../src/web/pages/pinned.ts";
6060 import { deployPage } from "../src/web/pinned.ts";
6161 import { Session } from "../src/tui/session.ts";
6262 import { recordCloud, sequence } from "./helpers/recorded-cloud.ts";
@@ -331,7 +331,7 @@ describe("a deployed forge is claimed with the link its deployer was shown, and
331331 const tok = createToken(seller.db, admin().id, "admin", "admin").token;
332332 const get = async (path: string) =>
333333 (await fetch(sellerServers.url + path, { headers: { authorization: `Bearer ${tok}` } })).text();
334 const list = await get("/pinned");
334 const list = await get("/infra");
335335 expect(list.split("snapshot its disk").length - 1).toBe(1);
336336 expect(list).not.toContain("no access");
337337 expect(list).toContain('value="/pinned/acme/check"');
@@ -699,7 +699,7 @@ describe("claimed is what the deployed forge says, never what the seller says (#
699699 // The pages, drawn from the rows every door reads (#16220's assertions, kept).
700700 const page = (): string => {
701701 const rows = pinnedForges(app, alice);
702 return rows.ok ? String(pinnedListPage(rows.value, { names: new Map(), checks: new Map(), domain: "" })) : "";
702 return rows.ok ? String(pinnedRegion(rows.value, { names: new Map(), checks: new Map(), domain: "" })) : "";
703703 };
704704 const offered = (name: string): string[] =>
705705 ["update", "rollback", "claim", "check"].filter((act) => page().includes(`value="/pinned/${name}/${act}"`));
test/pinned-domain-doors.test.ts +1 −1
@@ -172,7 +172,7 @@ describe("the domain for deployed forges", () => {
172172 expect((await post("forges.test")).status).toBe(303);
173173 expect(getBaseDomain(app.db)).toBe("forges.test");
174174 const page = await (
175 await fetch(`${servers.url}/pinned`, { headers: headers(adminTok) })
175 await fetch(`${servers.url}/infra`, { headers: headers(adminTok) })
176176 ).text();
177177 expect(page).toContain('name="domain"');
178178 expect(page).toContain('value="forges.test"');
test/pinned-lifetimes.test.ts +3 −3
@@ -22,7 +22,7 @@ import { ok } from "../src/kernel/result.ts";
2222 import { createForgeApp } from "../src/tui/forge.ts";
2323 import { pinnedScreen } from "../src/tui/screens/pinned.ts";
2424 import { headlessTerminal } from "../src/tui/term/terminal.ts";
25 import { pinnedListPage } from "../src/web/pages/pinned.ts";
25 import { pinnedRegion } from "../src/web/pages/pinned.ts";
2626 import { quietLogs } from "./helpers/globals.ts";
2727 import { seedPlaces } from "./helpers/places-fixture.ts";
2828 import { settleApp } from "./helpers/tui.ts";
@@ -176,7 +176,7 @@ describe("pinned forge lifetimes", () => {
176176
177177 const page = await post("/pinned/route1/keep", adminTok);
178178 expect(page.status, "the page's form").toBe(303);
179 expect(page.headers.get("location") ?? "").toStartWith("/pinned");
179 expect(page.headers.get("location") ?? "").toStartWith("/infra");
180180 expect(end()).toBe(t0 + LIFETIME_DAYS * DAY);
181181 expect([403, 404], "a non-admin at the page").toContain((await post("/pinned/route1/keep", bobTok)).status);
182182 expect(end(), "a refused keep changes nothing").toBe(t0 + LIFETIME_DAYS * DAY);
@@ -227,7 +227,7 @@ describe("pinned forge lifetimes", () => {
227227 test("the doors: the page's Ends fact with Keep and End now, the MCP keep, the terminal's e", async () => {
228228 const forges = pinnedForges(app, admin);
229229 if (!forges.ok) throw new Error("not admin");
230 const page = String(pinnedListPage(forges.value, { names: new Map(), checks: new Map(), domain: "" }));
230 const page = String(pinnedRegion(forges.value, { names: new Map(), checks: new Map(), domain: "" }));
231231 const ends = getPinned(app.db, "exp1")!;
232232 expect(page).toContain(`<dt>Ends</dt><dd>${endsWords(lifetimeOf(app.db, ends.id)!.endsAt)}</dd>`);
233233 expect(page).toContain('action="/pinned/exp1/keep"');
test/pinned-page.test.ts +3 −3
@@ -132,7 +132,7 @@ describe("pinned list page", () => {
132132 }
133133 const adminTok = createToken(app.db, getUserByName(app.db, "alice")!.id, "admin", "admin").token;
134134 const bobTok = createToken(app.db, getUserByName(app.db, "bob")!.id, "admin", "admin").token;
135 const get = (tok?: string) => fetch(servers.url + "/pinned", { redirect: "manual", headers: tok ? { authorization: `Bearer ${tok}` } : {} });
135 const get = (tok?: string) => fetch(servers.url + "/infra", { redirect: "manual", headers: tok ? { authorization: `Bearer ${tok}` } : {} });
136136 expect((await get()).status).toBe(303);
137137 expect((await get(bobTok)).status).toBe(403);
138138 const empty = await (await get(adminTok)).text();
@@ -218,7 +218,7 @@ describe("pinned list page actions", () => {
218218 const dep = await act("/deploy-to", adminTok, { name: "acme", host: "acme.forge.test", account: "main", app: "alice/shop", source: SOURCE, version: V });
219219 expect(dep.status).toBe(200);
220220
221 const list = await (await get("/pinned", adminTok)).text();
221 const list = await (await get("/infra", adminTok)).text();
222222 for (const w of ["/pinned/acme/update", "/pinned/acme/rollback", "/pinned/acme/check"]) expect(list).toContain(w);
223223
224224 // The confirm page words each and carries the version to the POST.
@@ -264,7 +264,7 @@ describe("pinned list page actions", () => {
264264 const chk = await act("/pinned/acme/check", adminTok);
265265 expect(chk.status).toBe(303);
266266 expect(calls.length).toBeGreaterThan(before);
267 const checked = await (await get("/pinned", adminTok)).text();
267 const checked = await (await get("/infra", adminTok)).text();
268268 expect(checked).not.toContain("never checked");
269269 expect((await act("/pinned/nope/check", adminTok)).status).toBe(303);
270270 } finally {
test/pinned-retire-doors.test.ts +2 −2
@@ -197,7 +197,7 @@ describe("retire at its doors", () => {
197197 });
198198 expect(deletes).toEqual(["/v2/droplets/7", "/v2/volumes/vol-1"]);
199199 const page = await (
200 await fetch(`${servers.url}/pinned`, { headers: headers(adminTok) })
200 await fetch(`${servers.url}/infra`, { headers: headers(adminTok) })
201201 ).text();
202202 expect(page).toContain("retired");
203203 expect(page).toContain("deleted");
@@ -207,7 +207,7 @@ describe("retire at its doors", () => {
207207 await make("theirs");
208208 expect(markClaimed(app.db, "theirs")).toBe(true);
209209 const page = await (
210 await fetch(`${servers.url}/pinned`, { headers: headers(adminTok) })
210 await fetch(`${servers.url}/infra`, { headers: headers(adminTok) })
211211 ).text();
212212 expect(page).toContain('name="despite_claim"');
213213 expect(page).toContain("Retire this buyer");
test/pinned-watch.test.ts +2 −2
@@ -19,7 +19,7 @@ import { createUser, getUserByName } from "../src/core/users.ts";
1919 import { quietLogs } from "./helpers/globals.ts";
2020 import { seedPlaces } from "./helpers/places-fixture.ts";
2121 import { pinnedScreen } from "../src/tui/screens/pinned.ts";
22 import { pinnedListPage } from "../src/web/pages/pinned.ts";
22 import { pinnedRegion } from "../src/web/pages/pinned.ts";
2323 import { quietCtx, screenText, sessionFor } from "./helpers/tui-text.ts";
2424
2525 quietLogs();
@@ -155,7 +155,7 @@ describe("the forge writes the record without a Check", () => {
155155 if (!r.ok) throw new Error(r.error);
156156 return r.value;
157157 };
158 const page = () => String(pinnedListPage(view(), { names: new Map(), checks: new Map(), domain: "forges.test" }));
158 const page = () => String(pinnedRegion(view(), { names: new Map(), checks: new Map(), domain: "forges.test" }));
159159 const stuck = view().find((v) => v.name === "gamma")!.stuck;
160160 expect(stuck).toContain("does not answer over HTTPS");
161161 expect(stuck.split(". ").length).toBe(1);

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

Keyboard shortcuts

Docs