Skip to content

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 ​

mermaid
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:

WritersourceAttribution & Safeguards
Automatic harness capture (TestMilestoneCapture)harnessCreated 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)manualExplicitly 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-testing are 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: TestMilestoneStore writes 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:

EcosystemAutomatically Detected Runners & Formats
JVMMaven (mvn/mvnw Surefire & Failsafe), Gradle (gradle/gradlew), sbt, direct java JUnit Platform / TestNG / ScalaTest
JavaScript / TypeScriptjest, vitest, mocha, playwright, node --test, npm/pnpm/yarn/bun test
Python & Mathpytest, python -m unittest, python -m doctest, SageMath (sage -t)
Rust & Gocargo test, go test
C / C++ / Embeddedctest, cmake --build ... test, GoogleTest (--gtest_*), Catch2, PlatformIO (pio test)
.NET & Appledotnet test, swift test, xcodebuild test / test-without-building
Dart & Flutterdart test, flutter test
Ruby, Perl, Shell, SQL, R, Lua, PowerShell, Vimrspec, 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):

text
/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 session

Live 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 stamped source=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 from target/surefire-reports and build/test-results, and add a custom rule for run_custom_suite.sh matching SUMMARY total=<n> passed=<n> failed=<n>."

The agent updates .kompile/test-milestones/config.json (autoCapture) via the test_milestone tool:

SettingPurpose
enabled / fallbackEnabledTurn automatic capture or generic summary-line fallback on/off
disabledFrameworksExclude specific runner groups (e.g., pytest, jvm, or * to disable all)
includeCommands / excludeCommandsRegex allow/exclude filters on executed command strings
reportPathsExtra JUnit/Surefire/TRX/JSON report directories or files to inspect
customRulesProprietary 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.


Released under the Apache-2.0 License.