Concept · Assayer
How the Assayer tests
How it finds a repository's test cases, reads the tests in each, runs them in a throwaway worktree at a share of the processor, marks flaky tests and their likely cause, says what changed when something breaks, puts a tool back, runs only the tests a change reaches, and runs your AI assistant's checks.
- Article
- 1802
- Applies to
- Assayer 0.10.5
- Last reviewed
- For
- For developers
Cases#
Code finds a repository's cases from its own files, at the commit tested:
| Case | Where it comes from |
|---|---|
| Unit tests | The test command in Castellan's Settings, or the one the repository suggests. |
| Typecheck, lint, build | package.json scripts (npm, pnpm or Yarn); pyproject.toml and the like (pytest, mypy, ruff); Cargo.toml (cargo test; clippy and build are found but off until you turn them on); a .NET solution or project (dotnet test; build off until turned on); go.mod (go test, vet); a Makefile's targets. |
| Release ready | The release checks, on for any project with a GitHub repository. See Release ready. |
Settings > Test cases you set turns a found case off or on, gives it another command, or adds one of your own: by the Project's name as Castellan's Settings have it, the Case, its Command, and Run it.
A project with no test command is tested by the cases it suggests.
Tests#
Each case's tests are read from its runner:
| Runner | What's read |
|---|---|
| node:test, Vitest, Jest | Their JSON reports |
| pytest | JUnit XML |
| dotnet test | TRX |
| cargo test, go test | Their output |
A runner it can't read still gives the case's pass or fail, and its output.
Each repository, case and test shows its last run, passed or failed, how long it took, its last few runs as dots, and the failing output. When a case failed before any test ran (a build error, a tool that isn't installed), the error lines come first, wherever they were in the output.
Flaky tests
A test that passed and failed on the same commit with the same tools is marked flaky. It's the test, or what it depends on, not the change.
The Assayer reads the test's own code for the usual cause: a wait for a fixed time before an assertion, long enough on a quiet PC and too short on a busy one. When it finds one, the page names it beside the test, with the file and line. The fix is to wait for the condition itself, with a deadline, or to use fake timers.
A test run#
A test run is every case that's on, one after the other.
- In a throwaway worktree under the Assayer's data folder, detached at the commit tested. Your checkout's working tree is never touched.
- At the checks pace, so the PC stays yours: below the priority of your own work, at most a third of the processor, with its memory capped so a runaway test fails instead of slowing the PC, and at most three check runs at once on the PC. The cap is shared with the Steward's own checks, so the two together stay under it. Background work at Full speed, in Castellan's Settings > General, raises it. See Castellan's settings.
- Stopped after 20 minutes for the whole run (Stop a test run after, a setting), with everything it started. Since the pace slows it, a run gets up to four times that before it's stopped. A run stopped this way counts as a failure.
- With git's commit and tag signing off, for the tests alone: the throwaway commits a repository's tests make don't each call on your signing key. Your own git settings, and your own commits, are untouched.
- A Node project borrows your checkout's
node_modulesonly when what's installed there is exactly what the commit's lockfile pins. It borrows through a link that's taken away before the worktree is removed, so yournode_modulesis never emptied. A Next.js app never borrows. - Otherwise the worktree gets its own install first:
npm ci, or pnpm's or Yarn's frozen install. If that fails, the run couldn't be tested: it's tried again in the next round, and never counted as a failure of your code.
Repositories inside WSL aren't tested in its rounds, so the rounds never wake WSL. Your AI assistant can still check them (below).
What changed#
Each run notes the versions of the tools it used: Git, and Node.js, npm, pnpm, Yarn, Python, Rust, .NET, Go, Java or the Visual Studio build tools, as the repository needs.
When a case goes from passing to failing, the run says what changed since the last passing run: the commits between them, and the tools whose versions moved.
Put a tool back
When it's the same commit and only the tools changed, the toolchain is the likely cause. The page offers each tool's last good version back, through the version manager you already use (nvm-windows, pyenv-win, rustup) or winget. Check the ones to put back, and press Put back. The Assayer never changes a tool on its own.
Faster tests: only what a change reaches#
A branch of yours is a change against the project's branch, so its unit tests run only the test files that change reaches (Test only what a change reaches, under Advanced in Settings, on by default):
- node:test (a test script of the form
node --test "<glob>"): the test files that changed, the ones whose imports reach a changed file (however deep), and the ones that name a changed file. A file in a folder that code reads whole reaches that code's tests. - Markdown (a changelog, a README, docs) reaches only code that reads it where it lies, such as a test of the project's own changelog. A change that only raises version lines, in
package.jsonor aVERSIONfile, reaches no test. - Vitest and Jest: their own
--changedand--changedSince. - Anything it can't follow runs every test: the TypeScript or npm setup, test fixtures, a file deleted or renamed, a file no code names, very many files at once, or another runner.
The daily health run and release ready always run everything. Each case on the page says what it ran.
Set it up in your project
A Node project on node:test, Vitest or Jest without a test:affected script is offered one under Faster tests. Set it up makes a branch, assayer/affected-tests, from the project's branch in a worktree of its own, with the script line (and for node:test, a small script needing nothing installed). It's tested at once and opened as a ready pull request. Once merged, npm run test:affected runs only the tests your change reaches, on your PC or in CI.
Workspaces (npm, pnpm or Yarn workspaces, Nx, Turborepo) are offered nothing: their own tools do this across packages.
Checks for your AI assistant#
The Assayer is an MCP server too, so your AI coding assistant runs a repository's checks through it instead of running them itself and reading all their output. It has four tools:
| Tool | What it does |
|---|---|
| check | Runs the repository's cases (unit tests, typecheck, lint, as a round finds them, or the ones named) in its working tree as it is, uncommitted changes included. |
| history | Which tests fail, since when, and which are flaky, from its checks and its own rounds. |
| toolchain | The tools' versions now, and which changed since the last passing check. |
| kept | How much test output its checks kept out of your assistant's context, as an estimate. |
What a check does
- It installs first what the checks need, when it's missing or isn't what the lockfile pins (
npm ci, or pnpm's or Yarn's frozen install), and says so. If the install fails, the answer gives its error lines, and no check runs. - It answers in a few lines: PASSED or FAILED, each case's result and counts, each failing test with its message, whether it failed before, is new or is flaky (with its likely cause), what changed in the tools since the last pass, and the path of a log with the whole output.
- The same code checked again within a day is answered at once, with nothing run again. Installed packages count as part of the code. A check that failed before any test ran (a build error, a missing tool) always runs again.
- Only what a change reaches: your assistant can ask for the unit tests its change reaches, against the project's branch, while it works, and the whole check before it pushes.
- A whole check that passed counts for a vouch. Commit exactly that code, and
steward vouchtakes the Assayer's pass instead of running the suite again. Something installed during the check stops it counting. See Vouching for your work. - Just the test you're fixing: your assistant can name test files, or part of a test's name, and only those run, with the runner's own filter (node:test, Vitest, Jest and pytest by file and name; cargo, dotnet and go by name). A command the Assayer can't narrow (several commands chained, a runner it doesn't know) is refused, saying why, rather than run whole.
- Repositories inside WSL can be checked, from Windows or from inside WSL. Their tests run inside WSL, with the distribution's own tools.
One Assayer for every session
Each session your assistant starts gets a small bridge to the Assayer's page, which runs the checks for all of them. Each session's checks still run as its own: with its environment (its PATH, an activated Python environment, the variables in your assistant's settings) and its WSL distribution. The bridge reaches the page on this PC only, with a secret only your account can read.
- When the Assayer updates, the page restarts, not your sessions: each comes back to the new version by itself, with any call it was waiting for, and your assistant is told the tools changed.
- A session started while the page was down (just after you sign in, say) runs the Assayer on its own, then moves to the page once it's up. A check already running finishes where it started.
Connect your assistant
On its page, the Connect your AI card, on the Your AI tab, connects it. For Claude Code, its Connect adds the Assayer's tools for every project through Claude Code's own claude command, allows them without asking, and adds short reminders to use them. Once Claude Code is on your PC, the Assayer does this by itself half a minute after it starts. Where the claude command isn't on this PC's PATH, as with the desktop app's Claude Code, the card gives the line to run once in a terminal. Inside WSL it waits for you to press the button. Disconnect takes all of it out, and it stays out, even as the Assayer starts, until you connect it again. Once your assistant is connected, the card is one line.
The very first time, before the Assayer has looked, the card is one quiet line, saying it's looking for your assistant. After an update or a restart, it shows what it found last time, marked "last seen", until it has looked again.
Each other assistant on this PC has a row of its own: Claude Desktop, Cursor, VS Code with Copilot, Windsurf, Gemini CLI, Codex CLI, Cline, Continue and Zed. The row says whether it has the Assayer, with a Connect or Disconnect button. Connect adds only the Assayer's own entry to that assistant's settings, and Disconnect takes only that entry out: nothing else in the file changes, and the file as it was is kept once beside it. A settings file it can't read is left alone, with a line saying why and the text to paste instead.
What it kept out
Kept out of your AI's context, on its page, shows how much test output its checks kept out of your assistant's context: this month, last month and all time, in tokens and roughly in dollars. These are estimates. It counts only what your assistant would really have read: each test command's output up to 30,000 characters, the most Claude Code takes from one command, less the few lines the Assayer answered with.
Related articles
Is this page right?
If something on it is wrong or out of date, tell us and we'll fix the page.
Still stuck? Write to support@castellan-software.com and mention article 1802. Every version of Assayer, and what changed in it, is in its release notes.