# Limits

> What trimtest cannot see, where it deliberately over-selects, and why a scheduled full run still matters.

trimtest is conservative, not omniscient. Know where it can be wrong or wasteful.

## Always keep a full run

Keep a scheduled full run (`trimtest run --full`) as a safety net. Selection is evidence-based, and some evidence
is weak: the static graph cannot see reflection, dependency injection, `eval`, macros, named Zig modules or
Playwright end-to-end links.

## Unobserved files only warn by default

If a changed file is one that no test is known to reach, `trimtest select` and `trimtest run` report it as
`unobserved` and, unless you pass `--strict` or set `on_unobserved = "full"`, only print a warning: those tests are
not added and no full run is triggered. That is the default because most such files (docs, scripts, examples) are
genuinely untested, but it means an edit to a file linked to tests only in a way trimtest cannot see (reflection,
generated code, a file read by name) will not be caught by the selection. In CI, use `--strict` so an unobserved change
runs everything. See [safety rules](/concepts/safety-rules/#unobserved-changes).

## Ignored and gitignored paths

Files matched by `ignore` globs are never traced: they are not part of the dependency graph and select no tests. Their
content is fingerprinted when the map is recorded (up to 20,000 files; beyond that nothing is stored and every
map-based `select` reports `(ignored paths too many to track)`), so against the map baseline an edit, addition or
deletion of one is reported as `unobserved` (and `--strict` or `on_unobserved = "full"` runs everything). Files that
are gitignored (when `respect_gitignore` is on) and directories such as `node_modules`, `target`, build output and
virtualenvs are not hashed at all, since they are large and are not source: an edit there is invisible to the map
baseline. With a git baseline, changes under those paths are reported as `unobserved`. `select --verbose` does not list
this blind spot yet.

## Where it errs toward running more

- Hub modules: when one module imports everything, most changes reach most tests, so the static tier can select
  75–100% of a tightly coupled project.
- Name-based function matching (Python identifiers, JS function names) shares a verdict between same-named
  functions.
- Files coverage cannot vouch for (constants, statement-less files, macros, mocked or abstract classes) stay
  attached to every test that statically depends on them.
- Tests that start other processes run on any change.

## What it cannot see

- Access by string: `getattr(mod, "NAME")`, dynamic `require(variable)` without a recording.
- Behaviour driven by files it does not parse (databases, remote services, environment).
- Anything in a file type it does not track unless a test's source mentions the file name. Flutter assets declared in
  `pubspec.yaml` and `.arb` files are the exception: they run every test of the package.
- Playwright browser coverage sees only JavaScript that ran in Chromium pages. Backend and SSR code, stylesheets,
  markup a server renders, environment variables and `webServer` config are invisible to it, so a Playwright
  recording never replaces the static graph or `[map]` (it only adds files); route those through `[map]`.
  Web workers and service workers started by the page are not measured either, so such a spec depends on every
  project file. Scripts from a CDN or another origin are treated as third-party code and ignored.
- Computed loads in a test (`require(x)`, `import('./' + x)`, `` import(`./${x}`) ``, `jest.requireActual(x)`, `vi.mock(x)`,
  `require.context`; Python `importlib.import_module(x)`, `__import__(x)`, `runpy`, `exec(x)`, `pkgutil.iter_modules`;
  Java/Kotlin `Class.forName(x)`, `loadClass(x)`, `ServiceLoader`; Go `plugin.Open`) cannot be traced, so that test
  depends on every non-test file of its project and is selected for any change there. Only test files and only
  non-literal arguments count: `require('./a')` and `import_module('pkg.a')` stay precise. Loads in non-test code
  (a plugin loader in the library itself) are still not traced by name; recording (`--coverage`) sees them.
- Frameworks without a recording (Ruby, PHP, .NET, Elixir, SQL, Bun, Deno, Cypress, WebdriverIO, Patrol, Maestro, Detox,
  Android instrumented) are never trimmed below their static graph. Their config, lock files and native projects run
  everything, and dynamic loading (computed `require`/`import`, reflection, `eval`, Rails autoload, framework apps)
  makes a test depend on every project file.
- Patrol, Maestro and Android instrumented tests are reported as unrunnable (exit code 3) when no `adb` device or booted
  simulator is found; that is a warning, not proof nothing can run (Patrol can fall back to Chrome). Detox follows
  relative imports only. App code that no Maestro flow or Detox test imports is "unobserved": link it with `[map]` or
  set `on_unobserved = "full"`.
- Python: unittest and nose2 see only `test*.py`; a hyphenated test name runs `unittest discover` (nose2: its whole
  directory). unittest is chosen only without a pytest marker and with a `TestCase` present.
- Mocha with `spec` in `.mocharc` still runs the whole configured set, and flags that live only in `package.json`
  scripts are not carried over (put them in `.mocharc`).
- .NET: namespace-level granularity inside a project; only `.csproj` references are traced; a change in a referenced
  project selects every dependent test. PHP test files are recognised by `Test.php`, `Tests.php` or `_test.php`
  (use `[tests]` for others) and run one process per file. Pest was not run against a real install.

## Granularity

File-level, except tests with a `--coverage` recording in Python, Jest/Vitest, Rust, Java, Kotlin, Go, Dart/Flutter and Swift
(function-level). Files with `#if` (Swift), build constraints, `//line` directives or cgo (Go), `part` directives (Dart) and files
that do not parse stay at file level.

## Platform

Linux, macOS and Windows are supported. The soundness bench (`bench/RESULTS.md`) has been run on all three with no
misses observed: most runs are on Linux and macOS, and Windows has its own section (9 repositories, 10 mutations each, from the
`bench-windows` workflow), which is a smaller sample. Windows results are copied into `RESULTS.md` by hand after each
run, so they can lag the current binary. See the [Windows guide](/guides/windows/).

## Measuring it

The [soundness bench](/trust/soundness/) mutates real projects and counts misses. Zero misses so far is
encouraging, not a proof.

## What CI proves

Every adapter has selection tests that run everywhere with no tool installed: they build a small repository,
record, edit, and assert exactly which tests are selected. Separate end-to-end tests drive the real test runner
(jest, gradle, dart, psql and so on). Those skip themselves when the tool is missing, so a green run alone does not
say the real tool was exercised.

CI sets `TRIMTEST_REQUIRE_TOOLS` in the jobs that provision a tool, which turns a missing tool into a failure
rather than a skip. The real-runner tests are enforced for:

- **Python** (pytest and coverage.py), **Rust** (`cargo llvm-cov`), **Jest** and **Playwright** on Linux, and
  Python, Rust, Jest, **Maven** and **Gradle** on Windows;
- **Go**, **Ruby** (minitest and RSpec), **PHP** (PHPUnit), **.NET** (xunit) and **Elixir** (`mix test`), each in
  its own Linux job.

Not enforced, so their real-runner tests run only where a contributor has the tool: Dart, Flutter and Patrol,
SwiftPM and Xcode, Mocha, `node:test`, Bun, Deno, nose2, behave, and the PostgreSQL adapters (`psql`, pgTAP). Those
adapters are covered by the selection tests and by the [soundness bench](/trust/soundness/), not by a mandatory
real-tool run in CI. See `CONTRIBUTING.md` in the repository for how to run them yourself.
