You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our repository is full of Dagger modules, mostly written in Go. The code for these modules cannot be built or linted by the standard Go toolchain from a clean git checkout. Now that we are trying to use reusable Dagger toolchains as much as possible, this has become a problem.
We have implemented a stopgap: ship a reusable toolchain that can generate dagger modules on the fly before attempting to build/lint them. This works but makes the toolchain more complex and VERY SLOW.
Solution
Everything would be simpler if we conformed to the prevailing convention for generated code: check them into git. This way, native toolchains can do their work without hooking or wrapping their execution.
Task list:
Remove relevant .gitignore entries in all our dagger modules
Still a bit hesitant to do this, but not blocking, considering we've already tried the status quo for long enough.
The failure mode to me would be if the pain of constantly re-generating and re-committing and permanently inflating the repo size is higher than the pain of a slower linting phase. Slow checkouts and fetches can be brutal for a large org.
If we're going to commit generated files, but then also imply a pattern of checking that the generated files are up-to-date like @marcosnils questioned (and I suspect some people feel compelled to do, right or wrong), then it doesn't feel like we would have escaped the slow lint anyway, we would have just moved it from the lint check to the check-generated check (granted, it would be in parallel).
What about Python/TypeScript/other codegen'd SDKs? Do they not have these issues? Or, if they do, would we reach the same decision there, to commit all their generated code? My recollection is those generate even more code which might be less palatable.
The failure mode to me would be if the pain of constantly re-generating and re-committing and permanently inflating the repo size is higher than the pain of a slower linting phase. Slow checkouts and fetches can be brutal for a large org.
That's true, we should watch for that. I'm hopeful that it won't make a significant difference in repo size, since it's mostly text files, and with the new toolchain pattern (+ dang 😁 ), the number of total modules will probably trend down?
If we're going to commit generated files, but then also imply a pattern of checking that the generated files are up-to-date like @marcosnils questioned (and I suspect some people feel compelled to do, right or wrong), then it doesn't feel like we would have escaped the slow lint anyway, we would have just moved it from the lint check to the check-generated check (granted, it would be in parallel).
That's true, but because the lifecycle of "lint" and "generate" are typically decoupled, users expect it to be that way, and are unpleasantly surprised when "lint" takes way too long. Even if the time budget is the same globally, it will still "feel" wrong.
Also there's the inconvenience of linters breaking on a fresh git checkout, which would go away.
What about Python/TypeScript/other codegen'd SDKs? Do they not have these issues? Or, if they do, would we reach the same decision there, to commit all their generated code? My recollection is those generate even more code which might be less palatable.
I guess yes, we would reach the same decision. With the same tradeoffs that you mentioned.
One last point: if the downsides turn out to be OK, and we enshrined this best practice as the "correct" one in the platform, we could harvest one more optimization: dropping codegen at runtime :) Which could speed up module loading time.
I cannot speak for the dagger repo, but regarding our own repos at Nine, I believe there would be many benefits to checking in the code. We have a large monorepo which houses all our dagger modules.
newcomers to our monorepo don't need to run dagger develop --recursive
tools like renovate would start working on our dagger modules
In order to ensure the generated code was always up-to-date, you would need a check-generated step. Seems like the kind of thing that could be built into dagger itself ?
@chrisjpalmer yes we plan on adding the following to Dagger:
A built-in dagger generate command which would rollup all functions marked by +generate, similar to dagger check and +check
A built-in generate function which would re-generate Dagger's own module code. So dagger generate would always re-generate modules out of the box
A built-in check function that checks that generated files are up-to-date. So dagger check would always check that all generated files (including for dagger modules) are up-to-date
This sounds really good. Great way of solving the problem. Like the sound of the // +generate pragma. Would this be some thing we could use for running code formatters perhaps ? I.e. you format the code and it wants to push a bunch of updates to files.. ?
This sounds really good. Great way of solving the problem. Like the sound of the // +generate pragma. Would this be some thing we could use for running code formatters perhaps ? I.e. you format the code and it wants to push a bunch of updates to files.. ?
Yes that would work just fine. Do you think end-users would find it weird to have to type dagger generate to format-fix their code? We could also consider adding a dagger fix + +fix, that would work exactly the same as generate, but with a different intent for end-users. wdyt? too much? @kpenfound@vito@marcosnils ?
The failure mode to me would be if the pain of constantly re-generating and re-committing and permanently inflating the repo size is higher than the pain of a slower linting phase. Slow checkouts and fetches can be brutal for a large org.
I'm hopeful that it won't make a significant difference in repo size, since it's mostly text files
The other thing to consider is, adding a ton more generated files to a code review and re-adding every time there's a change to a module will quickly become really tedious to code review. It will also look overwhelming to a reviewer and put them of doing a quick review. I'm not looking forward to chasing after reviewers telling them that this is a change that looks smaller than it really is. I am not too concerned about the repo size itself. But I am concerned about the DX/UX.
tools like renovate would start working on our dagger modules
We still don't want Renovate to touch dagger deps right? Not without more intelligence built into Renovate to understand Dagger.
A built-in dagger generate command which would rollup all functions marked by +generate, similar to dagger check and +check
I may have missed some recent development (I am on vacation 🙂) but why is there a need for a pragma? Or even a generate function? Isn't that the same as develop? Or are we looking for something more specific as develop isn't?
Do you think end-users would find it weird to have to type dagger generate to format-fix their code? We could also consider adding a dagger fix + +fix, that would work exactly the same as generate, but with a different intent for end-users. wdyt? too much?
As long as it's not something ambiguous it should be ok. But I fail to understand why the generate function would behave differently for an end user.
since it's mostly text files, and with the new toolchain pattern (+ dang 😁 ), the number of total modules will probably trend down?
Again sorry for my ignorance. It's all text isn't it? Not, mostly?
Also, how does toolchain pattern reduce the total number of modules?
Use checked-in Go module runtime files as the source of truth. Generation becomes a repo-level maintenance step; go:lint and go:check-tidy stop patching modules on the fly.
PR 1
Add one root generator under .dagger/main.go.
Scope it to the same modules dagger check go:* touches now.
For each target module:
find the module root
require sdk.source == "go"
run GeneratedContextChangeset()
merge all changesets into one repo-wide changeset
Do a one-time repo cleanup for each targeted Go SDK module:
add "codegen": { "automaticGitignore": false } to dagger.json
remove only generated-runtime entries from local .gitignore
Delete GenerateDaggerRuntime() from toolchains/go/main.go.
Remove the calls to it from TidyModule and LintModule.
Leave check generated as the only authority on stale runtime files.
Verification
Run the new generator twice; the second run must be empty.
dagger check generated must pass on a clean tree.
Delete one committed generated file; dagger check generated must fail.
From a clean checkout, dagger check go:check-tidy and dagger check go:lint must pass without regenerating anything.
Important implementation detail: develop -r is not enough for this repo because it walks dependencies, not toolchains. The new root generator should cover the same module set the current Go toolchain lints today, including toolchain modules.
This should let us remove the just-in-time overlay path from toolchains/go entirely while keeping stale generated files enforced by the existing generated-files check.
Activity
shykes commentedon Nov 21, 2025
@dagger/maintainers any objections to this?
[-]Commit generate dagger files in our repo[/-][+]Commit generated dagger files in our repo[/+]marcosnils commentedon Nov 24, 2025
I guess we should also add a check on each commit that verifies generated files are up-to-date.
vito commentedon Nov 24, 2025
Still a bit hesitant to do this, but not blocking, considering we've already tried the status quo for long enough.
The failure mode to me would be if the pain of constantly re-generating and re-committing and permanently inflating the repo size is higher than the pain of a slower linting phase. Slow checkouts and fetches can be brutal for a large org.
If we're going to commit generated files, but then also imply a pattern of checking that the generated files are up-to-date like @marcosnils questioned (and I suspect some people feel compelled to do, right or wrong), then it doesn't feel like we would have escaped the slow lint anyway, we would have just moved it from the
lintcheck to thecheck-generatedcheck (granted, it would be in parallel).What about Python/TypeScript/other codegen'd SDKs? Do they not have these issues? Or, if they do, would we reach the same decision there, to commit all their generated code? My recollection is those generate even more code which might be less palatable.
shykes commentedon Nov 25, 2025
Curious what you all think @chrisjpalmer @nipuna-perera ?
To be clear this issue is about changing our own repo only. But it's also an experiment in changing the best practice for all users in the future.
shykes commentedon Nov 25, 2025
That's true, we should watch for that. I'm hopeful that it won't make a significant difference in repo size, since it's mostly text files, and with the new toolchain pattern (+ dang 😁 ), the number of total modules will probably trend down?
That's true, but because the lifecycle of "lint" and "generate" are typically decoupled, users expect it to be that way, and are unpleasantly surprised when "lint" takes way too long. Even if the time budget is the same globally, it will still "feel" wrong.
Also there's the inconvenience of linters breaking on a fresh git checkout, which would go away.
I guess yes, we would reach the same decision. With the same tradeoffs that you mentioned.
One last point: if the downsides turn out to be OK, and we enshrined this best practice as the "correct" one in the platform, we could harvest one more optimization: dropping codegen at runtime :) Which could speed up module loading time.
chrisjpalmer commentedon Nov 25, 2025
I cannot speak for the dagger repo, but regarding our own repos at Nine, I believe there would be many benefits to checking in the code. We have a large monorepo which houses all our dagger modules.
dagger develop --recursiveIn order to ensure the generated code was always up-to-date, you would need a
check-generatedstep. Seems like the kind of thing that could be built into dagger itself ?shykes commentedon Nov 25, 2025
@chrisjpalmer yes we plan on adding the following to Dagger:
dagger generatecommand which would rollup all functions marked by+generate, similar todagger checkand+checkdagger generatewould always re-generate modules out of the boxdagger checkwould always check that all generated files (including for dagger modules) are up-to-datechrisjpalmer commentedon Nov 25, 2025
This sounds really good. Great way of solving the problem. Like the sound of the
// +generatepragma. Would this be some thing we could use for running code formatters perhaps ? I.e. you format the code and it wants to push a bunch of updates to files.. ?shykes commentedon Nov 25, 2025
Yes that would work just fine. Do you think end-users would find it weird to have to type
dagger generateto format-fix their code? We could also consider adding adagger fix++fix, that would work exactly the same asgenerate, but with a different intent for end-users. wdyt? too much? @kpenfound @vito @marcosnils ?chrisjpalmer commentedon Nov 25, 2025
That does feel more on par yes. But still if it had to be dagger generate for a while I don't think users would mind.
nipuna-perera commentedon Nov 26, 2025
The other thing to consider is, adding a ton more generated files to a code review and re-adding every time there's a change to a module will quickly become really tedious to code review. It will also look overwhelming to a reviewer and put them of doing a quick review. I'm not looking forward to chasing after reviewers telling them that this is a change that looks smaller than it really is. I am not too concerned about the repo size itself. But I am concerned about the DX/UX.
We still don't want Renovate to touch dagger deps right? Not without more intelligence built into Renovate to understand Dagger.
I may have missed some recent development (I am on vacation 🙂) but why is there a need for a pragma? Or even a generate function? Isn't that the same as develop? Or are we looking for something more specific as develop isn't?
As long as it's not something ambiguous it should be ok. But I fail to understand why the
generatefunction would behave differently for an end user.Again sorry for my ignorance. It's all text isn't it? Not, mostly?
Also, how does toolchain pattern reduce the total number of modules?
shykes commentedon Apr 8, 2026
I want to try this again now.
shykes commentedon Apr 9, 2026
Implementation plan:
Use checked-in Go module runtime files as the source of truth. Generation becomes a repo-level maintenance step;
go:lintandgo:check-tidystop patching modules on the fly.PR 1
.dagger/main.go.dagger check go:*touches now.sdk.source == "go"GeneratedContextChangeset()"codegen": { "automaticGitignore": false }todagger.json.gitignore.gitattributesdagger.json.gitignoredagger.gen.gointernal/dagger,internal/querybuilder,internal/telemetryPR 2
GenerateDaggerRuntime()fromtoolchains/go/main.go.TidyModuleandLintModule.check generatedas the only authority on stale runtime files.Verification
dagger check generatedmust pass on a clean tree.dagger check generatedmust fail.dagger check go:check-tidyanddagger check go:lintmust pass without regenerating anything.Important implementation detail:
develop -ris not enough for this repo because it walks dependencies, not toolchains. The new root generator should cover the same module set the current Go toolchain lints today, including toolchain modules.This should let us remove the just-in-time overlay path from
toolchains/goentirely while keeping stale generated files enforced by the existing generated-files check.