# The DST API, v1

f+ DST runs your tests in a deterministic simulator under timing faults, on our machines. This API is the bare
tool: push an image, run jobs on it, read the results, pay by the core-hour. Every call has one `fplus dst` command;
`-json` prints the API's answer as it came. `fplus dst help` lists the common path, `fplus dst help advanced` the rest.

Install fplus and sign in: `curl -fsSL https://staging.extrafunctional-staging.fyi/dst.sh | sh`, then `fplus login` (run it twice: the
first prints a GitHub code, the next waits for it; it finds or makes your team). Calls go to
`https://staging.extrafunctional-staging.fyi/v1/dst/teams/TEAM/...` with your fplus sign-in or a DST token (`Authorization: Bearer dstt_…`).

A new team (a bot's, an agent's, another project's) comes first, then its token, in this order:

    fplus dst team create NAME                 # you are its admin
    fplus dst token -team NAME -name agent     # its token, shown once

## Without fplus

Every `fplus dst` command is one HTTPS call, so an agent that may not run our binary can use curl and its own Docker,
and read every step. Your person signs in at https://staging.extrafunctional-staging.fyi/account, makes a DST token there (shown once) and
gives you it and the team's name. Then, in the repository's folder, with `.fplus/environment/` written (step 3 of
https://staging.extrafunctional-staging.fyi/dst.md shows what goes in it):

    export EXFUN_DST_TOKEN=dstt_… TEAM=your-team
    api() { p=$1; shift; curl -sS --fail-with-body -H "Authorization: Bearer $EXFUN_DST_TOKEN" "https://staging.extrafunctional-staging.fyi/v1/dst/teams/$TEAM/$p" "$@"; echo; }
    docker build --platform linux/amd64 -f .fplus/environment/Dockerfile -t dst-image .
    docker run --rm --platform linux/amd64 --network none dst-image bash .fplus/environment/verify.sh TEST  # must pass here
    docker save dst-image -o image.tar
    sha=$(shasum -a 256 image.tar | cut -d' ' -f1); size=$(wc -c < image.tar | tr -d ' ')
    split -b 16m -a 3 image.tar part.             # 16 MiB parts, named in order
    n=0; for p in part.*; do api "images/$sha/parts/$n" -X PUT --data-binary @"$p"; n=$((n+1)); done
    api images -H 'content-type: application/json' -d "{\"sha256\":\"$sha\",\"size\":$size,\"parts\":$n}"   # {"image":"img_…"}
    api jobs -H 'content-type: application/json' -d '{"kind":"hunt","image":"img_…","test":"TEST","budget_min":30,"tier":"batch"}'
    api "jobs/JOB?wait=30"                        # again until "state":"done"; then jobs/JOB/result, findings/FINDING

A hunt queues the image's check itself. [Calls](#calls) lists the rest; the answers are the same JSON `fplus dst -json`
prints. What you lose: `image push`'s layout check before sending (the `docker run` line stands in for it), `scan`
and the no-Docker `-env`, `-go`, and `-bin` pushes. What leaves your machine, where it is kept, for how long and how to delete it: section 0 of https://staging.extrafunctional-staging.fyi/dst.md.

## In CI

1. `fplus dst token` prints a DST token once (`-name ci -days 90` by default; `-list`, `-revoke NAME`). Store it as
   the repository's Actions secret `EXFUN_DST_TOKEN`.
2. `fplus dst ci-workflow -test TEST > .github/workflows/dst.yml` writes a workflow that, on each push to the default
   branch, builds `.fplus/environment/Dockerfile` (edit the workflow for another) for linux/amd64 on ubuntu-latest, pushes it, then runs
   `check` and a 60-minute `hunt` of TEST. It names your team in `EXFUN_TEAM`.

With `EXFUN_DST_TOKEN` and `EXFUN_TEAM` set, `fplus dst` needs no sign-in or config: it calls `/v1/dst/teams/TEAM/`
(below) as the token, which works as the person who made it.

## Find flaky tests in CI

`fplus dst scan OWNER/REPO [-days 14] [-workflow NAME] [-team TEAM] [-max-runs 400] [-max-requests 1500] [-enough 40] [-dir DIR] [-json]` reads the repository's GitHub
Actions runs, jobs and test logs through f+, which reads public repositories on our server; a private one f+
refuses is read with your `fplus login` GitHub sign-in. A token you give in `GH_TOKEN` or `GITHUB_TOKEN` is used
instead, directly; gh's own sign-in never is. `-team` names the team whose f+ reads these are (default this machine's,
or `EXFUN_TEAM`). It first says what the scan will cost: the window's runs in each workflow, how many it reads (past
`-max-runs` runs in all, sampled evenly; a retried run always), and about how many reads of GitHub that takes (a
run's jobs and the logs it reads, sized from sampled runs), and how many runs a cap it reaches first leaves read. It stops
at `-max-requests` reads, and once `-enough` jobs show failing tests (enough flake evidence), keeping what it read: a
second scan goes on from there. A job's log that won't come after three tries is skipped. It lists
the tests that failed then passed at the same commit: a job's own retry (nextest FLAKY, gotestsum re-runs, jest
retries), or a re-run of the same job that succeeded. Tests that failed on two or more commits with no pass on retry are
listed after them as suspects, a lead rather than a proof. One error line that is no test's own (not generic) failing
five or more tests at once (console noise, a broken setup) is one suite-level failure, listed after the real test
flakes with how many tests it failed and a few of them, not one row per test. A test whose only CI line is console output
(`console.error`/`warn`, jest's "Console" block) is listed as console noise, after those, not as a flaky test. Each row has how often it flaked, on how many commits,
first and last day, CI's failure line, a run link, and the TEST to give `fplus dst hunt IMAGE TEST`. It reads go test
and gotestsum, cargo-nextest, jest and JUnit output. A second scan fetches only what is new. What it read is kept in `fplus/scan/OWNER/REPO` under your cache folder (or `-dir`): each job's failing tests, not its log, and at most 500 MB of scans, removing first a repository not scanned for 30 days, then the least recently scanned; scan prints where. `-json`
prints one record per flaky occurrence: `{repo, test, commit, error, error_regex, error_generic, run_url, kind,
runner, job, attempt, branch, event, when, tries, detail}`.

Through f+, scan calls `GET teams/{team}/github/repos/OWNER/REPO/actions/...` (the same paths as GitHub's API: a
repository's workflows, their runs, a run's jobs and a job's logs) with the team's sign-in or DST token, and f+ reads
GitHub as its own GitHub App. Only public repositories: a private one answers 403 "OWNER/REPO is private: f+ reads
only public repositories itself; …". Each answer is kept, shared by every team's scan of that repository: a finished
job's log 30 days, a past day's run list 7 days, the rest 6 hours, so a second scan, or another team's, costs no reads. A
team may make 2000 uncached reads a UTC day. `GET github/quota` answers `{cap, used, left, binding,
shared_left, resets_at}`: `left` is what the cap that binds allows (`binding`: `team`, the team's daily cap, or `shared`,
f+'s shared GitHub quota when that leaves fewer). Past it the answer is 429 saying whose limit it is, with `retry_after`
and when it resets, in UTC. `fplus dst scan` prints that cap first, reads at most `left`, and when it stops short still
reports the flakes in the runs it read, with `partial: N of M runs read …; run fplus login or set GH_TOKEN to finish`.
A person signed in with `fplus login` (with GitHub) scans as that sign-in, without f+'s daily share; a team's DST token
(an agent's, CI's) always reads through f+.

## Names

Every job and finding has a name as well as its ID, shown first everywhere (`fplus dst status`, `jobs`, `findings`,
the JSON's `name`):

- **A job:** the `name` its submitter gave (`-name NAME`, `{name}`: 1 to 60 letters, digits, spaces and `# . _ -`), or
  `<kind> <short test> #<n>`, e.g. `hunt can-restart-from-snapshot #3`. `n` counts the team's jobs of that kind and
  test, from 1.
- **A finding:** its short test and its fingerprint's first 6 characters, e.g. `can-restart-from-snapshot d5c853`.
- **The short test:** what follows the test ID's last `::` (a jest or pytest test name, spaces and all), else its last
  segment (after `/`, `#`, `.` or a space), with a test file's extension dropped (`reqresp.test.ts` → `reqresp`,
  `raft_test.go` → `raft`) and parameters dropped, without a `test_`/`Test` prefix, as kebab-case words, with filler words (after, joining, the, a, with, when, should, …) dropped
  until it fits 32 characters.
- **In place of an ID:** wherever a job or finding ID goes (paths such as `jobs/{job}`, `findings/{finding}`, a
  replay's `finding`, a fixcheck's `job`, and every `fplus dst` command), its name or a unique prefix of it works,
  ignoring case (URL-encode it in a path). None: 404. Several: 409 `ambiguous: <name> (<id>), …`. The ID stays the
  stable key.

## Credit and holds

A job holds the most it may be charged when it is queued, is charged what it used when it ends, and gets the rest of
the hold back. At $0.50 per core-hour, with 10 GiB of RAM or less per VM (prices: **Credits**):
- a check holds $0.58 (1.17 core-hours: its VM × its budget plus a margin, the wall cap our machines enforce) and is
  usually charged about $0.02;
- a hunt holds, and is charged at most, its VMs × its budget: a 60-minute hunt runs on 10 VMs, holds $5.00 while it runs and is charged at most $5.00,
  and a 15-minute hunt runs on 10 VMs, holds $1.25 while it runs and is charged at most $1.25. Its wall cap adds 10 to
  60 minutes to group and shrink what it found; that time is ours and isn't billed.

`fplus dst credits` (`GET credits`) shows `held_usd` by `open_jobs` and `available_usd` apart from what was spent. A hunt or fixcheck the credit left
can't hold whole runs shorter instead, down to its 5-minute minimum: the job says `budget_min` and `budget_cut` ("cut
from 60 to 25 min to fit your credit"). It is still charged at most its hold, so a team never spends past its credit.
Below 5 minutes it is refused with 402, saying what is held and what is free. A team without its own credit spends
your personal grant, which all your teams share; `grant_low` warns when it runs low, and a team made
`-own-credit-only` keeps to its own credit.

## Tokens

`POST tokens {name, days?}` → `{token, name, expires_at}`, shown once (90 days by default, at most 365); `GET tokens`;
`DELETE tokens/{name}`. A DST token calls as the team and the person who made it, and cannot manage tokens.

## Accounts for CI bots and agents

A bot or an agent gets a team of its own and a token, with no sign-in of its own:

1. `fplus dst team create NAME` (`POST /v1/dst/teams {name}`, signed in) makes the team, with you as its admin:
   `201 {team, admin}`; `200` if it is already yours; `409` if someone else's.
2. `fplus dst token -team NAME -name agent -days 30` mints its token.
3. Hand over `EXFUN_DST_TOKEN` and `EXFUN_TEAM` only. A token cannot create teams or tokens, so it cannot widen its
   own access. Its jobs spend your welcome credit first, then the team's, unless the team was made with
   `-own-credit-only` (`{name, own_credit_only: true}`, also on a team already yours): then only the team's own
   credit, never anyone's welcome credit. It can be turned on, never off.

## The image

- A `docker save` tar of a linux/amd64 image, at most 8 GB.
- It runs offline: no network, ever.
- One test runs as `bash .fplus/environment/verify.sh "$TEST"` from the image's final `WORKDIR`, as root (the image's
  `USER` is not used: a suite that refuses root, such as libuv's or PostgreSQL's, drops to a user in verify.sh, e.g.
  `exec su tester -c "…"`; the local `-check` runs as root too, so it fails the same way). It exits 0 only when
  the test passed, and a skipped test is a failure. `TEST` is your runner's own name for one test.
- The layout `fplus dst image push` checks before it sends anything (the server would refuse it only after converting
  the image for the simulator): the image sets a `WORKDIR`, and `<WORKDIR>/.fplus/environment/verify.sh` is in it and
  executable. Layer entries are written without a leading `./` (`tar -C DIR work`, not `tar -C DIR .`).
- verify.sh must read the knobs you set in a job's environment: a job's `COUNT=25` does nothing if verify.sh runs
  `-count=1`.
- `-faults disk` makes system calls fail: your test's own checks must tell an injected error from a bug. A write that
  fails with an injected ENOSPC or EIO and makes the test fail is reported as a finding. Count injected I/O errors as
  inconclusive (exit 0), and fail only on what the system must never do: corruption, or an acknowledged write that is
  gone. For example, a durability check that reopens the store and reads back every acknowledged key: a missing or
  wrong value fails; an EIO while reading passes as inconclusive.
- The test may see variables of the simulator's own. Don't read or depend on them; the names for you are
  `FPLUS-DST-HIST` records and, on an image with `services.yaml` (in every mode), `$FPLUS_DST_STOP_FAULTS`; a test that
  also runs without services calls it as `"${FPLUS_DST_STOP_FAULTS:-true}" SECONDS`.
- Test binaries are built into the image; verify.sh only runs them.
- Your runner's own retries are off: pytest-rerunfailures or `flaky`, nextest retries, xUnit retry attributes. A
  retried failure passes, and no hunt sees it.
- Timing, network, and disk (`-faults disk`, via Linux kernel `fail_function`) faults work on any Linux binary,
  static or dynamic (`EINTR` and `EAGAIN` apply only to sockets, pipes, and eventfds, never regular files). Process
  (`-faults process`) and powercut (`-faults powercut`) faults require `.fplus/environment/services.yaml`. Dynamic
  linking (glibc) is needed for Go's `-race` (cgo) and for per-service clock steps (`-faults clock` in `services.yaml`).
- `fplus dst image push -env [-label L]` packs `.fplus/environment/` (`services.yaml` with digest-pinned `image:`
  services, or self-contained `verify.sh`, up to 256 MiB) with `debian:bookworm-slim` in pure Go and pushes without
  Docker.
- `fplus dst image push -go ./... [-label L]` cross-compiles Go test packages for linux/amd64 (`CGO_ENABLED=0`), copies
  `testdata/`, fetches and caches `debian:bookworm-slim` in pure Go, generates `.fplus/environment/verify.sh`
  (accepting `TestName` or `DIR::TestName`), and pushes the OCI tar without Docker or a Dockerfile. Static binaries have
  no `-race` or CGo (and skip per-service `-faults clock` in `services.yaml`), while timing, `-faults network`, and
  `-faults disk` all work.
- `fplus dst image push -bin PATH [-label L]` validates a pre-built 64-bit linux/amd64 ELF binary (Rust
  `x86_64-unknown-linux-musl`, C/C++, Zig, etc.), packs it with `debian:bookworm-slim` (using `.fplus/environment/verify.sh`
  or `services.yaml` if present, or generating `verify.sh`), and pushes without Docker.
- `fplus dst image push -build -check TEST [-force]` builds `.fplus/environment/Dockerfile` from your repository's tracked files,
  its submodules, and everything in `.fplus/environment` (tracked or not: there's no need to commit the recipe first) (fetched first if they aren't) for linux/amd64 (warning about untracked files outside `.fplus/environment/` and uncommitted tracked changes). It runs TEST once here, under our limits (`--network none --cpus 2 --memory 4096m`, or `-memory`), and pushes only if it passes — pass `-force` to push anyway when the test fails.
  The local check is free.

## Public images

A job's `image` is an image the team pushed (`img_…`). A public image's reference (`golang:1.22`, `ghcr.io/owner/name:tag`) is
refused (400: `public images aren't run yet: docker pull NAME && fplus dst image push -from docker:NAME`): pull it and push it.

## The command (v1.1)

A check or hunt may name what runs, in place of the image's verify.sh (or a `services.yaml` image's `workload:`; refused on `composer:` images), so one image serves every test:
`"command": {"argv": ["go", "test", "-run", "^TestQuiet$", "./cache"], "script"?: "a bash body", "env"?: {"K": "v"},
"cwd"?: "/src"}`. It passes on exit 0. Give `argv`, a `script` (run with `argv` as `$@`), or both (an empty `argv` with a script is
the script alone). At most 64 KB and 64 variables. `test` is then optional: the job is labelled by its `argv`, else by
the test file its script runs (`verify.sh`'s argument, or the last test file it names), else `script`. A hunt's check runs the same command. A replay or
fixcheck runs its finding's command; a fixcheck may not change it (400: put the fix in the image). With fplus: `fplus dst hunt IMAGE -command
'{"argv": [...]}'`.

## A group of tests

A check or hunt may run a group of tests, a class or fixture, not one test: `"group": true`, with `test` the
runner's own filter as the image's verify.sh (or your command) passes it on, e.g. Go `-run 'TestA|TestB'`, NUnit
`--filter` `FullyQualifiedName~TxTests`, pytest `-k`, `cargo test module::`. Some flakes fail only beside their
neighbours (a shared pool, a port, a static), and a class often runs in seconds where its namespace takes a minute,
so it gets ten times the schedules. The check runs the group with no faults, and all of it must pass. The hunt treats
any test of the group that fails as found; each finding has `tests_failed`, the group's tests that failed in its runs,
and its `error` starts with the first of them (`T.Malformed_list(1): Expected: 1 But was: 2`), so two tests failing are
two findings. A replay or fixcheck of such a finding runs the group again. Hunt the group's findings one at a time with
the group, not the test alone: the failure may need the neighbours. With fplus: `fplus dst hunt IMAGE TEST -group`
(a TEST that starts with `-` goes after `--`: `fplus dst hunt IMAGE -group -- -run=^TestA$`).

## Which fault, from the symptom

| The symptom | Inject |
|---|---|
| A stall, a missed heartbeat, a timeout of seconds | the default search (steals and pauses reach seconds) |
| A Go timeout against a timer budget | `load` once it's live (not yet); meanwhile the default search |
| A race on shared state between threads | a hunt of 10 min or more (its PCT draws; every guest has 2 vCPUs) |
| A timeout or leak with a dial or connect in the stack | not reachable yet (slow-connect is coming); reproduce natively under `tc netem` latency |
| Lost acknowledged writes, crash consistency | power loss of a service with `data:` ([services](#services)) |
| Wrong handling of a disk error | `faults: ["disk"]` |
| Stale or divergent reads across nodes | [services](#services) with partitions and kills |
| `select`, map-order or seed nondeterminism | the default search (each schedule draws its own entropy) |
| Loss, delay, duplication or reordering of the test's own messages | `faults: ["network"]` |

Before a long hunt, run the reproduction natively under a CPU limit and under latency: if it never fails there, it
may need something our machines lack, and a hunt won't find it.

## The fault plan (v1.1)

A hunt may aim its faults with `"fault_plan"`, in f+ DST's own schedule language (each finding's
`minimal_schedule` is in it too). A fixcheck takes neither `fault_plan` nor `faults` (400: it replays and searches around its
finding's own schedule), and neither does a check or a replay:

- `schedules`: 1 to 32 exact lines, `<host tokens> | run <guest tokens>`, run first, each once, before the
  search. For example `stx=1200000:800 | run P=workload/raft@3~100:250` steals 800 µs at 1.2M branches and pauses
  thread raft. Their failures are findings with `arm: "given"`. A line f+ DST can't parse ends the job `error`,
  with its parser's message.
  - Host tokens: stolen time `stx=`, seeded steals `sts=`/`stg=`, timing `ste=`/`stb=`, tick jitter `tj…=`,
    disk `disk=`/`dseed=`.
  - Guest tokens: pauses `P=`, freezes and system-call faults `F=`. Kills `K=`, power cuts `C=`, service power losses `L=` and clock steps `T=`
    need an image with services (below), pushed by this fplus, which tells f+ it has a services.yaml: there they
    aim a kill, a step's power cut or the end cut (`disk=cut | run C=10 S=0`). On an image without services they
    are refused (400), as its test is one step and they'd have nothing to act on.
- `window` `{from_ms, to_ms}`: faults are drawn only in that span of the test, in guest milliseconds from its
  start.
- Or `phase`: faults are drawn only after the test prints `fplus-dst: phase <name>`.
- A plan gives schedules, a window or a phase: an empty one is refused (400).
- Kinds of fault stay `faults`, the budget `budget_min`. The result's `fault_plan_used` (also on the job, and in `status` as "fault plan applied") says what was honored. A hunt's `quiet_dropped` `{dropped, planned, share, warn, by_kind, fix, note}` counts the faults scheduled after the test ended, which the quiet period drops (add `J=0` to keep them); with `warn` (over 20 %), `status` leads with its `note`: a clean hunt never ran them.

With fplus: `fplus dst hunt IMAGE TEST -fault-plan '{"window": {"from_ms": 2000, "to_ms": 9000}}'`.

### Schedule grammar

Every schedule line has the shape `<host tokens> | run <guest tokens>`. Tokens are separated by single spaces; **never put spaces inside a token** (write `N=nodes.bridge.2@3-6:loss,100%`, not `N=nodes.bridge.2@3-6 loss 100%`). Host tokens (before `| run`) use lowercase keys; guest tokens (after `| run`) use capitalized keys. Leave the host side empty (`| run ...`) when no host token is needed.

**What a step is in time:**
- **Plain image (no `services.yaml`):** the whole test (`verify.sh`) is **1 step** (`step 0`). Timed pauses use `@0~<off_ms>:<dur_ms>`, syscall faults arm from `@0`, and network netem spans `@0-1`. Step-boundary faults (`K=`, `C=`, `L=`, `T=`) require `services.yaml` and are refused (400) on a plain image.
- **`services.yaml` image:** the workload is split into **10 steps** (`0` through `9`, with step `10` immediately after the last step). Step `0` starts the test in the background; step `i` (`0..8`) ends `(i + 1) * D` ms of guest time after start (or when the test exits); step `9` waits for the test to finish. **`D=<ms>`** sets one step's length in guest milliseconds, so "before step `a`" lands **`a * D` ms** into the test and a span `@from-to` runs for **`[from * D, to * D)` ms** (half-open: active from before step `from` until before step `to`). Hunts set `D=` automatically from the baseline check's duration (`baseline_ms / 10`); in a manual `fault_plan`, include `D=<ms>` (without `D=`, step boundaries sit at 0 ms). With `composer:` (Antithesis templates), the workload runs **30 steps** (`0` through `29`, `C=30` after the last step), one composer round (1 s of guest time) per step.

**Host tokens (before `| run`, lowercase keys):**

| Token | Arguments | Meaning | Example |
|---|---|---|---|
| `stx=` | `<branches>:<µs>[,...]` | Steal CPU time: after `<branches>` retired branches of the run phase, advance the guest clock by `<µs>` µs (up to 32 points). | `stx=1200000:800 \| run` |
| `sts=` / `stg=` | `<hex>` / `<branches>` | Seeded CPU steals over the run (`sts=` seed, `stg=` mean gap in branches; default `50000000`, min `100000`). | `sts=1a2b stg=5000000 \| run` |
| `ste=` / `stb=` | `<ns>` | Timing profile: guest nanoseconds per counted VM exit (`ste=`) or retired branch (`stb=`, default `3`). | `stb=5 \| run` |
| `tj=` | `<hex>` (+ `tjpm=`, `tjmax=`) | Seeded timer-tick jitter (`tj=` seed, `tjpm=` delayed ticks per 1000, `tjmax=` max delay). | `tj=cafe tjpm=20 \| run` |
| `disk=` | `none\|cut\|ioerr:<P>\|lying:<P>` | Data-disk fault class (`cut` honours volatile write cache so power cuts drop unflushed writes; `dseed=<hex>` seeds errors). | `disk=cut \| run C=10 S=0` |
| `slow=` | `<hex>:<permille>:<lo>-<hi>[:w]` | Slow disk flushes (with `:w`, writes too): chance per 1000, seeded delay `<lo>`–`<hi>` ms of guest time. | `slow=42:200:20-80:w \| run` |

**Guest tokens (after `| run`, capitalized keys):**

| Token | Arguments | Meaning | Example |
|---|---|---|---|
| `P=` | `<target>@<at>+<steps>` or `<target>@<at>~<off>:<dur>` or `workload/<thread>[#<k>]@<at>~<off>:<dur>[:<pct>]` | `SIGSTOP`/`SIGCONT` pause: step-bounded (`+<steps>`) or timed (`~<off>:<dur>` in guest ms); `workload/<thread>` pauses matching thread names (`comm`), optional `:<pct>` caps CPU share instead of freezing. | `\| run P=workload/raft@0~100:250` |
| `N=` | `<net_target>@<from>-<to>:<netem>` or `*@<at>:restore` or `<svc>@<at>~<off>:<dur>` | Two-way network fault for steps `[from, to)`. `<net_target>`: `<svc>` (service's port / links to peers), `<a>-<b>` (link), `<a>-*` (`a` vs all peers), `a,b/c` (component partition), `<group>.<shape>` (`halves[.<i>]`, `isolate[.<i>]`, `ring`, `bridge[.<i>]`, `primary`), `node:<svc>[,...][:in\|:out]`, or `*` (all traffic / localhost). `<netem>` is comma-separated (`loss,100%`, `delay,50ms`, `delay,20ms~5ms`, `duplicate,5%`, `reorder,10%`, `corrupt,1%`, `rate,500kbit`, `jam`, `rst`). | `\| run D=1000 N=nodes.bridge.2@3-6:loss,100%` |
| `O=` | `<net_target>@<from>-<to>:<req\|resp>:<netem>` | One-way network fault (`req` = packets to target, `resp` = packets from target) for steps `[from, to)`. | `\| run D=1000 O=n1@2-5:req:loss,100%` |
| `K=` | `<target>@<at>+<down>` or `<svc\|workload>/<proc>[#<k>]@<at>[~<ms>]` | `SIGKILL` before step `<at>` and restart before step `<at+down>` (or kill a matching child process without restarting the service). `<target>` is `<svc>`, `<svc>,<svc>`, or `<group>.<selector>` (`one`, `minority`, `majority`, `all`, `primary`, `follower`). Needs `services.yaml`. | `\| run D=1000 K=n1@3+2` |
| `L=` | `<svc>@<at>+<down>[:strict]` | Power loss of one `data:` service: stops it before step `<at>`, drops unwritten data on its filesystem, restarts before `<at+down>`. `:strict` disables periodic writeback from run start and cuts links while down. Single service name only (repeat `L=` for multiple). Needs `services.yaml`. | `\| run D=1000 L=n1@4+2:strict` |
| `C=` | `<at>` or `recovery~<ms>` | Whole-machine power cut before step `<at>` (`C=10` cuts after the last step), followed by recovery boot and `final:`/`check:`. Pair with `disk=cut` (and `S=0` to skip final `sync`). Needs `services.yaml`. | `disk=cut \| run C=10 S=0` |
| `T=` | `<at>:<sec>` or `<at>:@<point>[<off>]` or `<svc>@<at>:<sec\|<ms>ms\|<n>ppm>` | Clock step before step `<at>`: global realtime step (`T=4:-60`), UTC boundary (`T=2:@day-5s`), or per-service wall clock (`T=n1@3:300`, `T=n2@5:-200ms`; dynamic glibc services only). Needs `services.yaml`. | `\| run D=1000 T=n1@3:300` |
| `F=` | `<target>@<step\|recovery>:<calls>:<ERRNO>[#<k>][x<n>\|xall][@data\|@path=/p[*][,thread=t]]` or `<svc>[<>]<peer>@<step>[#<k>][:<match>]:<ms>` | Kernel syscall failure (`fail_function`, works on static and dynamic binaries; `#<k>` is 1-based match count, `x<n>`/`xall` repeats; `@data` limits to non-exec regular data files), or packet-triggered conversation freeze (`>` sends, `<` receives). | `\| run F=workload@0:fsync:EIO#3` |
| `D=` `S=` `V=` `J=` `E=` | `<ms>` / `0` / `<seed>` / `0\|1` / `<hex>` | Workload knobs and RNG: `D=<ms>` step length in guest ms (`services.yaml`); `S=0` skip final global `sync`; `V=<n>` `DST_SEED`; `J=0|1` keep faults after test exits (`J=<target>@<at>[+<back>]` for a cluster membership change); `E=<hex>` reseed guest RNG. | `\| run D=1000 V=7 J=0 N=*@0-1:loss,3%` |

## Services

A recipe may declare its services in `.fplus/environment/services.yaml`: long-running processes, each its own target,
and a workload that is the test, a client of them. A hunt then kills and restarts services, partitions them and
steps one service's clock while the workload runs; a service with `data:` also loses power (what it didn't fsync is
lost, it restarts, and the workload should notice lost acknowledged writes). With a `final:` read-back or a history
`check:`, the whole machine loses power too, during the test or after its last step. The rules, proven on a toy KV
store and Kvrocks, are in https://staging.extrafunctional-staging.fyi/dst-services.md.

    services:
      - name: n1
        run: "./kvnode --listen {addr:n1}:7000 --peers {addr:n2}:7000"
        data: /var/lib/kv               # optional: own file system for power-loss faults
      - name: n2
        run: "./kvnode --listen {addr:n2}:7000 --peers {addr:n1}:7000"
    groups:
      nodes: [n1, n2]                   # majority, primary (the first) and halves for partitions
    workload:
      run: "./client --to {addr:n1}:7000"
      seeds: true                       # optional: the test varies itself by $DST_SEED
      history: /out/history             # optional: its FPLUS-DST-HIST records, for check:
    check: {type: linearizable}         # optional: or list-append (consistency: …), or messages (claims: …, a queue's promises); needs history
    final: {run: "./client --read-all"} # optional: reads the state back, after a power cut too

- Each service gets its own address on a bridge: by default `10.89.0.0/16` with `10.89.0.11`, `.12`, … in file order
  (`10.89.0.1` is the gateway and `.10` is the test), or a custom RFC1918 `/16` or `/24` via top-level `network_cidr:`
  (e.g. `10.20.0.0/24`; each `addr:` must be a host address in that CIDR, and on custom subnets the test service takes
  `.254`). Services and the test see `SVC_<NAME>_ADDR`, and `{addr:<name>}` is substituted in `run:`, `entrypoint:`,
  `cmd:`, `ready:`, per-service `env:`, `groups.<g>.primary`, and `final.run` (quote such strings; top-level `env:` is
  not substituted). Listen on your own address or 0.0.0.0 and dial the others by theirs, never 127.0.0.1, or partitions
  won't cut your traffic.
- Each service runs the image with a writable root of its own (an overlay on the shared one): it doesn't see the test's files or
  the other services' unless they share a volume (`volumes:` / `mounts:`). A service's `run:` is a foreground command (`exec …`), or override the image's command with `entrypoint:` / `cmd:` string arrays (not combined with `run:`); the workload's never starts with `exec`, which would replace the wrapper that reads its exit status (push refuses it). `data: <dir>` gives it a file system of its own
  there (1024 MiB, or the service's `data_mib:`, 16 to 3072; the image's files there copied in): keep what must survive a
  power loss there, fsynced before you acknowledge. `<dir>` is an absolute path such as `/var/lib/kv`; `/`, `/tmp`,
  `/proc`, `/sys`, `/dev` (and anything under them) and anything under `/data` are reserved (`/data` itself may be, each
  service its own), and `fplus dst image push` refuses
  a services.yaml that names one, or a key the scheduler doesn't take (a service: `name`, `run`, `entrypoint`, `cmd`,
  `addr`, `data`, `data_mib`, `mounts`, `volumes`, `ready`, `env`, `image`, `build`, `names`, `faults`, `job`, `init`, `depends_on`,
  `after`, `restart`; the file: `services`, `groups`, `workload` with `run`, `history` and `seeds`, `check`, `final`, `env`,
  `composer`, `events`, `network_cidr`, `volumes`). Use `job: true` or `init: true` for one-shot setup containers
  (implies `faults: false`), `depends_on:` / `after:` for startup order, `restart:` (`no`, `always`, `unless-stopped`,
  `on-failure`, or `on-failure:<max>`; rejected on `init: true`/`job: true`) for fail-stop services, and `faults: false` to keep helper services
  unfaulted. `composer:` (dir, service, template) instead of workload: runs the image's Antithesis-compatible test
  templates (/opt/antithesis/test/v1/<template>/...) with Antithesis's semantics: one template, one first_, one
  eventually_ or finally_ per run (https://staging.extrafunctional-staging.fyi/dst-services.md).
- A service that never gets ready fails the setup with why: it exited first (keep `run:` in the foreground), it never
  listened on TCP at its address or 0.0.0.0 within 120 s (bind `{addr:<name>}` or 0.0.0.0, not 127.0.0.1, or give
  `ready:`), or its `ready:` never exited 0 within 120 s.
- An invalid services.yaml fails the job (`harness`, with why); it never runs the workload without its services.
- `-faults process` kills and restarts (~60%) or pauses (~40%) a service, a group's majority, or its primary — it never
  cuts power; `network` partitions services and groups, both ways or one; `clock` steps one service's clock; `powercut`
  cuts a `data:` service's power (`L=`) and, with `check:` or `final:`, the whole machine's power (`C=`), with zero
  injected syscall errnos; `disk` does those same power cuts plus kernel `fail_function` syscall errnos (`F=`). Whole-machine
  power cuts land during the test or after its last step, half of the latter without that step's sync (`S=0`), so what
  the services left unsynced is lost. Faults land at 10 points spread over the test's length. A service that doesn't
  start again after its own power loss is a finding.
- `workload.seeds: true`: each schedule draws a seed the test reads in `$DST_SEED` (0 without one), shown as `V=<n>` in
  a schedule. `workload.history` is a file the test appends `FPLUS-DST-HIST` records to (one per operation's invoke and
  outcome), which `check:` checks: `linearizable` (`model: register|cas`, `initial: nil|any`) or `list-append`
  (`consistency:`, strict-serializable by default). `final: {run}` reads the state back at the end, and after the
  recovery boot of a power cut. Formats in https://staging.extrafunctional-staging.fyi/dst-services.md.
- A services hunt splits its VMs between the scheduler's services draws and the engine's own timed explorer over the services.
- A finding's `minimal_schedule` reads, for example, `disk=cut | run V=9 C=10 S=0`: seed 9, a power cut after the last
  step (10), which didn't sync first.
- Clock steps don't reach Go or statically linked binaries (they work by preloading a library); such services are
  listed in `clock_unavailable` (with `clock_unavailable_why`, each one's reason, when known) and still get process crashes and partitions.
- Costs: about a third more wall time per run. The services share one read-only root of the image (each with a
  small overlay); a job takes at most 8 distinct images (`8192 MiB` / `8 GiB` combined). Without any `data:` services
  the image's size does not hit the disk check. Each `data:` service's own file system is 1024 MiB, or its `data_mib:`
  (16 to 3072); for a large image f+ shrinks the test's data disk and those file systems to 256 MiB at the least
  (https://staging.extrafunctional-staging.fyi/dst-services.md, Costs), and the engine's `32768 MiB` (`32 GiB`) disk must fit
  `1 + max(64, ceil64(1.3 × the image)) + 256 + min(256, ceil64(0.3 × the image)) + each data: service's (1 + min(256, its size))` MiB:
  about a `23.2 GiB` unpacked image with five `data:` services (use a multi-stage Dockerfile to keep images small and
  conversion fast). `fplus dst image push` refuses an image past it, with what it needs.
- A job shows `services`, `services_landed {svc: {kills, restarts, partitions, loss, clock_steps, power_losses}}`,
  `services_error` (an invalid file, at the check) and `clock_unavailable`. `fplus dst image push` checks the file
  before it uploads anything.

## Calls

A call's body is refused (400) with any field it doesn't take, naming the field and, when it looks like one it does, that one (`teir: this call takes no such field; did you mean tier?`): nothing sent is dropped. So is a field the job's kind doesn't use: `faults` other than on a hunt, and `test`, `image` or `command` on a job that runs its finding's own (a replay, debug or causality; a fixcheck takes an image).

| Call | `fplus dst` | Answer |
|---|---|---|
| `PUT images/{sha256}/parts/{n}` (16 MB parts; `GET images/{sha256}/parts` → `{parts: [n…]}`, those up already), then `POST images {sha256, size, parts, commit?, label?, services?}` (commit: 40 hex digits; `services: true` for an image with a services.yaml: a fault plan's `K=`, `C=` or `T=` needs it) | `image push [-env \| -go PKG \| -bin PATH \| -build [-check TEST [-force]] \| -from docker\|podman:TAG \| IMAGE.tar] [-commit C] [-label L]` (its commit: -commit; else with -build/-env/-go/-bin this checkout's HEAD; else the image's own `org.opencontainers.image.revision` label, or none) | `{image: "img_…", sha256, size, commit?}` |
| `GET images?label=L` | `images [-label L] [-json]`, `image list [-label L] [-json]` | `{images: [{image, sha256, size, commit?, label?, services?, created_at}]}`, newest first (at most 200); `label` filters to images pushed with that `-label` |
| `POST jobs {…, tier?}` (any kind) | `… -tier live\|batch\|on-demand` | optional scheduling hint (`live`, `batch`, or `on-demand`); pay-as-you-go is a single **$0.50 per core-hour** rate (Teams monthly: **$1,800/mo** for 7,200 core-hours, **$0.25/core-hour**). Shown as `tier` on the job and in `usage` |
| `POST jobs {…, idempotency_key?}` (any kind) | (fplus sends one per submit) | your own key for this submit, 8 to 64 of `A-Za-z0-9_-`: the same key sent again (a retry after a 5xx or a lost answer) answers the job it queued, with no second job or hold; the same key with another body is 409 (`idempotency_key K was sent with another submit`): give each submit its own key |
| `POST jobs {kind: "check", image, test}` | `check IMAGE TEST` | a job: one run with no faults. A hunt of an image waits for a check of it that passed, and queues one if there is none, or if the last could not run (`image-failed`, `error`, `expired`, `refused`). One that failed (`fails-without-faults`, `harness`) refuses the hunt with 409. |
| `POST jobs {kind: "hunt", image, test, faults?, budget_min?}` | `hunt IMAGE TEST [-faults disk,network] [-budget 15m]` | a job: a search under timing faults. `faults` adds kinds to the timing search, which always runs: network (netem on the test's traffic), disk (failing system calls), powercut (ext4 power cuts, without failing system calls; requires `.fplus/environment/services.yaml`), process (service pauses, kills, and restarts; requires `.fplus/environment/services.yaml`); thread, timer and clock are the timing search itself (CPU steals and pauses). On an image with `services.yaml` the same words also draw faults between its services: process kills (`K=`) and restarts as well as pauses (`P=`), network partitions, clogs and one-way loss (`N=`, `O=`), clock steps (`T=`), disk power loss of a service with `data:` or of the machine (`L=`, `C=`). `exclude_faults` (`-exclude-faults`) leaves kinds or patterns out (`syscall`, `corrupt`, `fsync:EIO`). `fault_tolerance` (`-fault-tolerance none|legacy|resilient|high_availability`) sets an Antithesis fault-tolerance preset with zero injected syscall errnos (cannot be combined with explicit `faults` or `all_faults`). `fault_exclusions` (`-fault-exclusions REGEX`) excludes matching compose/services container names from container-scoped faults. `load` (CPU contention) is not live yet: our machines drop it, so it is refused; a kind our machines don't run today is refused when the job is queued. The budget is 5 to 240 min, 15 by default; a rare flake (a few failures a month in CI) often needs 60–120 min, and a 15–30-min hunt suits a first look. Each hunt is its own search: queue several of one test to search in parallel, each on its own VMs (10; see **Guest**; a hunt is charged at most its budget × those VMs). |
| `POST jobs {kind: "replay", finding, job?, schedule?, name?}` | `replay FINDING [-job JOB] [-schedule found\|TEXT] [-image IMG] [-name NAME]` | a job: the finding's smallest failing schedule, run again on its own image. `job`: the find to use (`fplus dst finding` lists them); default the original find while its image is kept, else the oldest find whose image is. `schedule`: `found` replays the schedule it was found with (does it fail on its own, unshrunk?), or give one schedule line with `\| run`. With `-image`, it re-confirms on that image by searching nearby schedules (the fixcheck search), without claiming a fix; `-schedule` and `-image` cannot be used together. |
| `POST jobs {kind: "fixcheck", finding, image, job?, budget_min?, reconfirm?}` | `fixcheck FINDING IMAGE [-job JOB] [-budget 20m]` | a job: the finding made to fail again on its own image, then its schedule replayed on IMAGE and a search near it. `job`: the find to use (`fplus dst finding` lists them); default the original find while its image is kept, else the oldest find whose image is. The fix's image must run the test exactly as the hunted one did: the same runner, verify.sh and command, with only the fix changed. `reconfirm: true` is the `replay FINDING -image IMG` form: it searches nearby schedules on that image without claiming a fix, and it never marks the finding fixed. |
| `POST jobs {kind: "debug", finding, at, in?, script, files?, job?}` | `debug FINDING -at 45.9s[,failure-2s] [-in SVC] [-file PATH]... -- CMD` | a job: `script` run at each moment of the finding's run, on a fresh branch of it ([Debugging a finding](#debugging-a-finding)). Until f+'s machines run debug jobs, one is refused at submit (400). |
| `POST findings/{f}/report {job?, cause?, patch?}`; `GET reports`; `DELETE reports/{id}` | `share FINDING [-job FIXCHECK] [-cause TEXT] [-patch FILE]`, `fixcheck FINDING IMAGE\|-build\|-env\|-go PKG\|-bin PATH -proof`, `share -list`, `share -revoke ID` | a read-only proof at `exfun.app/r/{id}`, no login needed, until revoked: the finding's test, failure, smallest failing schedule and its faults in words, where the failure is decided (its newest causality's largest jump), the team's `cause` (4 KB) and the fix's `patch` (256 KB), and the fix check (`job`, ended or not, else its newest) with the failure rate before, the nearby schedules that pass after, a `Verification:` line to paste once fixed, and what the evidence cost; nothing of the team. `fixcheck -proof` includes the fix diff: unless given `-patch FILE`, the CLI diffs the current checkout against the finding's image commit (HEAD if unknown or unavailable locally), adds untracked files except gitignored files, untracked `.fplus/` files, unreadable files, binaries (a NUL in the first 8 KiB) and files over 256 KiB, and includes tracked `.fplus/` changes. Outside a git checkout, supply `-patch FILE`. It refuses an empty diff and omits a diff over 256 KiB, so the check cannot say "Fix verified". Made while its fix check runs, it says so and refreshes until the verdict. A patch shared after a done fixcheck that returned `FIXED_UNREVIEWED` for `diff_unseen` returns `late_diff: "sent for review"` and submits the diff to be read for test changes without another run or charge: it can only lower the verdict (test or harness edits), never upgrade it to FIXED, as nothing ties it to the image that ran; the review queue is private to f+ admins and is not a public API. A private team makes none (403) |
| `GET links`; `PUT links/handle {handle}`; `PUT links/apps/{slug} {app, private?}`; `DELETE links/apps/{slug}` (its viewers too); `POST links/apps/{slug}/viewers {login}`, `DELETE links/apps/{slug}/viewers/{login}` | `codemode -links`, `-handle NAME`, `-slug APP NAME [-private]`, `-slug-rm NAME`, `-viewer APP add\|rm LOGIN` | `{team, handle?, apps: [{slug, app, private, viewers, url}]}`: the team's stable app links, `exfun.app/{handle}/{slug}` (code mode, beta); a handle taken is 409, reserved or malformed 400, a private app's viewer 400 |
| `GET triage`, `POST triage {on}` | `triage [-on \| -off]` | `{team, triage}`: the automatic triage of new findings, on unless turned off |
| `POST jobs {kind: "causality", finding, job?, points?, runs?, budget_simulation_hours?}` | `causality FINDING [-points 12] [-runs 12] [-simulation-hours N] [-job JOB]` | a job: the finding's failure probability over guest time ([Causality](#causality)). On the finding's own image, with its command and RAM. `budget_simulation_hours` (default: sized from the find's test length, about points × runs × 0.7 probes of 2.5 runs each, at least 1, at most 25; a 4-minute test is about 8) is its `max_simulation_hours`; the job's `plan` shows `estimate_simulation_hours` and `test_s`. Credit that can't hold it is a 402 naming the number. |
| any job above, with `memory_mib` | `-memory MiB` (check, hunt, replay, fixcheck) | a job whose VMs get that much RAM each (below) |
| any job above, with `vcpus` | `-vcpus N` (check, hunt, replay, fixcheck) | a job whose VMs get N vCPUs each: 1, 2 (the default) or 4 (below) |
| a hunt, with `vms: N` | `-vms N` | a hunt that runs on at most N VMs at once (1 to 10; default 10), to pace spend: its hold (`held_simulation_hours`, N × `budget_min` / 60, matching its charge cap; `max_simulation_hours` keeps the margin for shrinking) is for N; the job shows `vms`. When `vms` is omitted, an idle host may elastically burst past 10 VMs (`guest.vms > 10`) while still capping the charge at the 10-VM quote |
| a hunt, with `stop_at_first: true` | `-stop-at-first` (the CLI sends it on an image's first hunt unless `-full`) | a hunt that ends at its first failing schedule, then confirms and shrinks it and files the finding, rather than searching its whole budget; charged for what it ran (refused, 400, if a machine doesn't run it) |
| a check or hunt, with `group: true` | `-group` | `test` is a group of tests, the runner's own filter ([A group of tests](#a-group-of-tests)) |
| `GET jobs/{job}?wait=30` | `status JOB [-watch \| -wait]` | a job, held up to 30 s until it changes (`-watch` / `-wait` print live deduplicated progress and a `FIRST FAILURE:` callout); done, `status` also lists its properties (violated, never reached, never true; passing ones when few) |
| `GET jobs/{job}/result` | `status JOB -json` (its `result`, once done) | the result (below), once the job ended |
| `GET jobs/{job}/result`, `GET findings/{finding}` of each | `status JOB -md` | a done job's triage report in markdown: the job, every property, and each finding's rate, smallest schedule, failure, console, triage excerpts and the commands that go on |
| `GET jobs/{job}/logs` | `logs JOB [-all] [-o FILE]` | the job's consoles, gzipped; the CLI extracts and prints the run summary's line when the engine itself ended the run (a boot that never reached the test: our side), then the failing console tail (last 200 lines), straight to stdout (`-all` for full log, `-o logs.tar.gz` to save the archive) |
| `POST jobs/{job}/start` | `start JOB [JOB...]` | confirm and release a waiting hunt held because its check passed with a never-true `sometimes` / `reachable` property (or pass `start_anyway: true` / `-start-anyway` on `hunt` to bypass the hold) |
| `POST jobs/{job}/stop` | `stop JOB`, or `stop -test TEST [-yes]` | the job, stopped; `-test` lists every waiting or running job of the test by its exact full ID and stops it at once only when it is one job of your own (`mine`), else only with `-yes` |
| `GET jobs?since=7d&label=L&limit=N&before=C` | `jobs [-since 7d] [-label L]` | `{jobs: [job…], next_cursor?}`, newest first (up to `limit` 1–1000, default 1000; pass `before=next_cursor` for the next page); `since` (here and below) is a span, `7d`, `2h` or `30m`, or an ISO time; `label` keeps those of images pushed with that `-label` (a repository's name, say); `findings` and `images` take it too |
| `GET usage?since=30d` | (none: `report [-since 7d]` reads `GET jobs`) | `{jobs: [{job, kind, test, image, tier, seconds, simulation_hours, cost_usd, ended_at}], simulation_hours, cost_usd}` |
| `GET whoami` | | `{team, login, github_id, token?: {name, expires_at}}`: who calls, and the DST token if it is one |
| `GET coverage` | `coverage` | `{tests: [{test, state, image, at, simulation_hours, searched_simulation_hours?, void_simulation_hours?, finding?, replayed?, fixcheck?}]}`: each test's state: reproduced, fix verified, searched (non-void hunts; all-void tests stay `never hunted` with `void_simulation_hours`) or never hunted |
| `GET /v1/dst/sample` (no sign-in) | `sample` | a real flake f+ DST found and fixed (Consul's TestClient_LANReap, a CI flake; its fix is to the test), from its recorded results: `{repo, test, source, fix (its proof page), failure, cause, minimal_schedule, faults [{text}], replays, rate_before_pct, nearby_pass, verdict, fix_kind? (test or code, when verified), verdict_reason?, causality?, cost_usd}` |
| `GET credits` | `credits` | `{balance_simulation_hours, balance_usd, held_simulation_hours, available_simulation_hours (batch), welcome_usd, team_usd, own_credit_only?, token_scoped?, grant_simulation_hours, grant_usd, prices {on_demand_usd_per_simulation_hour, live_usd_per_simulation_hour, batch_usd_per_simulation_hour, included_ram_gib, ram_usd_per_gib_hour (live tier: tier_price / 10 above included_ram_gib; every tier scales proportionally with RAM past 10 GiB)}, storage: {images, used_gb, free_gb}, limits: {tier, core_hours_today, core_hours_per_day, max_concurrent_vms, images_24h?, images_per_day?}, team_spent_usd, team_spent_today_usd}`: `limits` are the daily limits and what the team used of them (core-hours of the jobs that ended this UTC day; new images pushed in the last 24 hours); `welcome_usd` is the person's grant left, across all their teams, not this team's spend; `grant_usd` is the account's initial welcome grant (`0` if none); `team_usd` the team's own credit; `token_scoped` is `true` when authenticated with a team-scoped DST token (`dstt_…`), which only accesses this team; `team_spent_usd` what this team's jobs and asks cost in the last 30 days (`team_spent_today_usd` today, UTC) |
| `POST credits/redeem {code}` | `credits redeem CODE` | `{team, code, usd, balance_usd, available_usd, team_usd}`: redeem a launch/promo credit code onto the team's ledger (once per team and once per GitHub account; expired, already-used, or exhausted codes are refused; f+'s own teams pay nothing: 400) |
| `POST credits/checkout {usd}` | `topup USD` | `{team, usd, url, reference, then}`: Stripe's hosted page to buy `usd` (25 to 500, whole dollars) of credit for the team; a person opens `url` and pays, and the credit is added once Stripe confirms it (`credits` shows it). A DST token can call it; f+'s own teams pay nothing (400) |
| `GET credits/payments` | `payments` | `{team, payments: [{kind: top-up\|refund\|payment (MPP)\|granted by f+\|taken back by f+, usd, reference, at, team_credit_after_usd, note}]}`: the team's paid top-ups and refunds, and f+'s grants and what it took back of them (with why, in `note`; never paid credit or what the team spent), newest first (at most 50): `reference` is the Stripe checkout's ID that `topup` printed (`cs_…`), `team_credit_after_usd` the team's own credit just after it (not the person's grant). A checkout not paid yet isn't listed |
| `POST credits/topup {usd}` | | buy `usd` of credit (0.50 to 500) over MPP (f+'s own teams pay nothing: 400): a 402 with its challenge, then, paid, `{team, usd, credited_usd, balance_usd, reference, payment_intent?, method}` with a `Payment-Receipt` ([Paying with MPP](#paying-with-mpp)) |
| (client side) | `report [-since 7d] [-format md\|csv\|json]` | each job's outcome, test, image, cost and findings; `md` is a one-page summary |

**A job** is `{name, job, kind, state: waiting|running|done, image?, test, group?, finding?, command?, fault_plan?, fault_plan_used?, quiet_dropped?, faults?, faults_not_run?, memory_mib?, queued_for?,
live?, progress?, running_at? (when f+'s machine began the job: the wait is queued_at to here), outcome?, never_true_sometimes? (IDs of `sometimes`/`reachable` properties never true in a done check/hunt), held? (`true` while a waiting hunt is held for confirmation), held_check?, held_properties?, findings?, logs?, tier, max_simulation_hours, held_simulation_hours, held_usd, isolation? ("ran on a host with no other customer", when the scheduler says so), meter?, cost_usd (0 until it ends), queued_at, control_job?}`. A replay or fixcheck
that named a find of its finding (`job`) says which in `control_job`. A check a hunt queued says which in
`queued_for`. A free rerun of a job that failed on our side is a new job with `rerun_of` (the original's ID) and `rerun_why`, charged nothing; the original keeps its result. When the scheduler reports them, `faults_landed_in_run {in_window, total, void_schedules}` and `window_coverage {from_branch, to_branch, of_branches, share}` say whether the faults reached the test; a search none of whose faults reached it is `void: true` with the reason "void: faults never reached the test": it proves nothing either way, unlike nothing-found. `exercised {schedules, faults_drawn, faults_landed, distinct_fingerprints_min, failed_blind, failed_natively}` says how much a hunt exercised its test: schedules run, faults drawn and those that acted inside it, at least how many distinct outcomes it saw, runs that failed from timing alone, and whether the test ever failed with no fault (`null`: unknown); a fixcheck's nearby search has `{schedules, failures}`. `faults` are the kinds a hunt asked for; `faults_not_run` lists any the machines could not run, so the search ran without them. A running search has `progress {schedules, failures, runs_per_min, first_failure?}`, refreshed each minute (`first_failure {provisional_id, arm, fingerprint?, test?, error?, schedule?, seen_at}`: the first failing schedule a hunt kept, before it is filed); a running fixcheck's also has `phase` (control, baseline, replays, then nearby) and, nearby, `near_total` (the schedules it plans: the 95 % count, or every distinct timing when fewer exist) and `needed` (the 95 % count), with its `live` line saying the phase in words. `waiting`: not running yet: queued with us (its `live` line says how many jobs f+'s machines take first: checks, replays and fixchecks before hunts, oldest first, some teams' jobs ahead by arrangement), or on an f+ machine still queued for a VM or building
its image there (its `live` line says which, e.g. "queued, next in line"); `running`: its VMs are running it. Only
VM time is charged, never time in either queue.
Stopping the last hunt waiting on such a check stops it too, and a stop's answer lists in `stopped`
every job it stopped. `findings` are the IDs of the findings it hit (filed, found again,
replayed or fixchecked: `fplus dst finding ID`); `finding` is the one a replay or fixcheck is of. A job that
stays `waiting` for 24 h, never taken by f+'s machines, ends `done` with outcome `expired` and a `reason`, costs
nothing, and gives back what it held; queue it again. A hunt waiting on its check counts from its own queue time.

**Guest:** a job shows `guest {vms, vcpus_per_vm, memory_mib}`.
- **VMs:** a check, replay or debug runs on 1, a fixcheck or causality on 2, a hunt on 10. A hunt gets fewer when its
  memory leaves a machine room for fewer, and up to 30 when a machine is free; its search is then shorter, so it uses
  about the same VM-hours. `guest.vms` is the count at the end, `meter.vm_hours` what all its VMs ran, and
  `meter.average_vms` that spread over the run's wall time.
- **vCPUs:** 2 per VM unless the job gives `vcpus` (1, 2 or 4). The search varies how the threads interleave on them;
  there is no preemption knob. The price counts VMs, hours and RAM, not vCPUs (**Credits**).
- A hunt waits for a check that passed, at any vCPU count (a failure at a different count is not its verdict). A
  replay, fixcheck, debug or causality uses its finding's vCPUs unless it gives its own.

**Memory:** `memory_mib` is each VM's RAM: 2048 to 32768 MiB in steps of 512, 4096 if omitted. A core-hour includes
up to 10 GiB; above that, the price scales with the RAM (**Credits**). A check that a hunt queues gets the hunt's memory,
and a hunt waits for a check at its own memory. A replay, fixcheck, debug or causality uses its finding's memory unless
it gives its own.

An error is `{error}`, a sentence saying what to do. A job that may use more than your credit left is refused with
402 before it runs.

## The result

A job's `result` (`status JOB -json`, once done) is the result as f+'s machines gave it, `"schema": "result-v1"`:

- **The verdict:** `receipt`, schema `verdict-receipt-v1`: `id`, `verdict` (FOUND, NOTHING_FOUND, REPRODUCED, FIXED, FIXED_EXACT,
  FIXED_TEST_MODIFIED, FIXED_UNREVIEWED, UNDERPOWERED, STILL_FAILS, NEW_FAILURE, INCONCLUSIVE, REFUSED, UNEXERCISED, INFRA_ERROR,
  HOST_INTERFERENCE: a replay or fix check not compared because the host took an SMI during the run (reason
  `smi_during_run`; `smi_unknown` says whether one happened is unknown), retry or run on another host; our host's fault, so charged nothing (refunded if it was charged), ...),
  `reasons [{code, text}]`, `evidence`, `power {seen, searched, lower_bound, needed, ran, at_lower_bound}`, `digests`
  (command, image, oracle, fix diff), `supersedes`. It is the only verdict: `outcome` is its projection, and the job
  view's `verdict` / `verdict_reasons` show the receipt that stands now (a reopen supersedes a fix check's FIXED;
  `outcome` then reads `withdrawn`). Only FIXED ("Fix verified") and FIXED_EXACT ("Fixed on exact schedule") settle a finding to fixed: a fix whose diff edits tests, assertions or the
  harness is FIXED_TEST_MODIFIED at best, and one whose diff was not sent (`fixcheck FINDING IMAGE` without `-patch`)
  FIXED_UNREVIEWED at best.

- **Every verdict**, the job kind that gives it and the `outcome` it projects to (jobs/tests/test_docs_verdicts.py
  keeps this list whole):

  | verdict | kind | outcome | means |
  |---|---|---|---|
  | FOUND | hunt | `found` | a failure under faults, filed as a finding |
  | NOTHING_FOUND | hunt | `nothing-found` | no failure in its budget |
  | FAILS_WITHOUT_FAULTS | check, hunt | `fails-without-faults` | the test fails with no fault at all: not a timing bug |
  | HARNESS_ERROR | check, hunt | `harness` | the test did not run as written (no test ran, the recipe or the runner failed) |
  | PREFLIGHT_PASSED | check | `passed` | the test runs and passes with no faults |
  | REPRODUCED | replay, reproduce | `replayed` / `reproduced` | the finding's schedule (or CI's flake) fails again the same way |
  | UNPROVEN | reproduce (a CI flake) | `unproven` | a failure that replays, but CI's error is too generic to prove it is CI's |
  | NOT_REPRODUCED | replay | `not-reproduced` | the schedule passed this time |
  | FAILS_OTHERWISE | replay | `replayed` | the schedule failed, in another way than the finding |
  | NONDETERMINISTIC | replay | `replayed` | the replay diverged from the finding's run (another fingerprint) |
  | HOST_INTERFERENCE | replay, fixcheck | `replayed` / `inconclusive` | not compared: the host was interrupted during the run (our side, free) |
  | FIXED | fixcheck | `fixed` | fix verified |
  | FIXED_EXACT | fixcheck | `fixed-exact` | exact failing schedule failed on the control and passed on the fix (nearby schedules did not reproduce) |
  | FIXED_TEST_MODIFIED | fixcheck | `fixed-test-modified` / `inconclusive` | the fix changes the test (or the harness, the oracle): review it |
  | FIXED_UNREVIEWED | fixcheck | `not-reproduced` | it passed, but the fix's diff was not sent: not verified |
  | UNDERPOWERED | fixcheck | `not-reproduced` | it passed in too few schedules for 95 % confidence (`weak: true`) |
  | STILL_FAILS | fixcheck | `still-fails` | the fix still fails |
  | NEW_FAILURE | fixcheck | `new-failure` | the original failure is gone, but a distinct new service crash/error is behind it (`control_crash`, `fix_crash`); the finding stays open |
  | INCONCLUSIVE | fixcheck | `inconclusive` | the fix check could not judge it |
  | REFUSED | fixcheck | `inconclusive` | the fix's image runs another command than the finding's |
  | NEEDS_REFIND | fixcheck | `needs-refind` | the finding is from an older engine: hunt its test again to find it on the current one |
  | ANALYZED | causality | `analyzed` | the failure's probability over guest time |
  | NOT_REPLAYED | causality | `not-replayed` | the finding's schedule no longer fails the same way on its image |
  | COMPLETED | debug | `debugged` | the moments were read |
  | PERTURBED | debug | `perturbed` | the probes changed the run's fingerprint: their output was discarded |
  | REOPENED | finding | (its fix checks: `withdrawn`) | the finding was reopened: its fix checks no longer stand |
  | WITHDRAWN | finding | (its fix checks: `withdrawn`) | f+ withdrew a fix check's verdict |
  | INFRA_ERROR | any | `error` | our machines could not run it (free) |
  | UNEXERCISED | any | `inconclusive` | it exercised nothing: not one valid run |
  | CANCELLED | any | `cancelled` | stopped |
  | SKIPPED | any | `skipped` | not run |

- **Every result:** `job` (this job's ID), `mode`, `outcome`, `reason`, `meter` (the job's: `{vcpus, seconds, vm_hours, simulation_hours, vms?, average_vms?, convert?, refunded?}`, below under **Charging**),
  `stages`, `machine_s`, `memory_mib` (each VM's RAM as it booted), `guest_touched_mib` (the most guest RAM any run wrote,
  zero-filled pages included: size `memory_mib` above it), `guest_resident_mib` (what held data once zero-filled pages
  were dropped: not a sizing guide), `baseline_s` (the no-fault run's test time), `schedule_wall_s` (one schedule's measured wall seconds on one machine, boot included: what a fixcheck of its finding is sized from), `logs` (their size; `fplus dst logs`) and `engine` (the engine build).
  A job shows them as `memory {touched_mib, resident_mib}`; `fplus dst status` says "needs N GB (touched), holds M GB
  after zero-dropping". A guest that runs out says so in `reason`.
- **Outcomes, by kind:**
  - check: `passed`, `fails-without-faults`, `harness`, `image-failed`;
    A check whose runner ran no test ends `harness` even if the test command exited 0, with a reason pointing to the test name or filter.
  - hunt: `found`, `nothing-found`, `cut-short` (its search ran under half its budget because our machines could not run it; free, like `error`), `check-failed` (the check it waited for didn't pass, so it never ran: free, its `reason` names the check);
  - fixcheck: `fixed` (`deterministic: true` for a finding that fails with no faults: its schedule failed every run unfixed and passes every replay on the fix, which needs no nearby search; `was` is the scheduler's own verdict), `fixed-test-modified` (the fix changes only the test, its receipt FIXED_TEST_MODIFIED: `says` "Fixed (changes the test): review the test change"; the finding stays open, and a fix that changes the harness or the oracle ends `inconclusive`), `still-fails`, `new-failure` (original service crash/error is gone, but a distinct new service crash/error appeared behind it on the fix: `control_crash` and `fix_crash` name both lines; the finding stays open), `inconclusive`, `not-reproduced` (`weak: true`: it passed, but in fewer schedules than the finding's own failure rate needs for 95 % confidence; the finding stays open, see `reason`, `confidence` (0 to 1) is what the schedules it ran give, and `needs_budget_min` is the `-budget` that would reach them).
    A fixcheck is sized at submit from its finding (the test's length, and its rate at a one-sided 95 % lower bound, as its verdict sizes it): with no `budget_min` it gets the core-hours a 95 % verdict needs, at most what the team's per-job cap, daily cap and credit allow (`sized {budget_simulation_hours, needs_simulation_hours}` and `max_simulation_hours` say so, and `budget_note` when a cap or the credit cut it, down to 0.05 core-hours). Its `quote {why, minutes, vms, nearby, chance}` says why it is that size ("3 failures in 100 schedules: proving a fix needs ~365 nearby runs"), its minutes on its VMs, the nearby schedules that fit, and the chance they show the failure again were it not fixed (0.95 or more: a 95 % verdict). A `budget_min` over a cap is refused (402) with the largest budget that fits and that chance, and a `budget_min` too short for one nearby schedule after the control, baseline and replays is refused (400) with the budget it needs. A fixcheck's `budget_min` is a hard limit on its nearby search; `searched_min` is the minutes it searched, and
    `near {schedules, failures, needed, distinct}` what that search ran. A group finding's fixcheck lists other tests of the group that failed nearby in `other_tests_failed [{test, signature, schedule}]`: each is its own finding, never this one's verdict (the proof page lists them apart). `fixed` with `weak: true` and
    `exhausted: true` means fewer distinct timings exist near the finding than 95 % needs, and every one of them ran
    and passed: the finding is marked fixed, with no `confidence` figure (see `reason`). Any `fixed` with `weak: true`,
    exhausted or not, marks the finding fixed but not verified (coverage: "fix not yet verified");
  - replay: `replayed` (with `fp_match`, `reproduced`, the engine's `oracle_verdict` (OK or VIOLATION; the job's
    `verdict` is its receipt's), and `fp_reason` when the fingerprint differs), `image-gone`; the job says its verdict in
    words (`says`), the replay that gave a finding with no fingerprint its reference says `set_reference`, and a replay of another schedule than its reference (`-schedule`) says `fingerprint_compared: not compared …` (no difference, no nondeterminism) and never sets or counts toward its fingerprint or replays;
  - debug: `debugged` (with `moments`), `diverged`, `image-gone`;
  - causality: `analyzed` (with `causality`; a `reason` when the budget ran out first), `not-replayed` (the finding's
    schedule no longer fails the same way on its image), `image-gone`;
  - any job: `error`, `cancelled`, `refused`, `expired` (no machine took it within 24 h). A fixcheck or replay that
    ends `error` at its wall cap has `partial`, what it showed before it stopped: `{control?, baseline?, replays?,
    near?: {ran, failures}}`, a key for each phase that ran.
- **No result:** a job stopped while still waiting (`cancelled`) or never taken (`expired`) has none: `GET jobs/{job}/result`
  answers 404 with why, and the job itself says its outcome and `reason`. One stopped once a machine had it has a
  `cancelled` result.
- **Each finding:** `name`, `signature`, `fingerprint`, `replays`, `schedule`, `minimal_schedule`, `error`,
  `image {sha256, epoch}`, `explanation`, and `rate {runs, failing_runs}` with `rare` (failing in under a third of
  runs: "seen in 3 of 412 runs").
- **A finding's image is kept:** never deleted while the finding is open, and for 3 days after a fixcheck closes
  it, on our machines or in our archive, checked by its sha256. Replays, fixchecks, causality and debug fetch it
  back wherever it is. `image-gone` only when no copy with that sha256 exists anywhere; such a finding says so
  (`image.missing`) and its re-hunt is free.

## Properties

A hunt, fixcheck or check whose runs carry assertions answers `properties`: use the thin zero-dependency f+ annotation
SDK (`sdk/{csharp,go,python,rust,typescript,java}`: `always`, `sometimes`, `reachable`, `unreachable`, `setup_complete`,
`send_event`; reads `FPLUS_DST_SDK_OUTPUT` first, falls back to `ANTITHESIS_SDK_LOCAL_OUTPUT`, no-op when neither is
set) — Antithesis SDKs work unchanged too, and our own defaults apply to every test. At most 200 (`properties_dropped`
counts the rest; passing ones go first):

    {id, kind: always|always_or_unreachable|sometimes|reachable|unreachable|eventually, message,
     source: sdk|catalog|default, status: ok|violation|not-exercised|not-reached, verdict, runs, runs_passed,
     runs_failed, first_failure?: {details, schedule}, finding?: "property:<id>", last_seen_job?}

- Without an SDK: a test appends one JSON line per evaluation to
  `$ANTITHESIS_SDK_LOCAL_OUTPUT`, as the SDKs write it: `{"antithesis_assert": {"hit": true, "must_hit": true,
  "assert_type": "always"|"sometimes"|"reachable"|"unreachable", "display_type", "message", "condition": true|false,
  "id", "location": {...}, "details": {}}}`. Measured: a check of a shell test that wrote two such lines listed both
  (`SDK records: 2 delivered`).
- `runs_*` count runs, not evaluations; one run can count in both. The SDK reports each assertion once per process
  per run.
- `violation` files a finding (`signature: "property:<id>"`, `property`, `details`; its `error` is
  `VIOLATION assertion <id>`). `not-reached` is an always or eventually assertion seen before (`source: catalog`,
  `last_seen_job`) or declared but never evaluated in this job; `not-exercised` a sometimes or reachable one never
  true.
- Defaults (`source: default`): `dst.commands_exit_zero`, `dst.no_unexpected_container_exits` (exit other than 0, 137,
  143), `dst.no_unexpected_crashes` (SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGABRT), `dst.all_commands_started`,
  `dst.all_commands_completed`, `dst.sdk_records_delivered` (a record over 2,000 bytes or past 1 MiB a boot is lost),
  and `dst.peak_memory` (informational, always ok).
- `records {delivered, lost, lost_reasons {too_long, budget, other}}` says how many SDK records arrived.
- `fplus dst status JOB` groups them as Antithesis's triage report does (violated, never reached, never true,
  passing); `status JOB -md` is the whole table with each finding's evidence. Not yet in either: several examples per
  property, a search across every run's logs, a property's history across jobs.

## Debugging a finding

A debug job brings a finding's failing run back to moments you name and runs your script there, inside the guest. The
run is the finding's `minimal_schedule` on its own simulator image, replayed exactly, so every moment holds what the
failing run held.

- **`at`:** 1 to 4 moments (a list, or one string with commas): a guest time (`45.9s`, `46000ms`, on the clock of the
  finding's explanation), `failure`, `failure-10s` or `failure+1s`, `fault:3` or `fault:3+100ms` (the third fault the
  engine applied), `stop:7650`, or `end`. A time lands on the first stop of the run at or after it, within a few
  milliseconds; `landed {point, stop, ns}` says where.
- **`script`:** a shell script, at most 64 KB, run with a 60 s guest-time limit. `in` runs it in that service's network
  namespace; `host` (or none) runs it in the guest's own.
- **A fresh branch for each moment.** Killing a process (`kill -ABRT` for a core), taking a node down or deleting files
  never touches the reproduction: the next moment, and the next job, start from the recorded run again. The moment
  where the run ended (`failure`, `end`) is replayed live rather than restored from a snapshot; it is just as exact.
- **`files`:** up to 16 absolute paths in the guest (directories too), read after the script, 8 MB compressed per
  job. They come in the job's logs (`fplus dst logs JOB`; `fplus dst debug` writes them to `JOB-files.tar.gz`) under
  `files/<n>-<moment>/<path>`, and each moment lists `files [{path, bytes, sha256}]` and `files_missing`.
- **Guest paths and full service logs:** inside the guest, full service stdout/stderr logs live at
  `/tmp/fplus-dst/<service>.log` and per-service clock offset files live at `/tmp/fplus-dst/clock/<service>`. Because
  `fplus dst logs <job>` truncates per-service logs to the last 64 KiB, use
  `fplus dst debug FINDING -at <t> -file /tmp/fplus-dst/<service>.log -- tail -n 100 /tmp/fplus-dst/<service>.log`
  to inspect earlier timestamps in long runs.
- **The same request gives the same bytes.** A debug job's answer is a function of the finding's image and schedule,
  the moments, the script, `in` and `files`. The same request again is answered from the first result (`cached`, free).
- **The result:** `{outcome, finding_job, schedule, fingerprint, moments: [{at, landed, state: snapshot|live, status,
  stdout, stderr, stdout_truncated, state_fp, files, files_missing, error?}]}`. `stdout` and `stderr` keep 256 KB each.
  `state_fp` fingerprints the guest's whole state after the script. A run that does not come back as recorded ends
  `diverged`, never with output; a finding whose image is no longer kept ends `image-gone`.
- **Cost:** a debug job reserves 1 VM for at most 15 min (`max_simulation_hours` 1.25), and
  charges what it used: about one replay up to each moment, plus the script. A small test takes seconds a moment; a
  12 GiB guest took 1.5-2 min to reach 46 s and run two scripts there.

**Automatic triage.** Each new finding a hunt confirms is replayed once more at `failure-10s` and at `failure`, with a
built-in script: every process and thread with its state, kernel stack and wait channel, the sockets, and the tails
of the logs under `/tmp` and `/var/log`. Then the image's own `.fplus/triage/*.sh`, run from its `WORKDIR`. The output is
in the finding's `explanation.triage {outcome, moments: [{at, landed, state, default, customer?}]}` (12 KB a script).
It runs inside the hunt and is charged with it: about one replay per new finding (the replay to 10 s before the
failure, then the run to its end), measured at 19 s ($0.003) on a 0.3 s Go test and estimated at about 7 min ($0.06)
on a 12 GiB test that fails after 90 s. Turn it off for the team with `fplus dst triage -off` (`POST triage {on: false}`).

## Causality

`fplus dst causality FINDING` asks where the failure is decided. Each probe replays the finding's own run exactly up
to a moment t, then runs on with fresh faults drawn from the hunt's own mix (blind stolen time) after t. The share of
probes that fail with the finding's signature is P(t). Probes sit at t=0, just before and just after each fault the
finding applied, at the failure, and at uniform points between, up to `points`. A point stops at 0/6 or 6/6, and
otherwise runs to `runs`. One more round adds a point midway wherever P changes by 0.3 or more. Probes stop when the
job's core-hours reach `budget_simulation_hours`.

The result's `causality` is `{points: [{t, b, runs, failures, other, p}], jumps: [{from_t, to_t, from_b, to_b, delta,
from_p, to_p, faults: [{kind, text, token, t, b}], log_excerpt, log_note?}], failure {t, b}, faults, dead_faults, suffix,
plan, cost {probes, core_hours, budget_core_hours, capped}}`. Here `core_hours` and `budget_core_hours` are the
scheduler's vCPU-hours (2 vCPUs a VM), so the billed core-hours are half of them:

- `t` is guest seconds since boot and `b` guest branches, the exact replay position. `other` counts probes that
  failed another way.
- A jump is where P moves by 0.3 or more. It lists the faults the finding's run applied in that window, and that run's
  console lines stamped there. A jump with no fault means the run itself decides the failure there. The faults earlier
  only picked the path, and the window's log says what happened.
- `dead_faults` are schedule faults that never applied (after the run ended).
- `status JOB -wait` prints the curve and each jump.

Cost: the default plan is about 70 to 150 probes, roughly 0.75 core-hours for a test of about 20 s. A test of several
minutes needs more: a 4-minute test needs about 8 core-hours for the full plan. With less, the curve
comes back partial (`cost.capped`, and a `reason`), with its fault edges first and fewer uniform points.

## Logs

`logs JOB` writes a job's consoles to `JOB-logs.tar.gz` (`-o FILE`), from `GET jobs/{job}/logs` (`application/gzip`):
every run's guest console and engine log (the no-fault run, the search's arms, shrinks, replays), at most 20 MB
gzipped and 256 MiB unpacked, the earliest runs kept if there is more. Per-service logs in the archive are truncated to the last 64 KiB; for earlier
timestamps in long runs, read `/tmp/fplus-dst/<service>.log` with
`fplus dst debug FINDING -at <t> -file /tmp/fplus-dst/<service>.log -- tail -n 100 /tmp/fplus-dst/<service>.log`.
They come when the job ends; a job has `logs {bytes, files}` once they are up,
and a job with none answers 404 with why. Logs expire with the job's results.

## Findings

Each distinct failure a job's result reports is a finding of the team's, filed once: a check that fails with no
fault, a hunt's finds, a replay's. One found again (the same test, and the same signature, fingerprint or failure
line) is noted on the finding filed first, and a fixed one found again is open again. A harness summary
(`rc=1 ran=1 failed=1 …`) is not matched on, only its fingerprint, as it doesn't say which failure it was; a run's
`cold.test_passes` find beside another is that same failure, not a second finding; and a run in which no test ran
files none (its `reason` asks whether TEST is the runner's name for it).

| Call | `fplus dst` | Answer |
|---|---|---|
| `GET findings?since=7d&label=L&image=IMG` | `findings [-since 7d\|ISO] [-label L] [-image IMG]` | `{findings: [finding…]}`, newest first; `since`: changed since (default: all); `label`: images pushed with that `-label`; `image`: `img_…` or sha256 prefix |
| `GET findings/{finding}` | `finding FINDING` | a finding, with `jobs: [{job, how: found\|again\|replay\|fixcheck\|causality, outcome?, note?, at}]`, `bit_for_bit_replays` (the engine's replays of its find) and `replay_jobs` (replay jobs run on it) |
| `GET findings/{finding}/brief` | `brief FINDING` | the bug brief, to write a test aimed at the bug's mechanism that fails on the unfixed code and passes on the fix: `{finding, name, status, test, image, failure: {test, error?, signature?, location?}, mechanism?, schedule?, faults: [{text}], replays, decisive?: {job, text, window?: {from_s, to_s, faults}}, next: [step…]}`; `decisive` is the newest causality job's largest jump (none run: `next` says how); only what the finding's and its jobs' pages show |
| `GET /v1/dst/findings/{finding}` (no team in the path) | `finding FND`, `replay FND`, … without `-team` | a finding by its whole ID, with `team`, for anyone who may read that team (404 for anyone else, never naming the team); fplus then runs the command in that team |
| `POST close {confirm: TEAM, now?: boolean}`; `GET close`; `POST reopen` | `team close -confirm TEAM [-delete-now]`, `team reopen` | close the DST team: new jobs are refused at once, data stays readable to export for 30 days, then its live DST data (jobs, findings, images, logs, reports, tokens, etc.) is deleted and host/S3 purge is queued. `reopen` undoes the closure before deletion is due. With `now: true` (`-delete-now`), live DST data is deleted before the reply, with no grace period or reopen; requires the team's admin signed in (`fplus login`): a DST token and a member who is not the admin get 403, for close, close now and `reopen` alike. If the live purge fails after the closure is accepted, 503 says deletion will continue in the background and cannot be undone; use `GET close` to check its status. Exact team name required in `confirm`; at most 5 closure attempts per team per minute (429). `{team, closed_at, purge_at, closed_by, purged_at?, deleted_now, remains, then}`; `deleted_now` lists deleted categories after the live purge, otherwise `[]`. `remains` says what stays: the team's account and membership, closure and deletion records, its payments (top-ups, refunds, welcome grants) and credit holds, a usage ledger (job id, team and core-hours: billing, no content), 30-day database recovery points, encrypted database backups retained for 35 days, and copies on our machines and in the archive until the separately queued purge completes (subject to legal holds). What goes: its jobs with their results, logs, per-job charges and meters, its findings and reports, images, tokens, per-ask charges and settings, and its handle, app links and viewer logins. |
| `DELETE findings/{finding}` | `finding delete FINDING` | `{deleted, job?, evidence}`: the finding goes at once, with its job links, upstream report, hypothesis notes and shared proofs; its evidence on our simulation hosts and in our archive (the output and images of the jobs that found it, and of its replays, fix checks, debug and causality jobs) is deleted by the scheduler, which waits while any of those jobs is queued or running (refused under a legal hold). The jobs that found it keep their own results and logs until their images are deleted or the team is closed. Only the finding's own team |
| `POST findings/{finding}/close {why?}` | `close FINDING [-note "why"]` | the finding, closed; `why` (at most 280 characters) is shown on it as `closed_why`, and a reopen clears it. `fplus dst findings` lists closed findings only with `-all` |
| `GET images/{image}`, `GET images/{image}/parts/{n}` | `image pull IMAGE\|FINDING [-o FILE]` | an image of the team's (`{image, sha256, size, parts, commit?, label?}`), then each part as it was pushed: in order, its tar |
| `POST findings/{finding}/reopen {note}` | `finding reopen FINDING -note "why"` | the finding, open again, with `reopen_job`: a free job in which f+'s machines issue a REOPENED receipt superseding its fix checks' fixed verdicts (their proof pages and job views then say so, with the note) |

**A finding** is `{finding: "fnd_…", status: open|fixed|closed, test, job, image, image_label?, signature?, fingerprint?, error?,
schedule?, minimal_schedule?, trigger?, replays, sim_image: {sha256, epoch}, explanation?, tests_failed?,
fixed_by?, created_at, updated_at}`. `tests_failed`: a group's finding names the tests that failed in its runs. `image` is the image it was found on as you know it (`img_…`, or a pinned public one), with `image_label` when that image was pushed with `-label`;
`sim_image` is f+ DST's simulator image it replays in. A fixcheck whose outcome is
`fixed` marks it fixed (`fixed_by`, that job).

A finding may carry a `label`, with a `note` saying what it means:
- `timeout-under-load`: the test runner's own timeout fired while the search stole CPU time or paused the test. A
  deadline too tight for a loaded machine, or a real hang: it may or may not be the bug you're hunting.
- `fails-without-faults`: it failed in every fault-free run, with no fault injected (a deterministic failure, or a
  race the run's own schedule hits). Its replays and fixcheck run that same no-fault schedule; a fixcheck can read
  `fixed` when the finding's image still fails it and the fix passes it on every replay.
- `deterministic`: the same, for a job that ran its own `command`: the command's test fails as written, every run. A
  test written to show a bug does exactly that: it confirms the logic, not a timing failure.

A JVM finding's `error` is the JUnit or surefire failure line.

### Upstream

A finding's upstream report is the pull request, issue or comment the team sends the project about it, one per
finding. f+ DST drafts it from the finding's evidence; the team edits it, sends it itself, and says where it went;
then f+ DST reads that GitHub URL about hourly until it is merged or closed.

| Call | `fplus dst` | Answer |
|---|---|---|
| `POST findings/{finding}/upstream {kind?, fixcheck?, patch?, ci?}` | `upstream draft FINDING [-kind pr\|issue\|comment] [-fixcheck JOB] [-patch FILE] [-ci TEXT]` | the draft, made (again) |
| `GET findings/{finding}/upstream` | `upstream show FINDING` | the draft |
| `PATCH findings/{finding}/upstream {kind?, title?, body?, patch?}` | `upstream edit FINDING [-edit] [-set FIELD=TEXT\|@FILE]` | the draft, edited |
| `POST findings/{finding}/upstream/sent {url}` | `upstream sent FINDING -url URL` | the report, `open` |

**A report** is `{finding, kind: pr|issue|comment, title, body, patch?, fixcheck?, state: draft|open|merged|closed,
url?, comments?, review_comments?, sent_at?, checked_at?, outcome_at?}`. The draft's body has the failure line, `ci`
(how often it fails in CI, in your words), the smallest failing schedule's CPU stalls, and the fixcheck's verdict and
nearby schedules; the cause and fix are lines for you to fill in. `kind` defaults to `pr` with a `patch`, else
`issue`; `fixcheck` defaults to the one that fixed the finding, else its newest. `url` is a github.com pull request
or issue, or a comment on one (`#issuecomment-…`). A finding shows its report as `upstream {kind, state, url?,
sent_at?, outcome_at?}`.

## Hypotheses

A team's hypotheses are its agents' shared list of what could go wrong in its code, each rooted in source lines, that
a swarm works through with `fplus dst` alone: each agent takes the best open one (`next`, a claim with a lease),
designs and runs DST jobs to test it, attaches them and their findings, and gives a verdict with its evidence. The
`fplus-dst` skill's `hypotheses.md` (`fplus dst skills install`) is the whole workflow: map the modules, a cheap classifier
pass per module on your own machine, then the swarm's loop. Your code never leaves your machine: only the
hypotheses' text and their file:line references are sent. Hypotheses cost nothing; the jobs that test them cost
what jobs cost.

**Setup and envs.** A swarm builds its own images: `fplus dst hypo start` in the repository's checkout begins it,
and its first task, `setup`, is to build the test image (the recipe in `.fplus/environment/`) and push it. Whichever
agent calls `next` first gets it, before any hypothesis; it builds on its own machine, pushes with
`fplus dst image push`, and records the image with `fplus dst hypo done setup -image IMG`. Until then hypotheses wait
(`blocked`); after, each one `next` hands out carries `image`, so nobody passes image IDs around. A hypothesis that
needs another image (a multi-node [services](#services) one, say) says `needs: "env:NAME"`; that makes an `env:NAME`
task, built the same way from `.fplus/environment-NAME/`, and the hypothesis waits for it. `start` again at a new commit,
or with a changed recipe, makes each env built from other a task again (`rebuild`); the old image serves meanwhile.

| Call | `fplus dst` | Answer |
|---|---|---|
| `POST hypotheses/start {repo?, commit?, recipes?: {ENV: sha256}}` | `hypo start [-repo URL] [-commit C]` (default: `origin`, HEAD, and the hash of each `.fplus/environment*/` folder) | `{tasks: [task…]}`: starts the swarm (a `setup` task), or moves every env to the commit and recipes given |
| `GET hypotheses/{task}` | `hypo show setup`, `hypo show env:NAME` | the task |
| `POST hypotheses/{task}/done {agent, image, recipe?, commit?}` | `hypo done TASK -image IMG [-check TEST] -as NAME` | the task, `done`, with its image; refused (409) for an image no check has passed on (`-check` runs one first and waits), one pushed from another commit than the swarm's, or while another holds the task |
| `POST hypotheses/{task}/heartbeat`, `release {agent, note?}`, `update {agent, evidence}` | `hypo heartbeat TASK`, `hypo release TASK [-note WHY]`, `hypo update TASK -evidence E` (`-as NAME`) | the task: its lease renewed; given back; with a note for the next agent |
| `POST hypotheses {module?, refs, statement, class, test_plan?, priority?, commit?, needs?}` | `hypo add -statement S -class C -ref PATH:START-END... [-module M] [-plan P] [-priority 50] [-commit C] [-needs env:NAME]` | the hypothesis, `H<n>`; 409 naming the one it repeats |
| `POST hypotheses {hypotheses: [...]}` (up to 500) | `hypo add -file F.jsonl` (one object a line; `-` for stdin) | `{added: [hypothesis…], duplicates: [{index, of, hypothesis}]}`; a bad field refuses the whole batch (400, naming the item) |
| `GET hypotheses?module=&status=&class=&q=` | `hypo list [-module M] [-status S] [-class C] [-q WORDS]` | `{tasks: [task…], hypotheses: [hypothesis…], counts: {status: n}}`, best first (priority, then oldest). `module` takes its submodules (`p2p` takes `p2p/gossip`); `status` some of the statuses, comma-separated, or `active` (open, claimed, testing) or `done` (the verdicts); `q` words that must all appear in its statement, module, test plan or paths |
| `GET hypotheses/{h}` | `hypo show H` | the hypothesis with `notes`, its history |
| `POST hypotheses/next {agent, lease_min?, module?, class?, max_claims?}` | `hypo next -as NAME [-lease 30m] [-module M] [-class C] [-wait] [-max-claims 2]` | the best open one, now claimed by you, or 204 when none: a task to build first (setup, then an env an active hypothesis needs), then open hypotheses, then claimed or testing ones whose lease lapsed, skipping those whose env has no image yet. A task's lease and the cap count as a hypothesis'. An agent holding `max_claims` live claims (default 2, at most 10) is refused (409, naming them). `-wait` claims again on each change to a hypothesis ([Live events](#live-events)), or each minute, until it gets one |
| `POST hypotheses/{h}/heartbeat {agent, lease_min?}` | `hypo heartbeat H -as NAME [-lease 30m]` | the hypothesis, its lease renewed: for `lease_min` if given (which becomes its length), else for the length it was claimed with |
| `POST hypotheses/{h}/attach {agent?, job \| finding, note?}` | `hypo attach H JOB\|FINDING [-note N] -as NAME` | the hypothesis; a job or finding by ID or name. Anyone may attach; your own claimed one becomes `testing` |
| `POST hypotheses/{h}/update {agent, status?, evidence?, priority?, support?, needs?, image?}` | `hypo update H [-status testing\|open] [-evidence E] [-priority N] [-how real\|faults] [-needs env:NAME] [-image IMG [-check TEST]] -as NAME`; `hypo close H -status VERDICT -evidence E [-how mock\|real\|faults] -as NAME` | the hypothesis with its history; `open` gives a claim back; `support` alone on a supported one records how it was shown again |
| `POST hypotheses/{h}/dup {of, agent?, note?}` | `hypo dup H OF` | H, now `duplicate`, with `dup_of` |
| `POST hypotheses/{h}/release {agent}` | `hypo release H -as NAME` | H, open again; or, while jobs attached to it run, `parked`: held by no one and skipped by `next` until they end, then open again with their outcomes in its notes |
| `GET modules` | `modules` | `{modules: [{module, path?, notes?, classified, seeded, total, done, counts, unmapped?}], total, done, classified, seeded, counts}`: the module map and the swarm's progress in each (`done`: verdicts and duplicates); a module the hypotheses name that the map doesn't is `unmapped` |
| `POST modules {modules: [{name, path?, notes?, classified?, seeded?}]}` (up to 500) | `modules add NAME [-path P] [-notes N]`, `modules add -file F.jsonl`, `modules done NAME...` (classified), `modules seeded NAME...` | the map, as `GET modules`; upserted by name; `classified` (the classifier pass ran) and `seeded` (its hypotheses are written) stay true once set |

**A hypothesis** is `{name: "H12", hypothesis: "hyp_…", module?, status, class, priority, statement, test_plan?,
refs: [{path, start, end, commit?}], claimant?, lease_until?, lease_lapsed?, dup_of?, support?, jobs: [job_…], findings: [fnd_…],
needs?, image?, blocked?, parked?, created_by, created_at, updated_at, notes?: [{at, by, status?, text?, job?, finding?}]}`. `{h}` is
`H12`, `12` or the ID. `needs` is its env (`env:NAME`; none: the setup task's image); `image` the image it runs on: the
one recorded with its own test (`update -image`, which needs a passed check of it), else its env's, once built;
`blocked` the task it waits for; `parked` that its holder left while its jobs ran.

**A task** is `{task: "setup" | "env:NAME", kind: "setup" | "env", env, status: "open" | "claimed" | "done", rebuild?,
repo?, commit?, image?, built_commit?, recipe?, claimant?, lease_until?, lease_lapsed?, note?, needed_by?, waiting?,
updated_at}`: `commit` and `recipe` are what the swarm wants, `built_commit` what `image` was built from; `rebuild`
says the image is out of date (it still serves); `needed_by` names an env's active hypotheses, and `waiting` counts
those blocked on it.

- **refs:** 1 to 20, each `{path, start, end?, commit?}` or `"path:START-END"` (`"path:LINE"`, `"path:START-END@COMMIT"`);
  paths relative to the repository's root. A body-level `commit` applies to refs without their own.
- **class:** `time`, `randomness`, `concurrency`, `network`, `disk` (fsync, disk errors, crash consistency),
  `ordering` (map or set iteration, message order), `resource` (memory, descriptors, pools, limits), `other`.
- **priority:** 0 to 100, higher first; 50 by default.
- **status:** `open` → `claimed` (next) → `testing` (a job attached, or update) → a verdict: `supported`, `refuted`,
  `inconclusive`, `wontfix`; or `duplicate` (dup). A verdict needs `evidence` and ends the claim. `supported` should
  cite a finding; `refuted`, what was searched (jobs attached, budgets, faults).
- **support:** how a `supported` one was shown, required with it: `mock` (confirmed: its logic, by a test with
  mocks, often failing deterministically), `real` (reproduced on the real code path with no fault needed: it fails
  in a fault-free check or a hunt's base run) or `faults` (it fails only under DST's injected faults: its check and
  base run pass). One shown again another way is updated (`hypo update H -how real|faults`). `GET hypotheses` and
  `GET modules` count the supported ones by how in `support_counts`.
- **The lease:** `next` and `heartbeat` hold it for `lease_min` (5 to 240, default 30). While it is live only its
  holder changes the status, priority or marks it a duplicate (409 naming the holder and when it ends); anyone may
  attach. A lapsed lease is free: the next `next` takes it, and its history says whose lapsed.
- **agent:** the agent's own name, so that many agents on one DST token are told apart: the claimant is
  `login/agent`. fplus sends `-as NAME`, or `$FPLUS_AGENT`. Up to 80 characters, no spaces or `/`.
- **Duplicates:** an add whose module, class, first path and statement's words (case, punctuation and numbers aside)
  match one already in the team is refused (one) or skipped (bulk). Near-repeats are yours to catch: search with
  `hypo list -q` before adding, and mark later ones with `dup`.
- **Limits:** 10,000 hypotheses and 2,000 modules a team; a statement or test plan up to 2,000 characters, evidence
  or a note up to 4,000.

## Live events

A team's changes are pushed as they happen, so a page or a script never polls. `GET events?since=N` with
`Upgrade: websocket` (the same sign-in or DST token as any team call; `fplus dst status JOB -wait` uses it) opens
the team's events: one JSON object a message, each `{seq, at, type, …}`. `seq` numbers the team's events from 1,
in order.

- The first message is `{type: "hello", seq, oldest}`: the team's last event number and the oldest one still kept.
  Then come the events after `since`, then each new one, live. `since` is the last number you have (0: none).
- If those events are no longer all kept (the last 1000, and any of the last 24 h, are), or `since` is ahead of
  `seq`, a `{type: "reset", seq}` follows the hello: fetch what you show again, then carry on from that `seq`.
- Every team `GET` answers with an `x-dst-seq` header, read before its answer is built: render that answer, then
  subscribe since it. An event may come twice that way, never be missed. `GET events/seq` is `{seq}`.
- Each type carries the whole row its GET answers, so you patch your copy by its key:
  - `job` `{job}`: the job as `GET jobs/{job}` shows it, when it is queued, taken, changes state, ends or is
    charged. Its `live` line and `progress` send at most one event every few seconds.
  - `finding` `{finding}`: the finding as `GET findings` lists it, when a job files it, hits it or closes it.
  - `coverage` `{test, row}`: the test's row as `GET coverage` shows it (`null`: none).
  - `hypothesis` `{hypothesis}`: as `GET hypotheses` lists it, on each change.
  - `credits` `{credits: {team_usd, open_jobs, team_spent_usd, team_spent_today_usd}}`: the team's own credit and
    spend, when a job holds, is charged or gives credit back. Balances that count a person's welcome credit are
    that person's: read `GET credits`.
  Ignore types you don't know.
- Send the text `ping` to get `pong`, to keep a connection through idle proxies.
- A connection closes (code 4001) when its DST token is revoked, at once, or when its token expires or its person
  leaves the team, within 5 minutes.
- Without a WebSocket: `GET events?since=N&wait=25` answers `{seq, events}`, held up to `wait` seconds (at most
  25) until there is an event after `N`, or `{seq, reset: true, events: []}`.

In code mode, an app's page subscribes through its app (`ui.subscribe`); its credential stays on the server.

## Credits

- **Price, by the core-hour:** a core-hour is one VM (one simulation) running for one hour with up to 10 GiB of RAM,
  at any vCPU count (1, 2 or 4).
  - **Pay-as-you-go:** $0.50 per core-hour, no monthly fee.
  - **Teams:** $1,800 a month, including 7,200 core-hours ($0.25 each); more at $0.50 per core-hour.
  - **RAM above 10 GiB** costs in proportion: a VM-hour at 16 GiB is 1.6 core-hours ($0.80), at 20 GiB 2 ($1.00), at
    32 GiB 3.2 ($1.60).
  - **Example:** a 60-minute hunt on 10 VMs of 16 GiB is 10 × 1 h × 1.6 = 16 core-hours, $8.00 on pay-as-you-go.
  - `credits.prices` reports the active rate.
- **Grant:** each GitHub account gets $50 (100 core-hours), spent before its team's own credit. Top up with
  `fplus dst topup USD` (25 to 500 USD, `POST credits/checkout`, below): a Stripe page for a person to pay on, a DST token being enough. The grant is yours, not the team's: jobs you queue in any of your teams spend it, so a
  team's `credits` (`welcome_usd`) can fall by more than that team spent; `credits.team_spent_usd` is this team's alone. A DST
  token spends the grant of the person who made it.
- **What a job runs:** a hunt 10 simulations (VMs; see **Guest**), a fixcheck or causality 2, a check, replay or debug 1.
- **Charging:** a job is charged for what it used when it ends: its simulations × the hours they ran
  (`meter.simulation_hours`) at its tier's price, times its RAM factor above. `meter.vm_hours` is what all its VMs
  ran (`simulation_hours` is that, capped as below), `meter.average_vms` that over its run's wall time
  (`running_at` to its end), and `meter.vms` the VMs it ended on (any kind: a fix check or a causality may run on more than its quoted 2 to end sooner, and is charged at most its quote): an elastic hunt that ended on 4 VMs
  may have run 15 on average. `fplus dst status` says it as `ran: 8 VM-hours (15.5 VMs on average), charged for 8 core-hours`. Waiting in line is free, a job whose result f+'s machines mark as their own failure
  (`our_failure`, whatever its verdict: a test that never started, our simulator failing to boot it, a host's disk that filled, a search that completed no valid run, a replay our engine did not replay deterministically, our host interfering with a run) is free (its `hint` says it was ours and not charged), while one our machines stop at its time limit (its wall cap,
  budget + 60 min: its own test hung or ran past it) is charged like any run, at most its quote, and its `hint` says so; free too is an answer
  the scheduler gives from an earlier result (`cached`), or from a run already charged to another job. Building an image and
  converting it into a simulator image are free (`meter.convert {vcpus, seconds, cost: 0}`); conversion runs once per
  image and machine and scales with image size. We overbook machines' memory; a run our host's memory cap kills is run again and never
  charged, shown as `meter.refunded` (`why` says what was ours: a run our memory cap killed, the baseline a hunt runs again after a
  preemption, a host lost or moved). A charge we find later was our failure is given back to the team's credit, shown
  as `refund {usd, why}` on the job and in `usage`. A job never costs more than its `max_simulation_hours`, its
  simulations × (budget + 60 min) / 60 (a hunt's margin is its budget, 10 to 60 min; a fixcheck sized without
  `budget_min`: its `budget_simulation_hours`), at its tier.
  A hunt, and a fixcheck given `budget_min`, costs at most what it was quoted: `budget_min` / 60 × the simulations its hold was sized for (a hunt's 10, or its `vms`; a fixcheck's 2), whatever width
  it ran or ended on (a wider hunt's search is shorter); the time it takes past that to group, confirm and shrink what it
  found is ours.
  - check and replay have a 10 min budget, debug 15, fixcheck 20. A causality's `max_simulation_hours` is its `budget_simulation_hours`.
  - While it runs a job holds its `held_simulation_hours` at its tier's price (a hunt, or a fixcheck given `budget_min`: its quote, `budget_min` / 60 × its simulations; `max_simulation_hours` keeps the margin for shrinking), and its charge never exceeds that hold.
  - Example: a 15-minute hunt runs on 10 VMs, holds $1.25 while it runs and is charged at most $1.25 (a 5-minute hunt
    runs on 10 VMs, holds $0.42 while it runs and is charged at most $0.42; a 60-minute hunt runs on 10 VMs, holds $5.00
    while it runs and is charged at most $5.00), however long it takes to shrink what it found; an image's first hunt
    that ends at its first failure is charged less. A check holds $0.58.
- **Storage:** a trial team's images, and the parts of pushes not yet finished, take up to 50 GB free (500 GB once the team leaves trial via any credit purchase, a Teams plan, or an f+ promotion; `credits` shows what
  they take). A part past it is refused with 413. `GET images` (`fplus dst images` or `fplus dst image list [-label L]`) lists pushed images; `DELETE images/{image}` (`fplus dst image rm IMAGE`) deletes an
  image no unfinished job or open finding needs (409 otherwise) and its parts; an unfinished push's parts are deleted
  after two days.
- **Rate limits:** per account (a person and the tokens they minted, over all their teams), 600 API calls a minute
  (image parts and GitHub reads aside), then 429 with `Retry-After`; per team, 120 image part reads a minute (`image pull`
  waits the 429 out), and 30 new images a day (each is converted for
  the simulator once; re-pushing one the team has is not new, and pushes past the cap are refused 429 before parts upload; use `-overlay` for small edits), then 429. Leaving the basic trial (any credit purchase, a Teams plan, or an f+ promotion) lifts every trial limit together: 1000 new images a day, background warm conversions for every push (5 a day on trial), 500 GB storage, and no default spend caps (`GET credits` `limits.tier` shows `trial` or `paid`); f+ can also adjust a team's limits (ask with `fplus dst feedback`).
- **Accounts:** a new GitHub account is let straight in (f+ can switch to approval: `fplus login` and
  `POST /v1/dst/teams` then answer 403 saying the account waits). An account has its $50 grant and makes up to 3 teams of its
  own.
- **Spend caps:** a team may cap what one job may hold and what it spends and holds in a UTC day, in dollars
  (`GET caps` — also shows `images_24h` / `images_per_day` for metered teams — `PUT caps {daily_usd?, job_usd?}`, a number or null for none; `fplus dst caps -daily N -per-job N`).
  Changing caps requires the team's admin, signed in (`fplus login` or https://staging.extrafunctional-staging.fyi/account): never a DST token, nor another member (403). A
  new welcome-credit-only team has $25 a day and $15 a job until it sets its own or holds more than the $50 welcome grant (paid credit or credit f+ granted); teams that ran jobs before the caps shipped have none. A
  job over either is refused at once with 402, saying what is spent or held today and what it may use. Every submit's
  answer has `caps {daily_usd, job_usd, today_usd}`.
- **Core-hours a day:** a team's jobs may use 200 core-hours each UTC day (VMs × the time they run: about twenty 60-minute hunts), kept by
  f+'s machines: a job past it is accepted and waits there, its live line saying so, until the day resets at 00:00 UTC.
  Ask us to raise your team's limit (there's no self-serve setting yet).
- **Concurrent VMs:** a customer team may run up to 120 concurrent VMs at once (`limits.max_concurrent_vms` in `GET credits`). Short triage jobs (`check`, `replay`, `debug`, `fixcheck`) are queued ahead of your own hunts and get bounded headroom above the cap so triage runs do not wait behind 60-minute hunts; use `-vms N` (1–10) to run narrower hunts in parallel or `-tier on-demand` to run ahead of `live`/`batch` hunts.
- **Refused jobs:** credit that open jobs may still use is held. A job whose hold (`held_simulation_hours` at its tier) is more than what's
  left is refused. A job stopped before it ran costs nothing.

## Asking our agents (beta)

`fplus dst ask "QUESTION" [-agent setup|strategy|triage|expert]` (`POST agent {ask, agent?}`) puts a question to our
agents. They read this team's jobs and findings as you, search these docs and the skills, and queue a run only when
you ask for one. The answer is `{agent, answer, calls: [{method, path, status, mutating?}], cited, cost_usd}`; an ask
costs about $0.002 (`cost_usd`), from your credit; while it runs it holds at most $0.10, and what it doesn't use comes back. `fplus dst agents` (`GET agent`) lists the agents and
what each remembers of this team; `fplus dst agents forget NAME` (`DELETE agent/{name}`) clears it.

The agents follow the DST skill set, which your own agent can follow too: one skill, `fplus-dst`, whose SKILL.md
onboards to DST and links its other pages (triage.md, strategy.md, reproduce.md with its recipes, expert.md) and the
optional pieces (debug and causality, code mode). `fplus dst skills install` writes it to `.claude/skills` (`-dir`
elsewhere), and `GET /v1/dst/skills` lists it with its version and files (`GET /v1/dst/skills/fplus-dst` for
SKILL.md, a page at `fplus-dst/{path}`). fplus says when an installed copy is older than ours.

## Feedback

`fplus dst feedback "TEXT" [-kind bug|missing|docs|ux|wish] [-job JOB] [-finding FINDING] [-file PATH]` (`POST
feedback {text, kind?, job?, finding?, file?: {name, content}, app?, source?, context?}`) tells us what f+ DST lacks
or got wrong: a missing feature or option, a confusing doc or error, a wish. `kind` defaults to `wish`; `text` is 1
to 4000 characters; `file` is a text file of at most 64 KB; `context` is a JSON object of at most 8 KB (fplus sends
its version and the command). It is never charged, a team may send 20 an hour and 100 a day (429 with
`retry_after` past that), and the answer is `{id, received_at, message}`. `fplus dst feedback list` (`GET
feedback`) shows the team's own, newest first, with our `reply` once we answer. Our agents (`fplus dst ask`) file
one for you when DST can't do what you asked.

## Legal holds

A team under a legal hold can't be closed at once: `POST close {now: true}` is refused with 409 `team TEAM is under a
legal hold`. A team closed with the 30-day grace stays queued for deletion after its grace, its data intact, until the
hold is cleared.

## Paying with MPP

A job refused for credit (402) can be paid for on the spot over MPP, the Machine Payments Protocol
([mpp.dev](https://mpp.dev)). The 402 carries `WWW-Authenticate: Payment` challenges offering a top-up: the smallest
of $10, $25, $50, $100, $250 and $500 that covers what the job is short.

- **How to pay:** directly in `USDC.e` on Tempo mainnet (method `tempo`, chain `4217`) verified on-chain to our
  receive-only recipient address — no server private keys are held — and, when configured, by card with a Stripe
  Shared Payment Token (method `stripe`).
- **Retry:** send the same request again with your MPP credential in `Payment-Authorization`, and keep your sign-in
  or DST token in `Authorization`. The credit is added and the job queued in that request, which answers with a
  `Payment-Receipt`.
- **Limits:** a challenge lasts 5 minutes and is bound to its team and amount. A credential counts once: sent again,
  it gets a 402 with a fresh challenge. What the job doesn't use stays as the team's credit.
- **Top up directly:** `POST /v1/dst/teams/{team}/credits/topup {usd}` asks for exactly `usd` (`$0.50–$500`) the same
  way, and answers what was credited and the balance.
- **MPP clients:** an MPP client does the challenge, payment and retry for you, keeping your `Authorization`.
  For example: `npx mppx https://staging.extrafunctional-staging.fyi/v1/dst/teams/TEAM/credits/topup -H "Authorization: Bearer $EXFUN_DST_TOKEN"
  -J '{"usd": 20}'`.
