GoDirectory.includeDiscovered (go.dang:682-692) runs the helper with ["go-includes", "--test", workspacePath], where workspacePath is derived from the directory's module root — not the directory itself. Every GoDirectory produced for the same GoModule therefore fires the same helper exec and gets back the same include list.
For a module with N test directories, that's N identical privileged-nesting helper invocations per dagger check run. Each one builds nothing new — it's pure duplication. None of them are cached today (privileged nesting), so the cost is real, not theoretical.
The exact same value is already available one level up: GoModule.includeDiscovered(ws, test: true) (go.dang:369-383) produces it. The fix is to compute it once in GoModule.testDirectories and pass the result into each constructed GoDirectory, then delete GoDirectory.includeDiscovered and GoDirectory.goIncludesHelper (lines 653-692) entirely.
Why this is worth doing now, before the bigger caching refactor:
- It's a Dang-only change. No helper code, no CLI surface, no decisions about privileged nesting or input materialization.
- It composes with the bigger refactor. When the helper is later made cacheable, the per-directory call site won't exist to also benefit — but it also won't be re-firing N times in scenarios where the cache misses for legitimate reasons.
- It removes ~40 lines of
go.dang (a duplicated helper container definition and a duplicated exec call site).
- The win scales with test-directory count, which in practice is what users notice on real workspaces.
Scope: lift includeDiscovered from GoDirectory to a constructor parameter populated by GoModule.testDirectories from includeDiscovered(ws, test: true). Delete the now-unused GoDirectory.goIncludesHelper and GoDirectory.includeDiscovered.
GoDirectory.includeDiscovered(go.dang:682-692) runs the helper with["go-includes", "--test", workspacePath], whereworkspacePathis derived from the directory's module root — not the directory itself. EveryGoDirectoryproduced for the sameGoModuletherefore fires the same helper exec and gets back the same include list.For a module with N test directories, that's N identical privileged-nesting helper invocations per
dagger checkrun. Each one builds nothing new — it's pure duplication. None of them are cached today (privileged nesting), so the cost is real, not theoretical.The exact same value is already available one level up:
GoModule.includeDiscovered(ws, test: true)(go.dang:369-383) produces it. The fix is to compute it once inGoModule.testDirectoriesand pass the result into each constructedGoDirectory, then deleteGoDirectory.includeDiscoveredandGoDirectory.goIncludesHelper(lines 653-692) entirely.Why this is worth doing now, before the bigger caching refactor:
go.dang(a duplicated helper container definition and a duplicated exec call site).Scope: lift
includeDiscoveredfromGoDirectoryto a constructor parameter populated byGoModule.testDirectoriesfromincludeDiscovered(ws, test: true). Delete the now-unusedGoDirectory.goIncludesHelperandGoDirectory.includeDiscovered.