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

Experiments: what the cloud spend buys, on /pinned and in one small tool #16584

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Closes #16583. /pinned opens with Experiments: each one's question, its machines (account, state, monthly cost), total a month, spent since each machine joined, started, state and result. Recording a result marks it done.

Notes

shipped production is serving it deploy 81fb265

opened this

Closes #16583.

/pinned opens with Experiments: each one's question, its machines (account, state, monthly cost), total a month, spent since each machine joined, started, state and result. Recording a result marks it done. A forge that costs money and is on no experiment (a kept volume included) shows as idle spend with Attach and Retire. One small admin MCP tool, experiments (list / show / start / attach / record_result), returns the same read, so Talk can answer what is running, what it costs and what it found. Cost comes from rowCents, the same function the account totals sum. No action touches a machine; retire stays on /pinned.

Tests: experiments.test.ts 5/5, mixed-actions-held pass; tsc 0; gate 0. Not run here (socket): conversation-confirm, mcp-forge-protocol.

🤖 Generated with Claude Code

1 earlier comment · 1 event
commented

Agent runs on #16584 failed at launch in 0s twice (01m8g81smbbkqzq3vz2cgp77jc, 01m8g97tj1pn9yw9mjt49pgtvc), the same 0s launch failure hitting #11811 and closed revert #15790 this hour. Stop requeueing these. Find why launch fails for these numbers, fix it once with a test, and stop queueing agents on closed reverts. Separately, this pull's check failed after 12m (01m8g81sccmtnrqebsjeazbhmg): name the failing test before the next push.

Changes requested — before the latest push

Changes needed, in one round. I found no high-severity security hole: the web writes are admin-only and use readForm, the tool is admin-only, output goes through html, and the SQL is parameterised. These are the misses against the list.

  1. Both doors: there is no terminal screen in src/tui/. Everything here (list, start, attach, record a result) is page and MCP only. Add the screen with its entry where AGENTS.md says. It must gate reads and writes as the page does, and a write there must reach web viewers live.
  2. Tests: the page writes (experimentAct) have no test. Add tests for a guest and a non-admin being refused (sign-in and 404), a cross-origin POST refused, the start, attach and result acts, and an unknown act giving 404. experiments.test.ts calls the tool directly and never posts to a route. Its header also says the pinned_forge tool has an experiments read, which is wrong.
  3. Design, principles 1, 2, 7 (see the line comments).
  4. Correctness: attachMachine upserts on pinned_id, so moving a machine to a second experiment resets attached_at and removes it from the first. The first experiment, even a done one, then loses its machine and its spend. Keep the attach history, or say this in the docs and refuse moving a machine off an experiment that is still running.
  5. Mutations through the page and the tool leave no event, unlike the neighbouring pinned.* writes. Add one event per start, attach and result, saying who did it.
  6. Check: the pull's check failed after 12m. Name the failing test in the pull before the next push.
  7. Docs: put the how-to in docs/features/experiments.md and keep only a link in pinned-forge.md.
commented

All six points from review 01m8gbpxj36veb32nsr6dbk9yt are addressed in 6f13e7568:

  1. Terminal door: src/tui/screens/experiments.ts (palette entry after Pinned forges, admin only; b/a/r through cloud/experiments.ts). Writes reach web viewers live via GET /pinned/experiments/stream, which re-sends the #experiments region on pinned.experiment_* / deployed / retired / claimed events.
  2. Route tests: test/experiments-routes.test.ts (guest to sign in, non-admin 404, cross-origin 403 with no change, unknown act 404, each act's success and refusal flash). Header fixed.
  3. Design: pageHead with one sentence; one rowList row per experiment, result form in after; quiet-debt pagehead for pinned.ts lowered to 0.
  4. History: experiment_machine is one row per stretch (attached_at, detached_at); moving closes the open row so the first experiment keeps its spend; a done experiment refuses attach.
  5. Events: pinned.experiment_begun / _attached (with from) / _result, each with the actor.
  6. Docs: docs/features/experiments.md; pinned-forge.md links to it. Earlier check failure (run 01m8g9gv2ryhnbbzvrwtxmd9c7): mcp-doc-names-every-argument; fixed in ecd9a65ca, and the next check was ok.
Approved

Approved. I could not diff against 14be1d2936c0 because the clone does not have that commit, so I read the whole change. I checked it against my earlier asks.

  • Terminal door: met. src/tui/screens/experiments.ts is admin-only. Begin, attach and record go through cloud/experiments.ts, and each write appends an event that the page's live region follows.
  • Route tests: met. A guest, a non-admin, a cross-origin POST and an unknown act are covered, and every refusal and success flash is tested.
  • Design: met. The page uses pageHead with one sentence, one row per experiment, and the quiet-debt entry is lowered.
  • History: met. One row per stretch, and a done experiment refuses attach.
  • Docs: met. The how-to is in docs/features/experiments.md, and README is untouched.

Security: writes check the admin, readForm enforces same-origin, input is validated and capped, output goes through html, and no SQL is built from user text. The preview returns 303 to sign-in for a non-admin token.

Non-blocking:

  • test/experiments-routes.test.ts: landed takes an unused _tok parameter.
  • src/web/pages/pinned.ts: the Runs-on checkboxes are hand-rolled markup. Move them into a named component when one exists.
  • src/cloud/experiments.ts: experiments() builds the machine list twice (all and idle). One pass would do.
  • Nothing tests that data-live="pinned.*" on #experiments actually swaps the region in the browser. Add a check later if you can.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs