Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
22a721a
Studio: Run cost's calibration trial — $0.41 per 5-hour percent on Ma…
danielrispler Dec 2, 2026
a0943cf
Merge #1058: Run cost's calibration trial
danielrispler Dec 2, 2026
6296379
Studio: the run cost engine, estimates, actuals and the 7-day total i…
danielrispler Dec 2, 2026
ac2c0ad
Merge #1059: the cost engine
danielrispler Dec 2, 2026
059af98
Studio: the run record and the views carry each run's cost (#1060)
danielrispler Dec 2, 2026
99bdbb2
Merge #1060: the run record and the views carry each run's cost
danielrispler Dec 2, 2026
04dd2c6
Studio: every run button shows its cost estimate, and every run its a…
danielrispler Dec 2, 2026
19961c6
Merge #1063: every run button shows its cost estimate, and every run …
danielrispler Dec 2, 2026
a006f59
Studio: plotkeeper detects your Claude plan (#1061)
danielrispler Dec 2, 2026
2bd31de
Merge remote-tracking branch 'origin/issue-1056-run-cost' into issue-…
danielrispler Dec 2, 2026
beba4a0
Studio: the snap base answers set_plan and detect_plan (#1061)
danielrispler Dec 2, 2026
90c21d8
Merge #1061: plotkeeper detects your Claude plan
danielrispler Dec 2, 2026
c269ed9
Merge origin/main into issue-1056-run-cost
danielrispler Dec 2, 2026
90cbba5
Studio: Settings shows the detected plan to confirm or change (#1064)
danielrispler Dec 2, 2026
8368632
Merge remote-tracking branch 'origin/issue-1056-run-cost' into issue-…
danielrispler Dec 2, 2026
7aa4ddf
Studio: type the plan row test's cases (#1064)
danielrispler Dec 2, 2026
7b427fb
Merge #1064: Settings shows the detected plan to confirm or change
danielrispler Dec 2, 2026
4656158
Studio: Run cost's docs and glossary (#1065)
danielrispler Dec 2, 2026
f0f953d
Merge #1065: Run cost's docs and glossary
danielrispler Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/studio/CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ _Avoid_: Session, job, a check sent to the background (a check an agent backgrou
The read-only **Background run** that checks the map text a PR added or changed (parts' names, purposes and captions, held items, link reasons and law texts) against the PR's code, and keeps a verdict per item. Its flags show on Ratify's rows and never block. Distinct from the **Claim check**, which checks a **PR brief** against its facts.
_Avoid_: Map lint, map check (the check of ownership, imports and laws), fact check

**Run cost**:
What a **Background run** takes: its API price, and for a subscriber the share of the plan's 5-hour and weekly limits it is estimated to use. It shows twice: as an estimate before the click, a range ("about 1-3% of the 5-hour window") from the last 20 recorded runs of the kind, or from the calibration trial's figures while fewer than 3 are recorded; and as the actual cost after it, where the run's result shows and on its row in the Background runs list, with the last 7 days' total, all projects, on the list's head. An Ultra subscriber sees weekly shares only, an API-key user dollars, and a plan not known dollars labelled "API price". A share rests on a factor the trial measured on one plan, so it always says "about" and its hover names the date; the factor is no plan size, which Anthropic does not publish. It brings back one reading of the retired **Plan usage** (the subscription's two windows), for runs only: plotkeeper reads the plan's numbers to turn a run's price into a share, and shows no plan limit of its own. [Background runs](behaviour/background-runs.md#cost) has the rules.
_Avoid_: Estimate (a session's remaining-time range, only a run's cost before its click is an estimate of a cost), usage, quota

**Micro-world**:
A small interactive page, built by a **Background run** from the project's real code, that lets Daniel play with one mechanism: a flow of a part's **Refresher**, or the parts a step of a **PR brief** lights. plotkeeper checks the page before keeping it and shows it walled off from everything else it serves.
_Avoid_: Demo, simulation, explainer (an explainer is the dsh-visual page of a diff)
Expand Down Expand Up @@ -440,6 +444,10 @@ _Avoid_: Edge (a computed edge)
**Link kind**:
What joins a link's ends: `import`, a code dependency the extractors can prove, or one of the run-time kinds no extractor sees, `http`, `spawn` and `file`.

**Run-time link**:
A **link** of a kind no extractor sees: `http`, `spawn` or `file`. Each carries a reason, which `import` links do not. Drafting new ones is a later spec's (danielrispler/plotkeeper#935).
_Avoid_: Link reason (the text a run-time link carries), dynamic link

**Read part**:
A part at least one of whose files a named extractor reads. The link check compares links with computed edges only between read parts.

Expand Down
18 changes: 17 additions & 1 deletion docs/studio/behaviour/background-runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,23 @@ A **batch** is several runs asked for as one request (`Runner::submit_batch`), s

A run ends as one of: finished; finished with tool calls denied; failed; stopped at its limit; died; setup failed; not logged in; rate limited. A run that exits 0 with denials in its result is reported with them, never as a clean success. A result that says it is an error, by `is_error` or by a `subtype` such as `error_max_turns`, is a failure whatever the exit code, and so is a run whose result or error output shows the sandbox failing (`sandbox_apply: Operation not permitted` or `Sandbox is required but`). A result that only names the settings does not match. Only a failed run's words are read for a login or a limit, with the writer's own word list, so a good result that mentions a rate limit pauses nothing; a failed run that only mentions one does pause, which costs one Resume.

Each run appends one line to `background-runs.jsonl` in the data folder: the time, its id, kind, project, outcome, denials, cost and duration. A cancelled run is recorded as `cancelled`.
Each run appends one line to `background-runs.jsonl` in the data folder: the time, its id, kind, project, outcome, denials, cost and duration, and three optional fields (spec #1056, #1060), left out when a run has none, so a line from before them still reads:

- `units`: the parts a First map writer or reviewer group covered; no other kind has it. A First map line with no `units` gives no per-part figure.
- `model`: the model that cost the most in the result's `modelUsage`.
- `subject`: the key of the view that keeps the run's answer, so the view finds its runs' cost after the run is dismissed: a First map draft's id (its redrafts and retries use it too), a review's `<pr>@<head>`, a law's id, a micro-world's `<key>@<commit>`.

A cancelled run is recorded as `cancelled`.

## Cost

Every run has a **run cost** (spec #1056): an estimate before the click and an actual figure after. The server works the figures out from `background-runs.jsonl` and `settings.json`'s `plan` (`server/src/run_cost.rs`) and sends them with the views; the page only puts words round them (`ui/run-cost.ts`), in the time hint's style where the button has one. A figure is in the plan's unit: for Pro and Max, shares of the 5-hour window and of the week ("about 1-3% of the 5-hour window, under 1% of the week"); for Ultra, the week alone; for an API key, dollars; for a plan not known (nothing detected and none picked, or Don't know), dollars labelled "API price". A share under 1% says "under 1%", never "0%". A share carries "about", and its hover says it is the run's API price turned into the plan's share by a factor measured on a date; dollars say the price is as `claude` recorded it. How the plan is known is in [Settings](../settings.md).

**The estimate.** Beside every button that starts a run: Draft the map, its failed group's Retry, Back a law and Back this law, Guard with a law's Start the run, Explore this, a micro-world's Rebuild and Try again, and Review map text and Run again. It is a range, the 25th to the 75th percentile of the cost per unit of the last 20 recorded runs of the kind that have a cost, all projects, times the units. For First map the unit is a part and the units are the skeleton's (a group's, for its Retry), so a larger repository shows more, and the estimate includes the reviewers and the redrafts the draft starts on its own; for every other kind the unit is a run. With fewer than 3 such records, the estimate comes from the calibration trial's figures (`run_cost.rs`, from [`research/run-cost.md`](../research/run-cost.md)), so the first click is never blind.

**The actual cost.** A run's recorded cost, in the plan's unit, with the same factor; a run that recorded none (cancelled before it answered, died) shows none, never zero. Map text review and First map runs are dismissed as soon as their answers are kept, so their cost shows on the view that keeps the answer, found by `subject`: the Map draft panel's line once the draft is ready (the sum over the draft's runs), the review's line in Ratify, Back a law's patch review and a micro-world's row. Every ended run still listed shows its cost on its row.

**The total.** The Background runs list's head shows "Last 7 days, all projects:" and the sum of every recorded cost of the last 7 days, all kinds and projects, dismissed runs included, since they spent. It shows even when no run is listed, as long as the total is not zero.

## Fallback

Expand Down
4 changes: 4 additions & 0 deletions docs/studio/behaviour/storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ The app also keeps `roots.json` beside the log: the git worktree root of each fo

The desktop app ran the sessions it started with `workbench/statusline.sh` as their status line, which saved Claude Code's status line stdin, with the plan's usage and the context window's size, as `usage/<session_id>.json` beside the event log, mode 0600 in a folder of mode 0700. Sessions are started by hand now, so none saves one, and plotkeeper reads none (#416); the scripts and their reader are in `archive/workbench/`. Old snapshots stay in `usage/` until you remove the folder.

## The status line saves the plan's numbers

`plotkeeper statusline` (spec #1056, ticket #1061) saves four numbers from Claude Code's status-line JSON, in `plan-limits.json` in the data folder: the 5-hour and the weekly window's `used_percentage` and `resets_at`, from `rate_limits`. A window the JSON lacks is left out. It writes beside the file and renames over it, replacing the file on each call that has a window, and a call with neither (an API key's, or a subscriber's session before its first answer) leaves the file as it was. Nothing else of the JSON is saved: no session id, no cost, no context size, which the retired snapshots above held (this reverses part of #416 for those four numbers only). A failed write is let go and the status line still prints its link; a data folder plotkeeper never made is left unmade. [Plan detection](../settings.md) reads the file, which is useful for 60 seconds after it is written.

## The card store

`cards-v2.json` beside the event log holds the cards written before cards were retired (danielrispler/plotkeeper#348). No build writes one now, and the file still loads, with each card's change (`request.change`), its base, its prompt, its worker, its `summary` and `architecture`, and its record: your guess, flags, rating, taps, the check's result and the longer explanation you asked for. A store from before quizzes (danielrispler/Falinks#375) loads with no quiz, one from before briefs (danielrispler/Falinks#377) with no summary and no prompt, and a card stored without `request.change` with none. Nothing shows these cards; the studio reads them for the session's row line and for "Design so far", which may cite one. A missing store starts empty.
Expand Down
Loading