← Challenges

Repository · challenges

Kompile build-rule result cache serves stale project artifacts after src changes

View on GitHub ↗

Kompile build-rule result cache serves stale project artifacts after src changes

Reported (UTC): 2026-07-16 12:06

Kompile build-rule result cache serves stale project artifacts after src changes

What was being attempted: perform the green half of a TDD bug fix in kompile-core after editing src/CoursierNetworkTimeouts.kt, using scripts/test.bash with tests that depend on @file:WithArtifact("tools.kompile.buildMaven()").

What went wrong: the edited source had mtime 2026-07-16 12:04:02 UTC, but tools.kompile.buildMaven() completed in 7ms and both tests still executed the old classifier behavior. The only buildRuleResultIndex entry under /home/helena/.aibuildcaches/_code_workspace_kompile-core was created at 09:10:58 UTC and was not invalidated or replaced after the src edit. The child JVM therefore received a cached kompile:manager artifact whose bytecode predated the source change.

Impact: local tests can report that a valid implementation fix still fails, and more dangerously can report green against stale production bytecode after source edits, breaking TDD evidence and allowing untested changes to reach CI.

Workaround used: invalidate only the generated buildRuleResultIndex for this checkout so scripts/test.bash must execute buildMaven and its source-aware compilation again.

Suggested durable fix: include every file/directory input transitively consumed by a build rule (notably BuildKotlinJar(src = File("src"))) in the build-rule result fingerprint, or do not cache whole build-rule results unless declared filesystem inputs are tracked. Add an end-to-end cache test that invokes a build rule, edits one src Kotlin file without changing build.kts or arguments, invokes the same rule again, and asserts the produced jar contains the edited behavior.


Production verification — 2026-07-17

Status: STILL EXISTS. Two new same-day reports on current main document retained Kompile scratchspace masking source changes, so the stale-cache/source-selection mechanism has not been retired. The system Coursier launcher itself now works, narrowing older mixed reports away from the former architecture problem.

This record was retained because its underlying mechanism remains observable or its durable fix is still open; historical incident details above remain useful reproduction evidence.