Automatic Test Milestone Recording
In long agentic coding sessions, it is easy to lose track of which commit last had a green test suite — or for an agent to claim "tests pass" based on a compile-only run or a stale log.
Kompile solves this at the harness layer with Automatic Test Milestone Recording (TestMilestoneCapture): whenever an authorized test command runs through build, process, or bash, Kompile observes the real execution, parses structured test results, tags the Git HEAD commit and session/subagent origin, and writes an immutable milestone snapshot under <repo>/.kompile/test-milestones/milestones/<id>.json.
How automatic capture works
flowchart LR
CMD["Authorized Test Command\n(build / process / bash)"] --> DET["TestRunDetector\n(Command intent + runner detection;\nrejects compiles, dry-runs & log replays)"]
DET --> OBS["TestMilestoneCapture\nLive stdout/stderr line parsing +\nTestReportReader + JGit HEAD revision"]
OBS --> STORE["TestMilestoneStore\nAtomic write (.kompile/test-milestones/)\nsource=harness • executionId • logReference"]
STORE --> LIVE["Live Harness Visibility\nTestMilestoneDisplay card (TUI) +\nTranscript system notice + /test-milestones + Web /insights"]Observed evidence vs. agent-reported records
Kompile clearly distinguishes the two writers to the milestone store so you can always tell observed truth from agent claims:
| Writer | source | Attribution & Safeguards |
|---|---|---|
Automatic harness capture (TestMilestoneCapture) | harness | Created only after command authorization, never from model prose. Stamps executionId, logReference, framework, parsed counts (totalTests, passed, failed, errors, skipped), outcome, module, and launch Git HEAD (via JGit, without spawning a git subprocess). |
Manual MCP call (test_milestone action=record|fail) | manual | Explicitly tagged source=manual, basis=agent-reported. Validates nonnegative integer counts and refuses a passing=true record with non-zero failures. |
Built-in anti-spoofing & accuracy safeguards
TestRunDetector fails closed against false positives so unrelated commands never pollute your milestone history:
- Compilation is never test evidence: Build-only tools (
javac,kotlinc,gcc,g++,clang,nvcc,tsc,ninja,msbuild,docker,podman) never generate test milestones. - Dry-runs and skipped suites are suppressed: Flags like
-DskipTests,-Dmaven.test.skip,--no-run,--collect-only,--list-tests,--gtest_list_tests,cargo test -- --list,go test -c|-list,ctest -N,--dry-run, and--without-testingare suppressed automatically. - Replayed output cannot spoof a run: Commands containing output-replay utilities (
cat,grep,tail,head,echo,sed,awk,git) are excluded so printing an old test summary never records a fake milestone. - Command substitution fails closed: Shell substitutions (
$(...), backticks,<(...),>(...)) disable automatic attribution rather than guessing which command ran. - Atomic writes & duplicate-free live delivery:
TestMilestoneStorewrites to a temp file and hard-links atomically without overwriting existing IDs. If live activity-journal delivery hits lock contention, it retries only the journal delivery (never re-running tests) and surfaces an explicit saved-ID warning so the agent never reruns or duplicates a record.
Supported test frameworks (automatic detection)
Automatic capture is language- and build-system-agnostic, recognizing runners and output formats across major ecosystems out of the box:
| Ecosystem | Automatically Detected Runners & Formats |
|---|---|
| JVM | Maven (mvn/mvnw Surefire & Failsafe), Gradle (gradle/gradlew), sbt, direct java JUnit Platform / TestNG / ScalaTest |
| JavaScript / TypeScript | jest, vitest, mocha, playwright, node --test, npm/pnpm/yarn/bun test |
| Python & Math | pytest, python -m unittest, python -m doctest, SageMath (sage -t) |
| Rust & Go | cargo test, go test |
| C / C++ / Embedded | ctest, cmake --build ... test, GoogleTest (--gtest_*), Catch2, PlatformIO (pio test) |
| .NET & Apple | dotnet test, swift test, xcodebuild test / test-without-building |
| Dart & Flutter | dart test, flutter test |
| Ruby, Perl, Shell, SQL, R, Lua, PowerShell, Vim | rspec, rake test|spec, prove (TAP), pg_prove (pgTAP), bats, shellspec, shunit2, busted, Invoke-Pester, testthat::test, Vader, make test|check, plus generic TAP and custom regex rules |
Inspecting test milestones
1. In chat & Web Harness (/test-milestones)
/test-milestones is a fast, read-only, model-free report available identically in terminal chat and the Web Harness (project-only store containment in Web, excluding global home and escaping symlinks):
/test-milestones # Current session, auto + agent sources, newest 20
/test-milestones 50 all # Newest 50 milestones across all sessions in this project
/test-milestones source:auto # Only harness-captured runs (excludes manual records)
/test-milestones source:agent module:cli # Filter by source and module
/test-milestones session:<session-id> # Milestones stamped by one specific sessionLive runs also surface stable-ID milestone cards directly inside the TUI via TestMilestoneDisplay and write post-save notices into the transcript. In the Web Harness, cross-session milestone trends also appear on the /insights tab.
2. Programmatically via MCP (test_milestone)
Agents and automated workflows can query, compare, and track regressions through the test_milestone MCP tool:
- Query & compare:
list,get(id),latest(module),summary,check,compare(from_id,to_id),delete - Manual recording:
record/fail(module,notes,tags,total_tests,passed,failed,errors,skipped— explicitly stampedsource=manual,basis=agent-reported) - Project configuration:
init,config,add_module,remove_module,set_target,status - Regression ledger:
add_regression,remove_regression,list_regressions
Customizing capture per project
Automatic capture works with zero configuration. When a repository has custom test scripts or extra report directories, ask the agent in plain English:
"Configure project test-milestone capture to ignore
smoke-only.sh, read reports fromtarget/surefire-reportsandbuild/test-results, and add a custom rule forrun_custom_suite.shmatchingSUMMARY total=<n> passed=<n> failed=<n>."
The agent updates .kompile/test-milestones/config.json (autoCapture) via the test_milestone tool:
| Setting | Purpose |
|---|---|
enabled / fallbackEnabled | Turn automatic capture or generic summary-line fallback on/off |
disabledFrameworks | Exclude specific runner groups (e.g., pytest, jvm, or * to disable all) |
includeCommands / excludeCommands | Regex allow/exclude filters on executed command strings |
reportPaths | Extra JUnit/Surefire/TRX/JSON report directories or files to inspect |
customRules | Proprietary runner rules pairing commandRegex with a summaryRegex containing named (?<total>...), (?<passed>...), and (?<failed>...) groups |
If a config file contains invalid JSON or a malformed regex, Kompile disables automatic capture safely and surfaces a diagnostic warning only on explicit test invocations — never breaking unrelated shell commands.
Related guides
- LSP & Edit Verification Gate — Fast fail-closed static checks before running full test suites
- Draft Workflow (
draft&draft_batch) — Staging changes while test runs execute - Standard Daily Workflow — Using
/test-milestonesalongside/cost,/usage, and/subagent-breakdown - Auditing & Provenance & The Judge — Evidence-backed verification across sessions