This is the full developer documentation for Rehearse # Overview > Rehearse a change before it ships. Bring the product up, sign in as named people, start from named worlds, and compare any scenario on the base and on the head. Rehearse sits beside any repository, so agents and people can try a change before it ships. It runs each scenario on the base and on the head, and tells you what changed without anyone saying so. Terminal ```text $ rehearse compare --base main 23 as on the base · 1 new · 5 changed and said so (5 announced) · 4 changed without saying so · 1 fails on the head ``` That line is [Kurvball](https://www.kurvball.ca)’s member directory, its sign-in screens and its handoff renderer, run on `main` and on a change, then compared. Four answers changed that nobody announced: the change slipped. One call fails on the head. The rest is as on the base, or changed and said so. ## What it does [Section titled “What it does”](#what-it-does) | Step | What Rehearse does | | ------------------ | ------------------------------------------------------------------------------------ | | Bring it up | Starts your services, waits until they are ready, and keeps two copies apart | | Sign in | Signs in as a named person, with credentials your local services already trust | | Start from a world | Builds a named starting state, and names every stand-in it runs with | | Run a scenario | Runs it once on a checkout and prints what it observed, as JSON | | Compare | Runs it on the base and on the head, sets aside ids and times, and gives one verdict | | Try it | Shows any scenario on one page, the stage, where you say whether it works | ## Scenarios, in formats you already write [Section titled “Scenarios, in formats you already write”](#scenarios-in-formats-you-already-write) | Kind | Format | What is compared | | ----- | --------------------------------------------- | ---------------------------------------------- | | piece | Storybook’s CSF, beside the component | the accessibility tree, errors, axe violations | | flow | steps by accessible name | the accessibility tree after each step | | call | Hurl’s plain part, beside the handler | status and body, with ids and times set aside | | file | `*.rehearse.yaml`: an input, a run, an output | the output’s fields, by column | ## The verdicts [Section titled “The verdicts”](#the-verdicts) Every scenario a comparison runs gets one verdict. | Verdict | What it means | | ------------------------- | -------------------------------------------------------------------------- | | as on the base | It answers as it did before. | | changed and said so | It changed, and the change announced it, or edited the scenario. | | changed without saying so | It changed, and nothing said it would. Look here first. | | new | The base doesn’t have it. | | fails on the head | Its own checks fail on the head. If they fail on the base too, it says so. | ## For people and for agents [Section titled “For people and for agents”](#for-people-and-for-agents) A person tries a scenario on the stage, in a browser. An agent runs the same commands with `--json` and reads one object back, described by a schema in `schema/v1/`. Other tools read Rehearse the same way, only through its JSON commands. Rehearse never needs [Ashlar](/guides/ashlar/): when Ashlar is there, Rehearse borrows its import graph. ## Where to go next [Section titled “Where to go next”](#where-to-go-next) Install Rehearse in your repository, build your first comparison, or learn how it works. [Get started](/get-started/)Install Rehearse in a repository with one command. [Tutorial](/tutorial/1-compare/)From an empty folder to a comparison of a change, in ten minutes. [Concepts](/concepts/blocks/)Services, people, worlds, stand-ins, scenarios, and how comparing works. ## The name [Section titled “The name”](#the-name) The package is `@kurvball/rehearse`, and its command is `rehearse`. The bare name `rehearse` is taken on npm (version 1.6.1, “React.js Live Development in Zen Mode”) and on PyPI (version 0.1.7, “Testing framework for AI Voice Agents”), as checked on 3 December 2026, so the package takes Kurvball’s scope. It isn’t on npm yet: each release is a tarball on its GitHub Release. Rehearse is MIT-licensed, [Copyright (c) 2026 Kurvball](https://github.com/kurvball/rehearse/blob/main/LICENSE). # Get started > Install Rehearse in a repository with one command, then build your first comparison, solve a task, or look something up. Rehearse tries a change before it ships: it compares any scenario on the base and on the head. ## Install Rehearse [Section titled “Install Rehearse”](#install-rehearse) Rehearse isn’t on npm yet. Each release attaches its package to its GitHub Release, so add Rehearse 1.2.0 to your repository from there, with Node 22.18 or later. * pnpm Terminal ```sh pnpm add -D https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` * npm Terminal ```sh npm install -D https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` * Yarn Terminal ```sh yarn add -D https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` To build it yourself instead, clone [kurvball/rehearse](https://github.com/kurvball/rehearse) and run `pnpm install` and `pnpm build`: the command is `node dist/cli.js`. [Versions and releases](/reference/versioning/) says how to pin a release. ## Where to go next [Section titled “Where to go next”](#where-to-go-next) [Tutorial](/tutorial/1-compare/)Build a service, compare a change with its base, and see a slip, in ten minutes. [Guides](/guides/pieces/)Write each kind of scenario, announce a change, gate a pull request. [Reference](/reference/cli/)Every command and flag, rehearse.yaml, the scenario files, the JSON contract. # Unit 1: Compare a change > From an empty folder to a comparison of a change with its base, in ten minutes. Rehearse catches a change nobody announced, then reads the announcement. In this unit you write a tiny service and one call to it, then change the service on a branch and compare the branch with `main`. By the end, Rehearse tells you the change altered an answer without saying so, then that it said so. The comparison you reach at the end of the unit reads as follows. Terminal ```text $ rehearse compare --said "greeting.hurl#The greeting says hello" 0 as on the base · 1 changed and said so (1 announced) changed and said so: The greeting says hello (greeting.hurl:2) — announced: Said on the command line. $.text: "Hello" → "Hello, friend" 1 id, time or opaque value was set aside before comparing. 1 base observation came from the cache (63e7527b08a5). ``` ## Before you begin [Section titled “Before you begin”](#before-you-begin) You need [Node](https://nodejs.org) 22.18 or later and [git](https://git-scm.com). Install Rehearse once for your user, so the `rehearse` command works in the empty folder this unit starts from. * pnpm Terminal ```sh pnpm add -g https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` * npm Terminal ```sh npm install -g https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` * Yarn Terminal ```sh yarn global add https://github.com/kurvball/rehearse/releases/download/v1.2.0/kurvball-rehearse-1.2.0.tgz ``` This unit uses calls only, so it needs no browser. Piece and flow scenarios need Chromium for Playwright. ## Write the service and its call [Section titled “Write the service and its call”](#write-the-service-and-its-call) 1. **Make a service.** In an empty folder, such as `~/hello`, write `server.mjs`: a server that answers a health check and a greeting. server.mjs ```js import { createServer } from 'node:http'; const port = Number(process.argv[2]); createServer((req, res) => { res.setHeader('content-type', 'application/json'); if (req.url === '/health') return res.end(JSON.stringify({ ok: true })); if (req.url === '/greeting') return res.end(JSON.stringify({ text: 'Hello', at: new Date().toISOString() })); res.statusCode = 404; res.end(JSON.stringify({ error: 'not_found' })); }).listen(port, '127.0.0.1'); ``` 2. **Say what the repository has.** Write `rehearse.yaml`. `{{port}}` is a free port Rehearse picks, and the service is ready when the health check answers. rehearse.yaml ```yaml base: main services: api: up: node server.mjs {{port}} port: auto ready: http://127.0.0.1:{{port}}/health scenarios: calls: ['**/*.hurl'] ``` In a real repository, `rehearse init` writes a starter with every block, commented. 3. **Write a call.** A call is Hurl’s plain part. The comment above it is its name, and `{{api}}` is the service’s address. greeting.hurl ```hurl # The greeting says hello GET {{api}}/greeting HTTP 200 [Asserts] jsonpath "$.text" startsWith "Hello" ``` 4. **Commit it on `main`.** The base of a comparison is a commit, and `.rehearse/` holds Rehearse’s own state, which stays out of git. Terminal ```sh printf '.rehearse\n' > .gitignore git init -b main && git add -A && git commit -m "Hello" ``` 5. **Run the call.** Rehearse brings the service up, sends the call, and takes the service down. Terminal ```text $ rehearse run "greeting.hurl#The greeting says hello" ✓ The greeting says hello (greeting.hurl#The greeting says hello) on ~/hello at 63e7527b08a5 GET /greeting as nobody → 200 ``` No one signed in, so the call went as nobody. [People](/concepts/blocks/#people) say who else it can go as. **Check:** `rehearse run` printed a ✓ and exited 0. If it printed ✗ instead, its last lines say which assert failed. ## Compare a change with its base [Section titled “Compare a change with its base”](#compare-a-change-with-its-base) 1. **Make a change.** On a branch, warm the greeting up. Terminal ```sh git checkout -b warmer sed -i "s/text: 'Hello'/text: 'Hello, friend'/" server.mjs git commit -am "A warmer greeting" ``` 2. **Compare it with `main`.** Rehearse runs the call on `main` and on the branch, and compares the two answers. Terminal ```text $ rehearse compare 0 as on the base · 1 changed without saying so changed without saying so: The greeting says hello (greeting.hurl:2) $.text: "Hello" → "Hello, friend" unannounced, by what changed: $.text — in 1 scenario 1 id, time or opaque value was set aside before comparing. 1 base observation came from the cache (63e7527b08a5). ``` The greeting’s time differs on every run, so Rehearse set it aside. The text changed, the assert still holds, and nothing said it would change: that is a slip. The command exits 1. 3. **Say so.** Announce the change on the command line, and compare again. Terminal ```text $ rehearse compare --said "greeting.hurl#The greeting says hello" 0 as on the base · 1 changed and said so (1 announced) changed and said so: The greeting says hello (greeting.hurl:2) — announced: Said on the command line. $.text: "Hello" → "Hello, friend" 1 id, time or opaque value was set aside before comparing. 1 base observation came from the cache (63e7527b08a5). ``` Now it exits 0. The base came from the cache: each base commit runs once. 4. **Try it on the stage.** The stage shows every scenario on one page. Terminal ```sh rehearse stage ``` Open the address it prints, `http://127.0.0.1:4400/`, choose the greeting, and switch between Base, Head and Diff. Edit the call and send it to either side, then say whether it works. Ctrl-C stops the stage and what it brought up. **Check:** the second comparison exited 0 and counted the greeting as changed and said so. Every command also takes `--json` and prints one object: `rehearse compare --json` is what an agent or a gate reads, and its schema is [`comparison`](/reference/json/#comparison). ## What you built [Section titled “What you built”](#what-you-built) You have a repository Rehearse can compare: one service, one call, and a branch whose change it caught, then read as announced. To go further, [write flows](/guides/flows/) and [piece scenarios](/guides/pieces/), or [announce a change](/guides/announce/) in a file a pull request carries. # Affected scenarios > How rehearse list --affected decides which scenarios a change reaches, and says why for each. In the shop fixture, a change to the API’s server reaches every scenario, and Rehearse says why for each one. Terminal ```text $ rehearse list --affected packages/api/server.mjs 8 of 8 scenarios are reached by 1 file. No import graph is here (no Ashlar, no affected.graph), so Rehearse took the touched packages and the packages that depend on them. v1 reads workspace links for JavaScript packages only: other languages’ packages count as folders. call packages/api/items.hurl#The shop says it is up it is in @shop/api, which the change touches … file packages/report/weekly.rehearse.yaml it is in @shop/report, which depends on @shop/api ``` A change touches some files. `rehearse list --affected` lists the scenarios those files reach, each with why, so you run what matters and skip the rest. Name the files, or let git find them. Terminal ```sh rehearse list --affected src/x.ts src/y.ts # the files you name rehearse list --since main # the files changed since main rehearse compare --base main --affected # compare only what the change between base and head reaches ``` `--since ` and `compare --affected` take every file that differs: committed, staged, unstaged and untracked. With `--json`, each scenario has `reachedBy`, and the result says how it decided (`by`: `graph` or `packages`) and anything it couldn’t do (`said`). ## The covering rule [Section titled “The covering rule”](#the-covering-rule) Nothing imports a `.hurl` file or a `.flow.yaml`. So whatever else Rehearse knows, it starts from where a scenario sits. A touched file reaches a scenario when: | Rule | reachedBy says | | ---------------------------------------------------------- | ----------------------------------------------- | | It is the scenario’s own file | `its own file changed` | | It is in the scenario’s package | `it is in @shop/api, which the change touches` | | It is in the package of the scenario’s service (its `cwd`) | `its service is in …, which the change touches` | | It matches the scenario’s `covers` globs | `it covers ` | A package is the nearest folder above a file that holds a `package.json`, `pyproject.toml`, `Cargo.toml` or `go.mod`. `covers` names what a scenario tries when its folder doesn’t say it. Put it on a path in the manifest, in a flow (a `*.flow.yaml`, or a flow module’s default export), or in a file scenario: rehearse.yaml ```yaml scenarios: calls: paths: [{ path: 'apps/web/stage/**/*.hurl', covers: ['packages/ui/src/**'] }] files: [{ path: 'packages/**/*.rehearse.yaml', covers: ['apps/web/features/**'] }] ``` A file scenario names its own `covers` beside its name. report.rehearse.yaml ```yaml name: The weekly report lists every item covers: ['packages/pricing/**'] run: node report.mjs {{output}}/weekly.csv output: { file: weekly.csv, layout: csv } ``` ## With an import graph [Section titled “With an import graph”](#with-an-import-graph) An import graph knows which files reach a file through imports. When one is here, Rehearse asks it for the dependents of each touched file, then applies the covering rule to the touched file and to each of its dependents. A call beside a handler that imports the touched file is reached, though nothing imports the call. The graph is, in order: 1. the command in `affected.graph`, when the manifest names one; 2. Ashlar’s, when the checkout has an `ashlar.config.*` (`ts`, `mts`, `js`, `mjs` or `json`) and Ashlar is installed: `node_modules/.bin/ashlar` in the checkout, else `ashlar` on `PATH`. Rehearse runs ` --json` in the checkout and reads what it prints against `schema/v1/dependents.schema.json`. See [Rehearse with Ashlar](/guides/ashlar/) for the contract. With a graph, the result names the command that gave it, and each touched file the graph doesn’t hold. Terminal ```text 8 of 8 scenarios are reached by 2 files (import graph: node ../graph.mjs). The graph doesn't hold README.md: for it, Rehearse took the package and the packages that depend on it. ``` A file the graph lists as `unknown`, or doesn’t list, falls back to packages, for that file only. ## Without one: packages [Section titled “Without one: packages”](#without-one-packages) Without a graph, or when the graph fails, Rehearse takes the touched packages and every package that depends on them, directly or not. It reads the links between packages from a pnpm workspace (`pnpm-workspace.yaml`) or npm and yarn workspaces (`workspaces` in the root `package.json`), from each package’s dependencies, dev, peer and optional dependencies. A change to the shop’s report script reaches only the report’s scenario. Terminal ```text $ rehearse list --affected packages/report/report.mjs 1 of 8 scenarios are reached by 1 file. No import graph is here (no Ashlar, no affected.graph), so Rehearse took the touched packages and the packages that depend on them. v1 reads workspace links for JavaScript packages only: other languages’ packages count as folders. file packages/report/weekly.rehearse.yaml it is in @shop/report, which the change touches ``` `@shop/report` depends on `@shop/api`, so a change in `@shop/api` reaches the report, and a change in the report reaches only the report. v1 reads links between JavaScript packages only. A Python, Rust or Go package still counts as a package (its own scenarios are reached), but packages that depend on it aren’t found. When the graph fails, the result says why and falls back to packages. Terminal ```text `node ../missing-graph.mjs` failed (exit 1: …), so Rehearse took the touched packages and the packages that depend on them. ``` ## Files outside every package [Section titled “Files outside every package”](#files-outside-every-package) A touched file in no package (a lockfile, `rehearse.yaml`, a root config, a script at the root) can change anything. It reaches every scenario. Terminal ```text $ rehearse list --affected seed.mjs 8 of 8 scenarios are reached by 1 file. … call packages/api/items.hurl#The shop says it is up seed.mjs is outside every package, so it reaches every scenario ``` A file in the root package, beside the root `package.json`, counts as outside every package. With an import graph that holds the file, the graph says what it reaches instead: in a repository that is one package, every file is outside every package, and the graph is what keeps a change from reaching everything. ## Scenarios beside the manifest [Section titled “Scenarios beside the manifest”](#scenarios-beside-the-manifest) A scenario read beside the manifest (a path starting with `./`) sits in no package of the product. Without `covers`, Rehearse can’t tell what it tries, so every change reaches it, with `it is read beside the manifest and says nothing of what it covers`. Give it `covers` to narrow it. Note When in doubt, Rehearse reaches a scenario rather than skips it. A scenario run for nothing costs a little time; a scenario skipped wrongly hides a change. # Services, people, worlds and stand-ins > The four blocks of rehearse.yaml that set the scene for a scenario. What comes up, who you sign in as, where you start, and what is faked. The shop fixture in Rehearse’s repository sets its scene with all four blocks. rehearse.yaml ```yaml base: main services: api: up: node packages/api/server.mjs --port {{port}} port: auto ready: http://127.0.0.1:{{port}}/health isolate: { env: SHOP_STATE } signIn: { command: node people.mjs, service: api } people: owner: { describe: Runs the shop, default: true } member: { describe: A customer with an account } worlds: empty: { describe: No items } stocked: describe: Three items in stock extends: empty add: node seed.mjs {{api_url}} default: true standins: payments: replaces: The payment provider by: packages/api/server.mjs (its fake provider) services: [api] env: { PAYMENTS: fake } real: { env: { PAYMENTS: sandbox } } ``` A repository says in `rehearse.yaml` what it has. Four blocks set the scene a scenario runs in: | Block | What it is | Why | | ---------- | ---------------------------------------------- | ----------------------------------------------------------- | | `services` | What comes up: a server, an app, a daemon | A scenario needs the product running | | `people` | Who you sign in as | The same request means different things to different people | | `worlds` | Named starting states that build on each other | A scenario starts from a known state, on both sides | | `standins` | Fakes for what can’t run locally | So the product can run, and every result says what was fake | Every block is optional. A repository of React components may declare no services at all. A command-line tool may declare only file scenarios. Declare what you have. Every field is listed in the [rehearse.yaml reference](/reference/manifest/). This page explains what each block does. ## Services [Section titled “Services”](#services) A service is something Rehearse brings up before a scenario runs and stops after it. rehearse.yaml ```yaml services: api: up: node packages/api/server.mjs --port {{port}} port: auto ready: http://127.0.0.1:{{port}}/health timeout: 20 isolate: { env: SHOP_STATE } ``` ### Up, ready, down [Section titled “Up, ready, down”](#up-ready-down) | Step | What Rehearse does | | ----- | ---------------------------------------------------------------------------------------------------------------------------------- | | up | Runs `up` in the checkout (or in `cwd`, relative to the checkout), in its own process group, with its output in `.rehearse/logs/`. | | ready | Waits until the service is ready, checking every quarter second, for `timeout` seconds (60 by default). | | down | Runs `down` if you gave one, then ends the process group, then removes the service’s scratch folder. | `ready` takes one of three forms: | Form | Ready when | | ----------------------------------------- | ------------------------------------------------ | | `ready: http://127.0.0.1:{{port}}/health` | the URL answers with a status under 500 | | `ready: pnpm drive snapshot --json` | the command exits 0 | | `ready: { log: 'listening on' }` | the service’s log matches the regular expression | A string that starts with `http://` or `https://` is a URL; any other string is a command. Without `ready`, a service with a port is ready when something answers on that port, and a service without a port is ready at once. If the service exits before it is ready, or isn’t ready in time, Rehearse stops it and says so with the last lines of its log: Terminal ```text api stopped before it was ready (exit 1): … Its log: …/.rehearse/logs/api@4f20e84ecf.log ``` ### Ports [Section titled “Ports”](#ports) `port: auto` picks a free port on 127.0.0.1. The service gets it as `{{port}}` and as the `PORT` variable. Its URL is `http://127.0.0.1:{{port}}` unless you give `url`. A fixed port that something already answers on is refused, so two copies never talk to each other by mistake. Other commands reach a service by name: `{{api_url}}` and `{{api_port}}`. `{{url}}` is the default service’s URL (the service named `api`, else the first with a URL, unless `defaults.service` says otherwise). ### Isolate [Section titled “Isolate”](#isolate) The base and the head can each have the service up. `isolate: { env: SHOP_STATE }` gives each copy its own scratch folder, through that environment variable, so they never share a database file or a socket. Every service also gets its scratch folder as `REHEARSE_SCRATCH` and as `{{scratch}}` in its `up`, `down` and `env`. A service with its [own driver](/guides/flows/#drive-through-a-services-own-driver) can use it to keep each copy’s driver state apart: rehearse.yaml ```yaml env: { DRIVE_DIR: '{{scratch}}/drive' } ``` ### Daemons [Section titled “Daemons”](#daemons) Some `up` commands start a daemon and exit 0. That is fine: Rehearse keeps the service as running, asks its `ready` again before it uses it later, and stops it with its `down` command. Give such a service a `down`. ### The registry [Section titled “The registry”](#the-registry) Rehearse keeps what it brought up in `.rehearse/services/`, one file per service and checkout. Later commands find it there. Four commands work with it. Terminal ```sh rehearse up # brings every service up, builds the default world, and leaves them running rehearse services # what can come up, and what is up now rehearse down # stops what Rehearse brought up in this checkout rehearse down --all # in every checkout ``` `rehearse up` says where each service answers and which world it built. Terminal ```text $ rehearse up api is up at http://127.0.0.1:43639 (pid 438228) World: stocked. Stop with `rehearse down`. ``` A scenario run while a service is already up uses it, if it was built with the same world. If it was built with another world, the scenario isn’t run, and Rehearse says which world is up and how to stop it. ### One set at a time [Section titled “One set at a time”](#one-set-at-a-time) A machine runs one set of services at a time by default. Before Rehearse brings services up in one checkout, it stops those it brought up in any other checkout: Terminal ```text The budget allows 1 set of services at once: stopping those in …/shop/.rehearse/checkouts/c68f00d9431f ``` Set `budget.services: 2` to allow two. A comparison runs the base, then the head, never both at once. ### Interrupted runs [Section titled “Interrupted runs”](#interrupted-runs) If you stop Rehearse with Ctrl-C (or it gets `SIGTERM`), it stops every service that command brought up before it ends. Services you asked to keep, with `rehearse up` or `rehearse run --keep`, stay up until `rehearse down`. ## People [Section titled “People”](#people) A person is someone you can sign in as. The manifest names each person, and the command that signs them in. rehearse.yaml ```yaml signIn: { command: node people.mjs, service: api } people: owner: { describe: Runs the shop, default: true } member: { describe: A customer with an account } ``` `signIn` is a command that prints everyone’s token as JSON, in the sign-in shape. The shop’s `people.mjs` prints this object, indented here. Terminal ```json { "people": { "owner": { "token": "local-owner-0001", "role": "owner" }, "member": { "token": "local-member-0002", "role": "member" } }, "variables": { "shop": "main-street" } } ``` A person’s value is a token, or an object with a `token` and other fields. Each other field becomes a variable named `_` (`owner_role`). `variables` adds more. `service: api` means the sign-in needs `api` up first. `rehearse people` says who each person is, and hides each token. Terminal ```text $ rehearse people owner (default) — local: Runs the shop · token (16 characters, hidden; --json prints it) member — local: A customer with an account · token (17 characters, hidden; --json prints it) variables: owner_role, member_role, shop ``` A person `signIn` doesn’t cover can have their own `token: { command: … }` or `token: { env: … }`. A person a browser signs in as needs `browser:` (a header, storage values, cookies, or sign-in steps): see [sign in](/guides/flows/#sign-in) in the flows guide. `real` says how real a person is: `local` (a sign-in the local services trust, the default), `stand-in` (a fake identity) or `real` (a real account). The names `you`, `nobody` and `api` are reserved: they are Rehearse’s own. `nobody` sends a call signed in as no one: a call with no `Authorization` header is sent as nobody. `api` is the service’s address, `{{api}}`. `you` is kept for whoever runs Rehearse. A person is never a way around sign-in A person is a sign-in your local services already trust: a seeded user, a local identity provider, a test signing key. Never add a code path to the product that skips authentication when Rehearse runs it. Then a comparison tries the sign-in your users get. Rehearse replaces every token with `{{name}}` in what it keeps and prints: observations, the cache, the stage’s records and every line it writes. `rehearse people` prints tokens only with `--json`. ## Worlds [Section titled “Worlds”](#worlds) A world is a named starting state. A world can extend another and add to it. rehearse.yaml ```yaml worlds: empty: { describe: No items } stocked: describe: Three items in stock extends: empty add: node seed.mjs {{api_url}} default: true ``` `rehearse worlds` lists each world with the chain it is built from. Terminal ```text $ rehearse worlds empty — No items stocked (default) — Three items in stock built from empty → stocked ``` To build a world, Rehearse runs each world in its chain in order, from the root. Each world has two commands. | Field | When it runs | | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `before` | Before any service comes up, such as writing files a service reads at start. No service is up yet, so `{{port}}`, `{{url}}` and `{{scratch}}` aren’t filled. | | `add` | Once services are up, such as seeding through the API | Rehearse builds a world when it brings services up fresh for it: for `rehearse up`, a run or a comparison, `rehearse drive start`, and the first call you send from the stage. A world whose chain has an `add` needs every service up. A world’s commands see `{{world}}`, `{{checkout}}`, `{{manifest}}`, and each running service’s `{{_url}}` and `{{_port}}`. They run in the checkout, with up to 5 minutes each. A scenario starts from its own world, else the default world (`default: true`, or `defaults.world`). `--world ` runs it from another. A world is one family A world extends at most one other, so every world has a single line back to its root. Rehearse refuses worlds that extend in a circle. To combine two states, write a world that extends one and adds the other. ### Worlds in TypeScript [Section titled “Worlds in TypeScript”](#worlds-in-typescript) `defineWorld` writes the same chain in code: worlds.ts ```ts import { defineWorld, worldMain } from '@kurvball/rehearse/worlds'; const empty = defineWorld({ name: 'empty', add: async () => {} }); const stocked = defineWorld({ name: 'stocked', extends: 'empty', add: async ({ url }) => { await fetch(`${url}/items`, { method: 'POST', body: JSON.stringify({ name: 'Pen' }) }); }, }); await worldMain([empty, stocked]); ``` The manifest’s `add` runs that file with the world’s name and the service’s address. rehearse.yaml ```yaml worlds: stocked: { add: 'node worlds.ts stocked --url {{api_url}}' } ``` `worldMain` reads the world’s name and `--url`, builds the chain root first, and prints `{"v": 1, "world": "stocked", "built": ["empty", "stocked"]}`. Without `--url`, `worldMain` reads `$REHEARSE_URL`. Rehearse sets it to the default service’s URL, once that service is up, whenever it builds a world: for a run, a comparison, `rehearse up`, `drive start` or the stage. `--url`, as above, names the URL outright. ## Stand-ins [Section titled “Stand-ins”](#stand-ins) A stand-in is a fake for something that can’t run locally: a payment provider, a model, an identity provider. rehearse.yaml ```yaml standins: payments: replaces: The payment provider by: packages/api/server.mjs (its fake provider) fidelity: fake services: [api] env: { PAYMENTS: fake } real: { env: { PAYMENTS: sandbox } } ``` A stand-in is an environment preset on the services it names (every service when `services` is left out). Rehearse sets its `env` on those services while it is used. | Field | Says | | ---------- | ----------------------------------------------------------------------------------------------------------------- | | `replaces` | What it stands in for | | `by` | What plays it: a file, a package, a command | | `fidelity` | `fake` (written by hand, the default), `recorded` (replays real answers) or `local` (the real thing, run locally) | | `real` | The environment that uses the real dependency instead | `--real payments` on `run`, `compare` or `up` uses `real.env` instead. A stand-in without `real` can’t be swapped for the real one locally, and Rehearse says so. A stand-in says so in every result Every observation lists the stand-ins on the services its scenario uses, and every comparison lists them at the end. A fake is never silent. The text of a comparison ends with the stand-ins it ran with. Terminal ```text Stand-ins: payments (fake, for The payment provider). ``` ## Next [Section titled “Next”](#next) * [Scenarios](/concepts/scenarios/): what runs in this scene. * [Comparing base and head](/concepts/comparing/): how two runs become a verdict. * [rehearse.yaml reference](/reference/manifest/): every field and its default. # Comparing base and head > How Rehearse runs scenarios on the base and the head, sets aside what changes on every run, and sorts each scenario into one verdict. In the shop fixture, a change compared with `main` gets this answer. Terminal ```text $ rehearse compare --base main 2 as on the base · 1 new · 2 changed and said so (2 edited) · 2 changed without saying so · 1 fails on the head · 1 gone changed without saying so: The owner sees every item (packages/api/items.hurl:14) $.items[*].price: 3.5 → "3.50" (3 places) The weekly stock report lists every item with its price (packages/report/weekly.rehearse.yaml) weekly.csv column 3 "price": "3.5" → "3.50" (2 places) fails on the head: The count is right (packages/api/items.hurl:26) $.count: 3 → 2 line 30: jsonpath "$.count" == 3 · expected 3, got 2 changed and said so: The shop names itself (packages/api/items.hurl:8) — its definition was edited $.name: "Shop" → "The Shop" A member isn't told the admin page exists (packages/api/items.hurl:21) — its definition was edited status: 404 → 403 $.error.code: "not_found" → "forbidden" new: The owner finds items by name (packages/api/items.hurl:33) unannounced, by what changed: $.items[*].price — in 1 scenario weekly.csv column 3 "price" — in 1 scenario gone from the head: The legacy ping answers (packages/api/items.hurl) 8 ids, times and opaque values were set aside before comparing. Stand-ins: payments (fake, for The payment provider). ``` `rehearse compare` runs every scenario on the base and on the head, compares what each saw, and gives each scenario one verdict. The first line counts them. This page explains each part. ## Base and head [Section titled “Base and head”](#base-and-head) | Side | What it is | Default | | ---- | ------------------------------------------------------------ | --------------------------------------------------------------------------- | | base | The branch production runs: what the change is compared with | `base` in `rehearse.yaml` (`main` when unset), or `--base ` | | head | The change | This checkout as it is now, uncommitted changes included, or `--head ` | **The head’s manifest drives both sides.** A comparison reads one `rehearse.yaml`, the one found from where you run Rehearse, and runs its commands in each checkout. A base that has no `rehearse.yaml` yet can still be run, so you can record today’s behaviour the day you adopt Rehearse. **The base is a git worktree, prepared once.** A ref becomes a detached worktree of its commit under `.rehearse/checkouts/`. Rehearse runs `prepare` there once (installing dependencies, building) and marks it prepared. The next comparison against the same commit reuses it. Rehearse keeps the newest three (`budget.checkouts`) and `rehearse clean` removes the rest. Rehearse says when it checks a base out. Terminal ```text Checking out main (c68f00d9431f) into …/shop/.rehearse/checkouts/c68f00d9431f ``` **Refs and folders.** `--base` and `--head` take a ref or a folder. Only a path that starts with `./`, `../`, `/` or `~/` is a folder, and a relative one is read from where you run Rehearse. Anything else is a ref, so a folder that happens to be called `main` never stands in for the branch. A folder inside a git repository means that repository’s top folder. The base and the head can’t be the same checkout. If the manifest names an `overlay`, its files are copied into each checkout before anything runs there. See [keeping the manifest outside the product](/guides/adopt/#keep-the-manifest-outside-the-product). Scenarios run on the base, then on the head, never both at once. The base runs only the scenarios the head still has. ## What is set aside [Section titled “What is set aside”](#what-is-set-aside) Some values differ on every run and mean nothing: an id the database made, the time a row was written, a cursor. Before comparing, Rehearse replaces them with a marker on both sides, so only real changes are left. | What | Where | Becomes | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | | UUIDs and ULIDs | any value that is one, and UUIDs inside text | `‹id›` | | Generated ids | under a key named `id`, ending in `Id` or `_id`, or starting with `correlation`: a string that looks generated (a UUID, a ULID, or 16 or more letters and digits mixed, with no spaces) | `‹id›` | | Integer ids | an integer under one of those keys | `‹id›` | | ISO date-times | any value that is one, and inside text | `‹time›` | | Epoch times | an integer over 10⁹ under a key ending in `At`, `_at`, `Time` or `_time`, or named `at`, `timestamp` or `ts` | `‹time›` | | Relative times | in text: “3 days ago”, “about an hour ago”, “in 5 minutes”, “just now” | `‹time›` | | Opaque values | a string under a key ending in `cursor`, `token`, `etag` or `nonce` (any case); a base64url string of 32 or more characters that mixes upper case, lower case and digits | `‹opaque›` | | Order | arrays (or a file’s rows) only where a scenario or the manifest says `unordered` | sorted | The rules are tight on purpose, so a real change still shows: * `roleId: "owner"` is compared: `owner` doesn’t look generated. * A hex checksum is compared: it has no upper case, so it isn’t opaque (unless its key names an id or a token). * “in 30 days” is compared: a promise about days is meant. Only seconds, minutes and hours ahead are set aside. * Array order is compared unless you say `unordered`. Pieces and flows render on a fixed browser clock (15 January 2026, 12:00 UTC), so a date on screen reads the same on both sides. Calls and JSON outputs get every rule. Text (a plain body, an accessibility tree, a file’s cells and lines, logged errors) gets the rules that work inside text: UUIDs, ISO times, relative times and your own values. ### Your own rules [Section titled “Your own rules”](#your-own-rules) The manifest’s `setAside` adds rules of your own. rehearse.yaml ```yaml setAside: keys: ['^requestHash$'] # values under these keys are set aside values: ['build-[0-9a-f]{7}'] # values (or text) matching these are set aside keep: ['$.expiresAt'] # never set aside: JSON paths, or a file's column names ``` Each rule is a regular expression. What they set aside becomes `‹set aside›`. `keep` takes a JSON path (`$.expiresAt`, or `$.items[*].sku` for every item) or a column name. A file scenario can add its own `setAside`, with `columns` that are never compared; see the [files guide](/guides/files/#set-aside). ### Counted, and stored raw [Section titled “Counted, and stored raw”](#counted-and-stored-raw) Every comparison lists what it set aside for each scenario, by kind and count (`ids`, `times`, `opaque`, `order`, `custom`), counted on the head’s side: one count per value a reader sees. The text ends with the total: Terminal ```text 8 ids, times and opaque values were set aside before comparing. ``` Observations are stored with nothing set aside. Rules apply when comparing, so a new rule never needs a new run. ## Differences, grouped by path [Section titled “Differences, grouped by path”](#differences-grouped-by-path) What is left after setting aside is compared. One change in many places is one difference with a count: | Kind | Compared | A difference reads | | ----- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | | call | status, content type, body | `status: 404 → 403`, `$.items[*].price: 3.5 → "3.50" (3 places)` | | file | exit code, each output by its layout | `weekly.csv column 3 "price": "3.5" → "3.50" (2 places)` | | piece | the tree, logged errors and axe violations, in each scheme; the screenshot only when asked | `light tree line 3: "- status: 0 in the basket" → "- status: 0 in your basket"` | | flow | the number of steps, whether each step held, the tree after each, and the errors the page logged | `step 2 (click “Add one” (button)) line 3: "- status: 1 in the basket" → "- status: 1 in your basket"` | JSON paths fold their indices (`$.items[3].price` becomes `$.items[*].price`). Text is compared line by line, and named by the head’s line. Two texts too long to align (their line counts multiplied come to over four million) are compared by position instead, so one line inserted there shows as a change to every line after it. A file’s rows are compared cell by cell and grouped by column. The folders a run sits in are written as placeholders in what Rehearse keeps, so the base (a worktree under `.rehearse/`) and the head never differ by where they sit. The checkout is `{{checkout}}`. When `rehearse.yaml` sits inside the checkout, as it usually does, its folder is written as that place in the checkout, `{{checkout}}/`, on both sides. `{{manifest}}` is used only for a manifest kept outside the checkout, as in the [Kurvball example](/examples/kurvball/). ## Verdicts [Section titled “Verdicts”](#verdicts) Each scenario gets one verdict. When more than one applies, the first in this list wins: | Verdict | In JSON | Means | | ------------------------- | -------- | ------------------------------------------------------------------------- | | fails on the head | `fails` | It fails on the head. `failsOnBase: true` when it fails on the base too | | new | `new` | The base has no such scenario | | changed without saying so | `unsaid` | It differs from the base, and nothing said it would | | changed and said so | `said` | It differs, and the change announced it, or its own definition was edited | | as on the base | `same` | Nothing differs once ids, times and opaque values are set aside | The verdict is one word, but nothing is lost. Each scenario in the JSON also keeps `changed`, `said` (`"announced"`, `"edited"` or `null`), `edited`, `failsOnBase`, `failsOnHead`, its `differences` and its `failures`. The [JSON reference](/reference/json/) has every field. Fails on both A scenario that fails on the base too is still `fails`, and the line counts it apart: `1 fails on the head (1 on the base too)`. It is not this change’s doing. See [gates](/guides/gates/) for how to treat it. ## Said so [Section titled “Said so”](#said-so) A change can say what it changes in two ways. They are kept apart: | Source | How | Shows as | | --------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------------- | | Announced | The scenario is named in `.rehearse/announce.yaml` beside the manifest, in `--announce `, or in `--said ` | `— announced: ` | | Edited | The scenario’s own definition changed between base and head | `— its definition was edited` | When both apply, announced wins: the why is what a reviewer wants to read. The line counts the two apart: `4 changed and said so (3 announced, 1 edited)`. See [announcing what a change changes](/guides/announce/). “Edited” is decided per scenario, never per file. Rehearse hashes each scenario’s own parsed definition: | Kind | Its definition | | ----- | -------------------------------------------------------------------------------------------------------------------------------------- | | call | its method, URL, headers, query, body, status, asserts, captures and options, and the earlier calls in its file whose captures it uses | | piece | its export’s statement, and the file’s meta: its default export and the object it names, never its imports | | flow | its service or piece, start, world, person and steps | | file | its parsed YAML, and its input file’s contents | So reformatting a file, adding a comment, or adding a scenario beside another says nothing about the others. A slip can’t hide behind an edit to the file next to it. Adding an import for a new story doesn’t edit the stories beside it either. A scenario read beside the manifest (`./…`) is the same file on both sides, so it is never edited. Only an announcement says it changed. ## The line [Section titled “The line”](#the-line) The first line counts the verdicts, and what else the comparison found: Terminal ```text 2 as on the base · 1 new · 4 changed and said so (3 announced, 1 edited) · 1 fails on the head · 1 gone 4 as on the base · 1 changed without saying so · 1 fails on the head (1 on the base too) ``` The JSON keeps the same in `line` and in `counts`: `same`, `said`, `announced`, `edited`, `unsaid`, `new`, `fails`, `failsOnBoth`, `gone` and `notRun`. ## Gone, not run, and the rest [Section titled “Gone, not run, and the rest”](#gone-not-run-and-the-rest) | Part | Means | | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | gone from the head | A scenario the base has and the head doesn’t. Listed apart, never run, no verdict. | | not run | A scenario that couldn’t run on a side: its service didn’t come up, its world didn’t build, the sign-in failed, or the runner stopped. Listed with the side, the step and what was said. No verdict. | | announced, but as on the base | An announcement whose scenarios all came out unchanged. Either the change didn’t do what it said, or the announcement is stale. | | unannounced, by what changed | The changes nobody said, grouped by path, the path in most scenarios first. One cause often shows in many scenarios. | | not read | A scenario file Rehearse couldn’t read on one side, with its line and why. In a comparison of every scenario, an announcement entry that names no scenario at all (none compared, gone or not run) is listed here too: “The announcement names X, which matches no scenario compared.” | ## The base that didn’t come up [Section titled “The base that didn’t come up”](#the-base-that-didnt-come-up) If the base can’t be checked out or prepared, or its services don’t come up, there is nothing to compare with. Rehearse says so once and gives no verdicts, instead of a misleading verdict per scenario: Terminal ```text $ rehearse compare --base main The base didn't come up (up): api stopped before it was ready (exit 1): … Its log: …/shopb/.rehearse/logs/api@4f20e84ecf.log ``` With `--json`, the comparison says the same, shortened here to the parts that matter. Terminal ```json { "ok": false, "base": { "ok": false, "step": "up", "says": "api stopped before it was ready (exit 1): …" }, "scenarios": [] } ``` `step` is where it stopped: `checkout`, `prepare`, `overlay`, `up` or `world`. If the head doesn’t come up, every scenario is listed as not run on the head. ## The cache [Section titled “The cache”](#the-cache) The base changes rarely; the head changes all the time. So Rehearse keeps each observation of a clean commit, and the next comparison against that commit reads it instead of running again: Terminal ```text 7 base observations came from the cache (c68f00d9431f). ``` An observation is kept under `.rehearse/cache//`, by a key made of: * the commit; * the scenario’s id, its definition, and what else in its file it depends on (a call’s earlier calls); * the group it ran with (below); * its world and person; * the stand-ins replaced with the real one (`--real`); * the kind runner’s version; * only the manifest parts it uses: its services, its world’s chain, the stand-ins on its services, `prepare`, `signIn`, its kind’s settings, and the overlay’s contents. Editing an unrelated service or world doesn’t throw the cache away. A new version of a kind’s runner does, and the base runs again. Rehearse never caches: * a checkout with uncommitted changes (the head as you work on it); * a run where something around the scenario broke: services that didn’t come up, a world that didn’t build; * a call whose service didn’t answer, or timed out; * a run on services someone else left up, since Rehearse can’t vouch for their state. A clean head commit is cached too, so comparing two commits a second time runs nothing. `--fresh` ignores the cache. ### Groups [Section titled “Groups”](#groups) Scenarios that run on the same services in the same world share those services’ state: what one call creates, the next one sees. So such scenarios form a group. Each member’s cache key holds the whole group (its members, their definitions, in the order they run), and a group is read from the cache whole or run whole. If one member misses, every member runs again, together. A scenario that needs no service is a group of its own. A call always runs after the calls before it in its file, even when you compare only that call, so its captures and its state are the ones it was written against. ## Choosing what to compare [Section titled “Choosing what to compare”](#choosing-what-to-compare) A comparison takes every scenario, the scenarios you name, or only those the change reaches. Terminal ```sh rehearse compare --base main # every scenario rehearse compare --base main 'packages/api/**' # ids, or globs over ids rehearse compare --base main --affected # only what the change reaches ``` `--affected` takes the files that differ between the base commit and the head (committed, staged, unstaged and untracked) and keeps the scenarios they reach. See [affected scenarios](/concepts/affected/). ## Where results are kept [Section titled “Where results are kept”](#where-results-are-kept) Each comparison is written to `.rehearse/compare/