Skip to content

strictSafety: incremental compilation skips the full-graph check when the module list changes in a file other than the entry point #117

Open

Description

@shreknitin89

Summary

With strictSafety auto-enabled on the aggregator module, the aggregator's compile task re-runs as documented. But Kotlin incremental compilation recompiles only the dirty files. If the change is to a module-list function in a different file from the startKoin call, the entry-point file isn't part of the compilation round, and the full-graph check doesn't run. The build passes even though a module was dropped from startKoin.

Environment

Reproduction

Reduced from our app, where steps 2–4 were run for real. The two-file reduction below hasn't been built as a standalone project.

:app, two files:

// AppKoinModules.kt
internal fun appKoinModules(): List<Module> = listOf(
    dataModule,
    networkModule,   // provides types that dataModule needs
    featureModule,
)

// App.kt
class App : Application() {
    override fun onCreate() {
        super.onCreate()
        startKoin { modules(appKoinModules()) }
    }
}
  1. Build once. It's green, and the graph is valid.
  2. Delete networkModule from appKoinModules() in AppKoinModules.kt, the only file edited.
  3. ./gradlew :app:compileDebugKotlin: BUILD SUCCESSFUL, no Koin diagnostics.
  4. ./gradlew :app:compileDebugKotlin --rerun -Pkotlin.incremental=false: fails with hundreds of KOIN-D001s (545 in our app), as expected.

The signature of appKoinModules() doesn't change, so IC has no reason to recompile App.kt, and the compilation round that runs has no entry point in it.

Expected

When strictSafety is active for a module, the full-graph pass should see the entry points even on an incremental round. Two possible ways:

  • Make the compile task non-incremental for aggregator modules.
  • Record the entry-point files and mark them dirty whenever a file contributing to the module graph changes (for example, through the lookup tracker).

Related: #32.

Activity

  1. added this to the 1.2.2 milestone on Oct 22, 2026
  2. arnaudgiuliani commented on Nov 3, 2026

    @arnaudgiuliani
    Member

    Confirmed: strictSafety alone doesn't cover this. IC recompiles only the edited file, so the entry point isn't in that compilation round. Planned for 1.3.0. Until then, a non-incremental build (clean, or -Pkotlin.incremental=false) catches it, so run it that way on CI.

    Thanks @shreknitin89 for the precise analysis 🙏

  3. modified the milestones: 1.2.2, 1.3.0 on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions