# How SageFs runs your tests as you type

As you edit an F# file, SageFs type-checks the unsaved buffer in the session that already has your project loaded, works out which tests that edit can affect, and runs them, so pass and fail marks move before you save. If the buffer doesn't type-check, nothing runs and the last results stay up, marked as blocked by compile errors, and every selection carries a label saying why those tests were picked.

This page describes the tree at `e47b355b`, which is master on 2026-10-01, and every source link is a permalink to that commit. Release v0.6.870, the last one when I wrote this, predates the per-test coverage, result provenance, pause and scope, the shared selection floor, the whitespace-aware keystroke gate and debugging a failing test from VS Code that this page describes. They were merged on 2026-10-01 and are in v0.6.875. Statements about Microsoft's products were read on 2026-10-01. I didn't run SageFs to write this page, so apart from the latency figures, which I quote as the `--integration-lt` tier recorded them, what follows is what the code says it does.

## What I learned from

NCrunch, Wallaby, testmon, Microsoft's test impact analysis and Visual Studio's Live Unit Testing are different answers to the same question, which is how to rerun fewer tests without lying about it.

NCrunch watches your open windows and the file system, builds the affected projects, and decides what's impacted in one of two ways. `CompareIL` compares the new assembly against the old at the IL level. `WatchText` marks any test covering any line in a changed source file, is "much less accurate", and doesn't wait for a build. The docs add that "no form of impact detection is 100% accurate. Tests should always be run before committing code" ([engine modes](https://www.ncrunch.net/documentation/concepts_engine-modes), [impact detection](https://www.ncrunch.net/documentation/reference_global-configuration_impact-detection-mode)). Wallaby.js runs tests as you type without saving, tracks change at a finer level than files, and puts coverage in the editor margin ([docs](https://wallabyjs.com/docs/)). pytest-testmon records which code each test ran through Coverage.py and compares file and function checksums to find what a change touches. It always reruns what failed last time, and it doesn't track static files or external services ([testmon](https://testmon.org/), [repo](https://github.com/tarpas/pytest-testmon)). Microsoft's test impact analysis in Azure Pipelines keeps a map from test method to dependencies, and when a change is one it can't reason about it runs everything ([docs](https://learn.microsoft.com/en-us/azure/devops/pipelines/test/test-impact-analysis)). Visual Studio's Live Unit Testing makes a workspace copy of your repo, applies your unsaved changes to it, builds, and runs the impacted tests on instrumented binaries ([docs](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing)).

Jest and Vitest pick tests from the module graph and work on files on disk, so they react to a save, not a keystroke ([Jest](https://jestjs.io/docs/cli), [Vitest](https://vitest.dev/guide/features.html)).

The one property I take from the good ones: there is a map from code to the tests that exercise it, built from what the tests actually touched, and the map is never trusted past what it knows. NCrunch tells you to run everything before you commit. testmon reruns last time's failures. TIA runs all tests when it's out of its depth. Of the group, only Wallaby, Live Unit Testing and (going by its wording) NCrunch react before you save. That second thing, reacting to the buffer, is the part I most wanted.

## What F# and .NET don't hand you

Visual Studio's Live Unit Testing page says it is "supported only in .NET". The 2017 article named C# and Visual Basic, and the real-time test discovery post says that feature is "powered by the Roslyn compiler" and "only available for C# and Visual Basic projects" ([overview](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing-intro?view=vs-2022), [2017 article](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2017), [.NET blog](https://devblogs.microsoft.com/dotnet/real-time-test-discovery/)). The current pages never mention F#. I read no Microsoft statement saying F# is unsupported, so all I'll say is that as of 2026-10-01 none of the pages I read says it is supported.

F# has no Roslyn. The thing that can check an unsaved F# buffer against your loaded project is the F# compiler's service, and an FSI session is an instance of it with your project already referenced. That's the seat I use.

The tests F# people write are mostly Expecto `testList` values with FsCheck properties inside. There's no attribute on each leaf to find in source, so SageFs reflects each `[<Tests>]` binding and flattens it into leaf cases ([`LiveTestingExecutors.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingExecutors.fs#L615-L638)). xUnit, NUnit, MSTest and TUnit work too ([built-in list](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingExecutors.fs#L687)).

Pending and focused Expecto tests are read the way Expecto reads them. Before it runs anything, the executor reads each flattened test's `state` and `focusOn` ([`executeReflected`](https://github.com/WillEhrendreich/SageFs/blob/be781645/SageFs.Core/Features/LiveTestingExecutors.fs#L666-L681), [`readFocus`](https://github.com/WillEhrendreich/SageFs/blob/be781645/SageFs.Core/Features/LiveTestingExecutors.fs#L693-L714)). A `ptest`, `ptestCase` or `ptestList` is never run and comes back as skipped with the reason `pending (ptest)`. When anything in the assembly is focused (`ftest`), Expecto runs only the focused tests, so the rest come back as skipped with the reason `not focused`. The rule is one small function over closed unions ([`ExpectoDisposition.decide`](https://github.com/WillEhrendreich/SageFs/blob/be781645/SageFs.Core/Features/LiveTestingExecutors.fs#L341-L350)). If a test's state can't be read, its body is not run and it is reported as not run. A skip is not a pass, so a `run_tests` receipt for two passing tests and a `ptest` reads `2 passed, 0 failed, 1 skipped, 0 did not report`, the verdict is `Incomplete`, and the text says "This is not green". Before this, the executor read only a test's name and body, ran the `ptest` body, and the same project read `3 passed, 0 failed, 0 skipped, 0 did not report` with the verdict `AllPassed`. A test that compares the executor with Expecto's own runner (`Impl.evalTestsSilent`) on generated mixes of normal, focused and pending tests holds this ([`ExpectoPendingTests.fs`](https://github.com/WillEhrendreich/SageFs/blob/be781645/SageFs.Tests/ExpectoPendingTests.fs)), and a daemon test checks the receipt itself ([`ExpectoPendingOutcomeTests.fs`](https://github.com/WillEhrendreich/SageFs/blob/be781645/SageFs.Tests/ExpectoPendingOutcomeTests.fs)). One gap is left: a binding that holds no test at all, such as an empty `ftestList` on its own, gives the executor nothing to read focus from, so it does not skip the other bindings.

And a default test run doesn't record which source lines a test touched. If you want a map from code to tests you have to build the recorder yourself.

## One keystroke, in the order the data moves

```
 keystroke in the editor
    |  300 ms after the last edit (VS Code)
    v
 POST /api/sessions/{sid}/buffer-changed      (the whole unsaved buffer)
    v
 only comments, blank lines or trailing space changed? --yes--> keep the check
    | no                                                  pending for the real edit,
    v                                                     queue nothing new
 tree-sitter (50 ms): where are the tests?    FCS type-check of the whole buffer
                                              (300 ms, backing off to 2 s)
                                                   |-- errors --> BlockedByCompileErrors,
                                                   |              last results stay
                                                   v
                       which tests?  name delta + dependency graph
                                     + coverage bitmaps + file scope
                                     + changed lines against per-test coverage
                                     nothing narrows a compiled file --> all discovered tests
                                                   v   (decision + "why" label)
                       paused, or outside the scope? --> held back, said so
                                                   v
                       eval the buffer into the live FSI session
                                                   |-- eval fails --> nothing runs
                                                   v
                       run the selected tests, stream results in batches
                       (rows say "Evaluated")
                                                   v
                       read each test's coverage --> stored per test, used by the next selection
                                                   v
                       quiet for 2 s --> one real build of the saved text, tests run again
                       (rows say "VerifiedByBuild" or "BuildDisagrees")
```

### Session start: the recorder

Before any editing happens, the project outputs get shadow-copied and instrumented once with Cecil ([`ActorCreation.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/ActorCreation.fs#L116-L134)). The instrumenter reads every non-hidden sequence point from the PDB, including the ones inside F# closures, injects a static class with a `bool[]` called `Hits`, and inserts a `Hit(slot)` call at each point ([`CoverageInstrumenter.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/CoverageInstrumenter.fs#L16-L24), [`Hits`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/CoverageInstrumenter.fs#L99-L104)). It also keeps the hash of each source line as it was compiled, for a file whose bytes on disk still match the checksum the compiler wrote into the PDB ([`baselinesOf`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/CoverageInstrumenter.fs#L60-L74)). A circuit breaker turns instrumentation off for the session after three straight failures ([same file](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/CoverageInstrumenter.fs#L351-L396)). Probes are booleans, not counts, so what you get back is a bitmap.

This is paid once, and it scales with project count. I haven't measured it on a large solution.

### The buffer leaves the editor

The VS Code extension waits 300 ms after the last edit and posts the whole unsaved buffer ([`Extension.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/sagefs-vscode/src/Extension.fs#L2385-L2435)). The daemon accepts it at `POST /api/sessions/{sid}/buffer-changed`, answers 202, and hands it to the Elm loop as `BufferContentChanged` ([`McpServer.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/McpServer.fs#L2819-L2843)). Any client that can POST can drive it.

The first check is cheap. The buffer is normalized and compared to the last one. Comments are dropped, blank lines and trailing space are dropped, and strings are kept. F# indentation means something, so the normalizer keeps the column each line starts at and a single space between tokens. Moving a line into or out of an offside block, or `x -1` to `x - 1`, is an edit. If the normalized buffers match, no new check is queued, and a check already pending for the real edit typed just before the comment stays ([`TriviaNormalization`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L94-L197), [`onKeystroke`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L681-L713)). Before 2026-10-01 that normalizer threw all whitespace away and a trivia keystroke cancelled the check for the edit before it. Both are fixed, with scenario tests behind them ([`LiveTestingAfterTypeCheckScenarioTests.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Tests/LiveTestingAfterTypeCheckScenarioTests.fs)).

### Two debounces, two passes

A 50 ms pause starts tree-sitter, and a 300 ms pause starts the type-check, which backs off to 2 s when further typing keeps cancelling the checks ([`Timeouts.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Timeouts.fs#L159-L169)). None of those numbers has a recorded reason; the file says so next to each one. Tree-sitter finds where the tests are in the buffer, the one stage that doesn't need the code to compile, and it only finds them ([`TestTreeSitter.discover`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/TestTreeSitter.fs#L106-L118)). The native library is looked up per runtime id for win, linux and osx on x64 and arm64, and if it's missing, discovery from source returns nothing and logs why ([lookup](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/TestTreeSitter.fs#L39-L66)).

The type-check is `ParseAndCheckInteraction` on the whole buffer in the live session, with symbol uses extracted when there are no blocking errors ([`Diagnostics.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/Diagnostics.fs#L102-L123), [`SageFsEffectHandler.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L498-L564)). The whole buffer, not one function. There's no MSBuild on this path and no copy of your repo to get wrong.

If it fails on a keystroke, nothing is evaluated and nothing is run. The state becomes `BlockedByCompileErrors` with the file and the error count, and the last good results stay on screen ([`LiveTestActivity.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestActivity.fs#L125-L136), [the `Failed` branch](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L998-L1016)). A save is the exception: a compiled file that fails the check on save queues a rebuild so a real compiler can say the real error ([`fallbackRebuildAfterFailedTypeCheck`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L374-L414)). Don't expect test feedback on code that doesn't compile. What you get is the previous answer, labeled as blocked.

### Picking the tests

This is the map, and it has four sources that get merged, plus a floor under them.

The first is names. The type-check yields every symbol the file uses, and SageFs builds a dependency graph from them: which production symbols each test references, plus a call graph through the production code so a test reaches things transitively ([`buildFromSymbolUses`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L2505-L2548)). The symbols whose names moved are looked up in that graph ([`findAffected`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L2415-L2419)). The second is coverage: tests whose stored bitmaps intersect probes that live in the changed file ([`findCoverageAffected`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L890-L911)). The third covers a body rewrite, which a name delta can't see (`a + b` to `a - b` moves no names): every test that reaches any symbol the file declares gets selected. That ran only on a save or an explicit run until 2026-10-01, so on a keystroke the pane stayed green. It runs on every trigger now, and your run policy can still defer the run and say so.

The fourth narrows the third. An edit that moves no symbol name and changes only lines that recorded coverage speaks for selects only the tests whose own coverage reaches those lines, labeled `line_coverage_narrowing`. Every rule points toward running more. The buffer's lines are hashed (FNV-1a) and compared with the hashes of the text the assembly was compiled from, so the changed lines are measured against what the coverage describes. An edit that inserts or removes a line isn't narrowed. A changed line with no sequence point, or one that runs when the module initializes, isn't narrowed. A test with no usable coverage is always included, and an empty answer widens ([`narrowByLines`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L917-L955), [`LineEdit.between`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L701-L718), [`decideAfterTypeCheck`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L170-L204), [decisions.html](decisions.html#a-line-edit-selects-only-the-tests-that-run-that-line-and-every-doubt-widens-it)).

The floor: if none of that finds anything for a compiled `.fs` file, on any trigger, every discovered test is selected and the decision says `ConservativeFallback` with the reason. Nothing found isn't "nothing affected": a cold dependency graph, or one that hasn't seen the test file that covers the symbol, finds nothing. Scripts (`.fsx`) are evaluated, not compiled, so they keep their narrow answer ([`decideAfterTypeCheck`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L76-L168)). It costs something: a compiled file no test reaches re-runs the suite on each save, and on each keystroke for a category set to `OnEveryChange`. I took that over a pane that stays green on a regression, and the way to make it cheaper is a better graph, not a smaller floor ([decisions.html](decisions.html#one-floor-for-which-tests-does-this-change-affect)).

Every decision carries a cause (keystroke, save, explicit), a precision (`ExactDependencyMatch`, `CoverageApproximation`, `LineCoverageNarrowing`, `ConservativeFallback`, `NoImpactedTests`, `SuppressedByPolicy`), the symbols that moved, the tests chosen, the tests deferred, and a reason sentence. The VS Code status bar tooltip shows it as two lines: `Last run:` says how the tests were chosen and how many, for example "exact dependency match (3 selected)", "coverage widened the rerun (5 selected)" or "conservative fallback rebuild (12 selected)", and `Why:` carries the daemon's reason sentence ([`describeSelection`](https://github.com/WillEhrendreich/SageFs/blob/master/sagefs-vscode/src/LiveTestingTypes.fs), [`SelectionPrecision` and `LiveTestingDecision`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L1123-L1160)). Run policy decides what runs on every change: unit and property tests on every change, integration and browser on demand, architecture on save ([`RunPolicyDefaults`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L211-L227)).

The cohort landing gate (merging agents' work) has a stricter cousin, `verificationTestSet`, which never returns an empty set for a real diff against a real suite ([`AffectedTests.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/AffectedTests.fs#L48-L82)). The live loop used to be rougher than that. Now they share the floor described above.

### A build input changes

Saves reach live testing through the daemon's file watcher as well as through the editor. Until 2026-11-11 that watcher saw `.fs` and `.fsx` files only, so a changed package version, a `Directory.Build.props`, or a fixture a test reads never reached live testing, and the status stayed green over a build that no longer matched the files. It now sees every file under the session's directory except bin, obj, .git, nested checkouts and the other pruned folders, and sorts each one by name ([`LiveTestBuildInput.classify`](../SageFs.Core/LiveTestWatcherCore.fs)):

- `.fs` and `.fsx` take the path described above, unchanged.
- A project file (`.fsproj`, `.csproj`, `.vbproj`) is diffed against the text the watcher read when it started watching, with the landing gate's rule (`ProjectFileChange.select`, see [decisions.html](decisions.html)): an edit that only changes the compile list runs the tests covering the files at and after the first difference, and a changed reference, package, property or any other item runs the whole suite. A save that states the same things (whitespace, a comment) runs nothing.
- Props, targets, `packages.lock.json`, `global.json`, a NuGet config, a signature or C# file, and any other file in the project's folder (a resource, a data file a test reads) run the whole suite when their content changes. A save with the same bytes runs nothing, except the first save of each after the watcher starts, which has nothing to compare with. A test that writes a data file into its own project folder on every run will start another run each time, so keep run output under bin, obj or a folder outside the project.
- Documents and scripts (`.md`, `.txt`, `.sh`, `.yml` and the rest of the landing gate's inert list), dotfiles, editor scratch files (`name~`, `.name.swp`, vim's `4913` probe, `.#name`, `name.tmp`) and Verify's `*.received.*` files are dropped, and the watcher log says so.

Either way the session is rebuilt first, since only a build reads these files, and the selected tests go stale until the rebuild's run reports ([`onBuildInputChanged`](../SageFs.Core/Features/LiveTestingCycle.fs)). A narrow that selects nothing runs the whole suite, the same floor as everywhere else. While a run is in flight the rebuild waits in the queue and starts when the run ends.

### Eval, then run

For a compiled `.fs` file with known buffer content, the effect that would have run or rebuilt the stale DLL is retargeted into evaluating the buffer in FSI and then running exactly the tests already selected ([`redirectToEvalBuffer`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L347-L372), [`SageFsEffectHandler.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L565-L624)). In the worker, the buffer goes through the same whole-file preprocessing the file watcher uses, so module identity is kept. If the eval fails, neither the compilation cache nor the discovery nor the last results are touched ([`evalLiveTestFile`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Host/WorkerMain.fs#L373-L448)). The discovery from that eval is merged over the compiled baseline by test id, and the dynamic one wins, so an edited-but-unsaved test overrides its compiled twin and doesn't show up twice ([`TestDiscoveryMerge.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/TestDiscoveryMerge.fs#L3-L26)).

Then the run. Each new run cancels the older one through a cancellation chain ([`CancellationChain`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingExecutors.fs#L1177-L1204)). Results stream back and get flushed to the model in batches of 25 or every 200 ms ([`SageFsEffectHandler.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L816-L840)). The daemon asks for a parallelism of `max 4 (ProcessorCount / 2)`, and a project with instrumented assemblies runs one test at a time anyway, see the coverage section. The per-test timeout defaults to 5 s and the whole run to 2 minutes, both overridable ([`Timeouts.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Timeouts.fs#L136-L147)). If you edit while a run is in flight, results that land afterward judged the old code, so they never become the row: each one is recorded as no result (`CodeEdited`), the row goes stale, and the run the edit owes starts when the old one ends. That holds for a script keystroke and for a save the worker's hook reloaded too, which used to be dropped when the session was busy ([`SupersededResults`, `QueuedMeans.RunOnly`](../SageFs.Core/Features/LiveTestingCycle.fs)). A test that outlives the per-test timeout fails as timed out, red, and a test cancelled mid-run reports no result; neither is a skip. A test the worker no longer knows (renamed or deleted in the buffer) answers not run, and its old green row goes stale. Any requested test that never reported gets a truthful "no result" with a reason, never a made-up failure ([`SageFsEffectHandler.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L853-L869)). The receipt that `run_tests` returns says the same thing for agents: a run where something didn't report is `Incomplete`, "never to be read as green" ([`TestRunReceipt.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/TestRunReceipt.fs#L46-L53)). The receipt also says whether the files on disk are newer than the build the tests ran against, and a pass over a build that is behind them is `PassedOnStaleSource`, never `AllPassed` (see [`run_tests`](mcp-tools.html#testing-and-verification)).

### Coverage comes back around

After each test, the worker reads the coverage the instrumented assemblies recorded, as a packed bitmap, and clears the hits, so the reading belongs to that one test ([`readAndClear`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/CoverageProbes.fs#L30-L38), [`HostAgent.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/HostAgent.fs#L725-L745)). It goes back as a coverage frame beside the test's result, and the daemon stores it against that test alone ([`WorkerHttpTransport.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Host/WorkerHttpTransport.fs#L536-L586), [`SageFsEffectHandler.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L824-L841)). The probes of a process are one shared array, so two tests running at once cannot be told apart, which is why a run against a project with instrumented assemblies runs its tests one at a time. A run with nothing instrumented keeps the parallel path. Dynamic assemblies are skipped when reading, so only code loaded from disk is counted, and a reading that hit nothing never replaces a recorded bitmap (after a keystroke eval the tests run against dynamic code, and an empty reading would blank the coverage marks).

That does two things. The coverage marks and the file annotations list, per line, exactly the tests whose own recorded coverage reaches it ([`projectWithCoverage`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/TestAnnotations.fs#L414-L452), [`coveringTestsByLine`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L959-L992)). And selection can use it, as above. The reasoning, and the cost of the serial runs, are in [decisions.html](decisions.html#coverage-is-attributed-per-test-so-tests-that-touch-instrumented-code-run-one-at-a-time).

### What a row says it ran against

A keystroke's tests run against code the session evaluated, not against a build, and every row says which. `Compiled` is a build's output, `Evaluated` is evaluated code that nothing has confirmed, `VerifiedByBuild` is evaluated and then run again against a real build of the same text with the same verdict, and `BuildDisagrees` carries why: the compiler's message, both verdicts, or that the build never answered ([`ResultProvenance`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L418-L447)). A disagreeing row's verdict is the build's, because that is what ships. Once the editing has been quiet for two seconds, one build of the saved text is started through the session's own rebuild, and the tests run again against what it made ([`liveTestConfirmationQuiet`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Timeouts.fs#L184), [`startConfirmationBuild`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsEffectHandler.fs#L215-L262)). The verdict from the eval is on screen the whole time, the confirmation never delays it, an eval that ran no tests starts no build, and a burst of edits costs one build, for the last text. The decision is a pure state machine, `BuildConfirmation.step`, folded under seeded scenarios with three twins that reproduce the bugs its invariants exist for ([`BuildConfirmation.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/BuildConfirmation.fs#L135-L140), `SageFs.Simulation/BuildConfirmationSim.fs`).

Two limits. A build can only confirm what is on disk, so an unsaved buffer stays `Evaluated`. And where the confirming build runs depends on what the session holds. A session that holds nothing a swap would lose has its worker swapped for one on the new build. A session that holds something (a value bound in the REPL, a script loaded, the evaluated buffer of another file, a test held for a debugger) is confirmed in a throwaway worker that is stopped afterwards, so the session's own worker is never touched. When there is no room for a second worker, or the session's startup starts an app on a fixed port, the rows say `NotConfirmed` and why, and the session is left alone ([decisions.html](decisions.html#a-confirming-build-runs-in-a-throwaway-worker-when-a-swap-would-lose-something)).

### Pause and scope

Pause holds test runs back while the session keeps type-checking and keeps its evaluated code current, so resuming judges the code as it is now: it evaluates the latest buffer again and runs the tests that went stale ([`LivePauseChanged`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/SageFsApp.fs#L1715-L1751)). A scope (every test, only the ones matching a pattern, or all but the ones matching) narrows what automatic runs touch, and an explicit run always runs what it names ([`LivePause` and `TestScope`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L235-L252), [the selection](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingCycle.fs#L222-L251), [the routes](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/McpServer.fs#L3306-L3310): `/api/live-testing/pause`, `/resume`, `/scope`). What Visual Studio has beyond that, and why it isn't copied, is in [decisions.html](decisions.html#pause-and-an-include-or-exclude-set-are-enough-memory-caps-and-battery-detection-are-not-copied).

### Debugging a failing test

In VS Code a failing test gets a Debug lens beside its result, a Debug link in the hover of its mark, and Debug Test in the Test Explorer ([lens](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/sagefs-vscode/src/TestCodeLensProvider.fs#L95-L104), [Test Explorer profile](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/sagefs-vscode/src/TestControllerAdapter.fs#L140-L158)). The daemon asks the host that runs your tests to hold one test and answers with its process id, the editor attaches a `coreclr` debugger to it, and the host releases the test only when a debugger is attached ([`/api/live-testing/debug`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs/McpServer.fs#L3417-L3445), [`LIVE_TESTING_GUIDE.html`](LIVE_TESTING_GUIDE.html#debugging-a-failing-test)). Breakpoints bind in your compiled project code. Code the session evaluated has no PDB, so they don't bind there, and SageFs says so when you start.

Neovim can do the same from the editor. In the sagefs.nvim repo, `:SageFsDebugTest` (or `<leader>rtg`) asks the daemon to hold the test, attaches netcoredbg through nvim-dap, and releases the test once the adapter has attached ([the plugin's README](https://github.com/WillEhrendreich/sagefs.nvim#debugging-a-failing-test)). That plugin's specs run the hold-attach-release steps against a fake nvim-dap. I haven't run a full attach from this repo's tests, for Neovim or for VS Code.

## Compared with Visual Studio Live Unit Testing

Live Unit Testing is Enterprise-only and shipped in Visual Studio 2017 ([launch post](https://devblogs.microsoft.com/visualstudio/live-unit-testing-in-visual-studio-2017-enterprise/)). It is a mature product with a debugger attached, and I'm comparing a one-person tool to it. Where a row says what Visual Studio does, the source is Microsoft's [configure and use](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2022) page, read on 2026-10-01.

| | Visual Studio Enterprise | SageFs |
|---|---|---|
| What it builds | A private workspace copy of the repo with unsaved edits applied, scoped parallel MSBuild builds of the relevant projects ([configure](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2022), [better and faster](https://devblogs.microsoft.com/visualstudio/live-unit-testing-preview-better-and-faster/)) | No workspace. The buffer is type-checked and evaluated in the live FSI session |
| Code that doesn't compile | Errors go to the Output window ([FAQ](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing-faq?view=vs-2022)). What the glyphs show during a red build isn't documented | Nothing runs, last results stay, state says blocked |
| Picking tests | "impacted tests". The mechanism isn't documented | Four signals and a floor, each decision labeled with its precision and reason. A compiled file where all of them find nothing runs every discovered test |
| Coverage per line | Hover the glyph for how many tests hit the line, select it for the tests by name and result. From instrumented binaries of the real build | Per line, the exact tests whose own recorded coverage reaches it, from instrumented binaries of your project outputs (not of a fresh build of your unsaved text) |
| How tests run | In each test assembly one after another ([Learn](https://learn.microsoft.com/en-us/visualstudio/test/live-unit-testing?view=vs-2022)) | One at a time on a project with instrumented assemblies, so each reading belongs to one test. Parallel on a project with none |
| What a result ran against | Binaries from a real MSBuild of the solution | Each row says: evaluated code, a real build, a real build that agreed with the eval, or a real build that disagreed and why |
| Pause, include and exclude | Pause (the glyphs go away while paused, and it catches up on continue). Options to pause during a build and a debug, and on low battery. A playlist you edit from the tool window, from a right-click on a test method, or from Solution Explorer. A memory cap | Pause, which keeps type-checking and holds only the runs. An include or exclude set by name pattern that automatic runs obey. No battery or debugger detection, no memory cap, no per-method gesture in the editor, see [decisions.html](decisions.html#pause-and-an-include-or-exclude-set-are-enough-memory-caps-and-battery-detection-are-not-copied) |
| Debugging a failure | The glyph's tooltip reruns or debugs the set of tests, or only the ones you select | VS Code and Neovim, one test at a time. In VS Code a failing test's Debug lens, hover link and Test Explorer profile attach a .NET debugger to the process that runs it. In Neovim `:SageFsDebugTest` does it through nvim-dap |
| Latency | Not documented | Measured on one machine and one small project, see "What's still rough" |
| Frameworks | xUnit, NUnit, MSTest | Expecto is driven end to end. xUnit (v2 and v3), NUnit, MSTest and TUnit share one attribute path that is tested only with made-up attributes, so for those four "discover, run and report" is expected to work and unproven |
| Languages | .NET. F# not mentioned on the current pages I read | F# |
| Platform, cost | Windows, ProjFS-backed workspace, Enterprise edition | Windows, Linux and macOS in the package (tree-sitter binaries per runtime id), though my CI runs on Linux only. MIT licensed |
| Clients | Visual Studio | HTTP and SSE, so any editor. The VS Code client is in the repo, the Neovim client is in another repo. The Visual Studio extension is deprecated |

Where Visual Studio is still ahead.

- Debugging. Its tooltip debugs several tests at once, and mine debugs one. I haven't run a full attach with the C# extension's debugger from this repo's tests, only the host side against a real isolated host, plus contract tests that run without VS Code ([guide](LIVE_TESTING_GUIDE.html#debugging-a-failing-test)). Neovim can debug a test from the editor too (`:SageFsDebugTest` in the sagefs.nvim repo), and that path is run end to end in my own tests: a real debugger (netcoredbg) attaches to the process the daemon names, and the held test runs when the debugger lets it go ([`DebugAttachJourneyTests.fs`](../SageFs.Tests/DebugAttachJourneyTests.fs), in the `--integration-lt` tier). A debug run isn't recorded in the live-testing state, so the marks update on the next normal run, and feeding debug runs into that state is still to do. Several tests at once and breakpoints in evaluated code are further out. The queued items are "Debug failing tests properly in VS Code" and "Debug a failing test from Neovim" on the [roadmap](roadmap.html).
- What it runs against. A keystroke's tests run against FSI-evaluated code, and a type-check in an FSI session isn't your project's compile, so something only the real build catches can pass here and fail in `dotnet build`. What I did is smaller than matching it: each row says what it ran against, and a real build of the saved text confirms or contradicts the eval once the editing goes quiet, with the compiler's own message when it fails. That makes the gap visible and short. It doesn't make it zero. An unsaved buffer is never confirmed. A session that holds nothing a swap would lose still has its worker replaced by the confirming build, and a check or an eval typed while that happens waits for the replacement (it asks a worker only when the session manager says one is Ready) and is judged as soon as there is one. That part merged after v0.6.875 and is in v0.6.882 and every release since. A session that holds something is confirmed in a throwaway worker instead, which keeps its REPL state and costs the same two workers at once that a swap already did ([decisions.html](decisions.html#a-confirming-build-runs-in-a-throwaway-worker-when-a-swap-would-lose-something)). Plan, written 2026-11-10: applying a throwaway worker's coverage, and timing a confirmation, are under "What is left" in [the plan](plans/confirm-builds-without-restarting-the-worker.html).
- Scale tooling. A playlist you edit with a right-click, pausing on battery or while you debug, and a memory cap. I have pause and a pattern scope, and no gesture on a test that edits the scope: the scope is typed as a pattern. Pausing on battery or while debugging and a memory cap are left out on purpose, and [decisions.html](decisions.html#pause-and-an-include-or-exclude-set-are-enough-memory-caps-and-battery-detection-are-not-copied) says why. Plan, written 2026-11-11: an include and an exclude action on a test in VS Code and Neovim that adds its name to the session's scope through the existing `/api/live-testing/scope` route, so a playlist is a click and not a pattern.
- Isolation. Its build happens in its own workspace so a regular build can't interfere. Mine shares the one session's project, and the confirming build now runs apart from the session's own worker when that worker holds anything, in a throwaway worker of its own. The build itself is still the project's normal build in its normal output folder, so a regular `dotnet build` running at the same moment can still collide with it. Plan, written 2026-11-10: a folder of its own for the confirming build is under "What is left" in [the plan](plans/confirm-builds-without-restarting-the-worker.html).
- Years. It's been shipping since 2017, and nothing I do closes that. Only time does, so the work goes into the other rows on the [roadmap](roadmap.html).

Where the table shows the two level: the tests behind each line, which Visual Studio lists by name when you select the glyph and SageFs lists in the per-line coverage data it sends the editor, and tests running one after another inside an assembly (or one project, for me). On those rows I'm not claiming better, only that Microsoft isn't ahead.

What I think I do better is smaller than it sounds. There's no repo copy to get wrong, so the failures you hit are about your code. Comment, blank-line and trailing-space edits don't start a run, where Visual Studio starts a build "whenever it detects that source files have changed" and I found nothing in its docs that treats a comment edit differently. You can ask why a test ran. Expecto and FsCheck are first class. A failing FsCheck property carries its shrunk counterexample and is classed as a real failure, not a flake ([`FlakyClassification`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L1444-L1456)). And it runs on Linux.

## What's still rough

Per-test coverage costs parallelism. To attribute a reading to one test, the tests of an instrumented project run one at a time. Visual Studio runs the tests of an assembly one after another too, but I measured the keystroke path on the small sample below and nothing else, so I can't tell you what it costs a suite of slow tests. Line narrowing widens on any doubt, and I've exercised it in unit tests and on the sample, not on a large project.

The floor trades speed for never reading green on nothing. A compiled file that no test reaches re-runs the suite on each save, and on each keystroke for a category set to `OnEveryChange`. If that hurts on a real project, the fix is a better graph.

The test-to-symbol graph attributes references to a test by a line-range heuristic: each test definition owns lines until the next one starts, and test functions are recognized by a `.Tests.` module name ([`LiveTestingTypes.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L2461-L2548), [`.Tests.`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L61-L63)). It's built from the symbol uses of files that were type-checked in this session, so a test file nothing has checked yet contributes nothing, which is what the floor is for.

Expecto leaves come from reflection, so they have no source line. Tree-sitter finds the `[<Tests>]` binding but not each `testCase`, so a marker on one specific `testCase` line isn't something you get today. Expecto categories come from the test name only, so a slow database test without "integration" in its name runs on every change under the default policy ([`LiveTestingExecutors.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingExecutors.fs#L627-L638)).

Code redefined by an eval lives in a dynamic assembly, which the coverage read skips. For a function you just edited the markers keep the last coverage that was recorded against a real build of it, so they describe the code as it was, not as you've typed it, until the confirming build runs the tests again. A confirmation that runs in a throwaway worker applies none of its coverage, because that worker instrumented its own copy of the build: the markers and per-test bitmaps stay those of the session's own worker until it is swapped.

An edit typed while the confirming build replaces the worker used to be lost, and isn't now. That fix merged on 2026-10-01 after v0.6.875 was tagged, and it is in v0.6.882 and every release since. A check or an eval waits for the session to be Ready, asks only the worker that is, and believes an answer only from the worker it asked ([decisions.html](decisions.html#a-check-or-an-eval-asks-a-worker-only-when-one-is-ready-and-waits-for-one-while-it-is-being-replaced)). What's left there is small. A wait is bounded by the same 30 s a rebuild gives the replacement, and a check that waits it out is dropped, not retried when the worker finally comes. The other effects that read a proxy, running affected tests and discovery, still drop a request that finds none. And line narrowing measures a save against the text the last build compiled, so putting back an edit that was made after that build, inside the quiet window, can select too little and leave the edit's red on screen.

Tests run inside the FSI host process alongside your session. I read the timeout and the cancellation and didn't look into what a test that blocks a thread or kills the process does to the session.

Debugging is one test at a time in VS Code and in Neovim, and breakpoints don't bind in code the session evaluated. The flake rules (a window of ten runs, flaky at two flips with at least three samples) are numbers I picked. A flip counts only between two runs with no edit, save or hot reload between them, so a red then a green across an edit is the edit's verdict and never a flake; a skip, a test no runner knew and one that never reported are not samples at all. A quarantined test's row says `Quarantined` with the reason in VS Code and Neovim, the dashboard's test grid gives it its own colour, says `quarantined` in the cell's label and counts it under `Quarantined` in the filter bar, and no surface shows its last verdict; the summaries count it as not passed. The quarantine and the flake windows are saved with the test cache, so a restart neither releases nor forgets them. There is no manual quarantine: an exclude scope does that job and says what it does ([`FlakyDefaults`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Core/Features/LiveTestingTypes.fs#L1439-L1442)).

Latency is measured now, on one machine and one small project, and that is all the figures say. The `--integration-lt` tier starts a daemon, opens the FromCSharp sample (11 Expecto tests), and times two paths through the daemon's own `/events` stream, 20 samples each after 2 warm-up edits ([`LiveTestingLatencyTests.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Tests/LiveTestingLatencyTests.fs#L1-L28), [`LatencyStats.fs`](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Tests/LatencyStats.fs#L14-L19)). From the edit leaving the client to the verdict on the edited function's test: p50 712 ms, p95 783 ms, min 651 ms, max 793 ms (the editor's own 300 ms pause is not in it). From a save to the suite back at all green with nothing running: p50 542 ms, p95 631 ms, min 512 ms, max 649 ms. The machine was an AMD Ryzen 7 5800XT, 16 threads, 24 GiB as the runtime reports it, Linux, .NET 11.0.0-rc.1, with other jobs running on it, and the tier was run several times: the p50s stayed within 700 to 720 ms and 536 to 620 ms. The first measurement, recorded next to the bound, was a p95 of 742 ms over 20 edits and 709 ms over 20 saves on the same machine. The tier fails if the keystroke p95 passes 1.8 s or the save p95 passes 1.5 s, about twice the worst p95 the release gate has recorded (884 ms and 750 ms, on 2026-10-04; two later runs read 657 to 667 ms and 429 to 460 ms). Until 2026-11-11 both bounds were 3 s, so a threefold slowdown passed ([`TestTimeouts.fs`](../SageFs.Tests/TestTimeouts.fs), `liveTestingKeystrokeP95Bound`). I have no figure for a large solution, for a project with slow tests, or for the first edit after a restart (the two warm-up edits are dropped), and none for the confirming build. Visual Studio documents no figure, so I have nothing to put beside mine.

## If you want to poke at it

- Run `list_tests` and `run_tests` over MCP and read the receipt. Ask `explain_test_failure` about a failure, and `coverage_intel` about a file.
- Enable live testing on a session and watch `GET /api/live-testing/status` while you edit a function a test covers. The integration test `HttpApiIntegrationTests.fs` ("editing a compiled F# file reruns tests against rebuilt output") drives this against the smoke sample ([test](https://github.com/WillEhrendreich/SageFs/blob/e47b355b/SageFs.Tests/HttpApiIntegrationTests.fs#L1138-L1264)).
- Break the syntax mid-edit and check the status says blocked while the old results stay.
- Pause with `POST /api/live-testing/pause`, edit, and resume: the stale tests run against the latest buffer.
- Unit-level: `LiveTestingDecisionScenarioTests`, `LiveTestingAfterTypeCheckScenarioTests`, `LiveTestingPerTestCoverageTests`, `LiveTestingProvenanceTests`, `LiveTestingScaleControlsTests`, `BuildConfirmationSimTests`, `CoverageInstrumenterTests`, `AffectedTestsTests`, `TestRunReceiptTests`, `TestDebugTests`. The real-path journeys are in `LiveTestingJourneyTests`, and the latency measurement runs under `--integration-lt`. Full unfiltered run is `dotnet SageFs.Tests/bin/Release/net11.0/SageFs.Tests.dll --summary`, and a filtered run that matches nothing exits 0, so look for the test name in the output.
