# Static vs recorded tier

> The static import graph, the recorded coverage tier, which languages have which, and what falling back to the static graph means.

## Static tier

The static tier uses only the import graph. It needs no recording and works with `--base <ref>`. It is precise
where imports are explicit (Dart, Go, TS/JS, Rust, Python), module-level for Swift, and conservative around
dynamic features (reflection, dependency injection, `eval`, macros, named Zig modules, Playwright E2E).

## Recorded tier

`trimtest record --coverage` runs every test file on its own under the ecosystem's coverage tooling and stores
the files it actually executed: `coverage.py` for pytest, V8 coverage for Jest and Vitest, `cargo llvm-cov` for
Rust, JaCoCo for Java and Kotlin. `select` and `run` then use those measurements for any test with a valid
recording (`--tier static` ignores them). Recordings:

- catch dependencies the import graph cannot see (`importlib.import_module`, `await import(variable)`, reflection,
  service loaders, DI-created classes),
- skip imports that never executed (for example type-only imports erased by the compiler),
- are ignored if the test file changed since, if the coverage tool version changed, or if you compare against
  another `--base`; those tests fall back to the static graph.

Re-recording keeps every recording whose test file and executed files are unchanged and re-measures the rest
(`--remeasure` forces everything). `record` baselines the tree *after* the run, so files tests create, like
`Cargo.lock`, are not seen as changes.

## Which languages have which

| | static | recorded (`--coverage`) | function-level |
|---|---|---|---|
| Python (pytest) | yes | yes | yes |
| JS/TS (Jest, Vitest) | yes | yes | yes (by function name) |
| Playwright | yes (`[map]` for E2E) | yes (Chromium JS coverage; only adds to the static graph) | no |
| Rust | yes | yes (`cargo llvm-cov`) | yes |
| Java (Gradle, Maven) | yes | yes (JaCoCo) | yes (by method signature) |
| Kotlin (Gradle, Maven) | yes | yes (JaCoCo) | yes (by function signature) |
| Go | yes | yes (`go test -coverprofile`) | yes |
| Dart, Flutter | yes | yes (`dart test --coverage`, `flutter test --coverage`) | yes |
| Swift (SwiftPM) | yes | yes (`swift test --enable-code-coverage`) | yes |
| Objective-C (SwiftPM targets) | yes | yes (same tool, file-level) | no |
| Zig | yes | no | no |
| Python (unittest, nose2, behave) | yes | yes (coverage.py) | yes |
| Mocha, `node:test` | yes | yes (V8 coverage) | yes (by function name) |
| Bun, Deno, Cypress, WebdriverIO | yes (`[map]` for E2E) | no | no |
| Flutter Patrol | yes | no (needs a device) | no |
| Maestro, Detox, Android instrumented | yes | no (needs a device) | no |
| Ruby (RSpec, Minitest) | yes | no | no |
| PHP (PHPUnit, Pest) | yes | no | no |
| .NET (xUnit, NUnit, MSTest) | yes | no | no |
| Elixir (ExUnit) | yes | no | no |
| SQL / PostgreSQL (pgTAP, psql scripts) | yes | no | no |

## What "falls back to the static graph" means

Zig has no recorded tier, so it uses the static graph; so does any other language where `record --coverage` has no support. They do **not** run every test: the
graph decides, and the safety rules still apply. Go, Swift and Dart resolve imports at compile time, so the
static graph is already exact there, before any recording. Statement-less files such as Go constants never appear in coverage output,
which would make recordings *less* safe, so they are deliberately not recorded.

## Tests that start other processes

Tests that spawn child processes (Rust `Command::new`/`CARGO_BIN_EXE_*`, Python `subprocess`/`os.system`, JVM
`ProcessBuilder`) cannot be measured through their children. `record --coverage` records them as depending on
every file of the project, so they run on any change. Node children inherit the V8 coverage environment, so Jest
and Vitest are measured normally.
