Skip to content

core/sdk: gate runtime codegen on config format - #13598

Merged
eunomie merged 4 commits into
dagger:mainfrom
eunomie:core-sdk-config-format-runtime-codegen-gate
Jul 13, 2026
Merged

eunomie merged 4 commits into
dagger:mainfrom
eunomie:core-sdk-config-format-runtime-codegen-gate

Conversation

@eunomie

@eunomie eunomie commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Extracts the generic engine-side runtime-codegen gate from the draft Python SDK stack (#13593) so it can be reviewed and land on its own. The first two commits are byte-identical to that stack (original messages and sign-offs preserved); a third engine commit makes bare dagger generate load workspace modules best-effort; the fourth is the test fallout.

What

One rule decides whether a module's runtime may regenerate its bindings, keyed on config format:

  • dagger.json (legacy): the runtime gets the schema introspection and may regenerate the module's bindings on the fly — today's behavior, for every SDK, unconditionally.
  • dagger-module.toml: no runtime codegen. The module commits its generated files (dagger generate) and the runtime builds from them as-is.

For a dagger-module.toml module the engine additionally omits the introspection JSON from the moduleRuntime call — but only when the SDK opts in by declaring its moduleRuntime introspectionJson argument optional. That's capability detection on the loaded SDK's own schema (like the existing moduleRuntime/codegen detection), no hardcoded SDK list. An SDK whose argument is still required keeps today's call byte-identical until it adopts the contract.

Why

This replaces the codegen.automaticGitignore opt-out + engine-version gate that #13381 shipped for the Go SDK with a single config-format input, so every module SDK gets the same semantics without per-SDK special-casing. Omitting the schema-file ID from the call also decouples the runtime container cache from deps-schema changes.

Notes

  • The best-effort generator-load commit is needed alongside the gate: without it, bare dagger generate fails on a fresh dagger-module.toml module (it can't load the not-yet-generated module). It lets generation skip + warn on a per-module load failure so the module's files can still be materialized (TestWorkspaceModuleGenerate).
  • The test commit is minimal fallout: TestVersionSkewFallsBackToCodegen asserted the removed mechanism and is replaced by TestLegacyConfigKeepsRuntimeCodegen; suites that call TOML Go fixtures — plus the client-generator and migration-hints paths — now materialize their generated files first, since nothing regenerates them at load time anymore.
  • Fuller coverage (Python analogs, Go happy-path) lands with the follow-up Python SDK PR (sdk(python): adopt no-codegen-at-runtime + slim module runtime #13593), which is stacked on this one.
  • Verified: gofmt/vet/build clean; core/sdk + core/schema unit tests green (incl. TestBaseSchemaAllowlist); integration green on a dev engine — TestRuntimeCodegen, TestWorkspaceModuleGenerate, TestWorkspaceMigrateOutcomes, the client-generator suite, TestModule/TestTypedefSourceMaps, TestModuleConfig/TestIncludeExclude, TestCall/TestGitMod.

@eunomie
eunomie force-pushed the core-sdk-config-format-runtime-codegen-gate branch 2 times, most recently from 8e59c79 to 3da044e Compare July 9, 2026 14:49
@eunomie
eunomie requested a review from TomChv July 9, 2026 15:02
@eunomie
eunomie force-pushed the core-sdk-config-format-runtime-codegen-gate branch 4 times, most recently from de0de08 to fafef56 Compare July 10, 2026 13:55
@eunomie
eunomie marked this pull request as ready for review July 10, 2026 14:45
eunomie added 4 commits July 13, 2026 15:37
Move the runtime-codegen gate out of the Go SDK so the module-SDK
adapters can apply the same semantics, and reduce it to a single rule:

  - dagger.json (legacy): the runtime gets the schema introspection and
    may regenerate the module's bindings on the fly — today's behavior,
    for every SDK, unconditionally.
  - dagger-module.toml: no runtime codegen. The module commits its
    generated files (dagger generate) and the runtime builds from them
    as-is.

The codegen.automaticGitignore opt-out and the engine-version gate are
not read anymore: the config format is the only input.

Signed-off-by: Yves Brissaud <[email protected]>
…odegen

Apply the config-format rule to module SDKs: for dagger-module.toml
modules, the engine skips building the deps introspection JSON and omits
the introspectionJson argument from the moduleRuntime call — no codegen
possible at runtime, the SDK builds from the module's committed
generated files.

The rule is SDK-agnostic. An SDK adopts it by declaring its moduleRuntime
introspectionJson argument optional — capability detection on the loaded
SDK module's own schema, like moduleRuntime/codegen detection, no
hardcoded SDK list. SDKs with a required argument keep today's call,
byte-identical, until they adopt the contract. Legacy dagger.json
modules never qualify, so existing modules are unaffected.

Since toml modules must keep their generated files in the module context
(local context loading is gitignore-filtered), codegen stops writing
VCS-generated paths into .gitignore for them; non-generated ignores
(.venv, __pycache__) still apply.

Leaving the schema-file ID out of the moduleRuntime call also decouples
the runtime container cache from deps-schema changes.

Signed-off-by: Yves Brissaud <[email protected]>
dagger-module.toml modules never run codegen at runtime, so a freshly
scaffolded module (or one whose generated files were never committed)
fails to load with the missing-generated-files error. Bare
`dagger generate` used to die on that load — a dead-end, since running
the SDK generator is exactly what materializes those files.

Workspace.generators now loads modules best-effort: a module that fails
to load is skipped with a console warning instead of failing the run,
its recorded error kept for other operations. Checks and services keep
the strict behavior.

[rebased onto main: the core.Server test fakes added on main since this
was authored (core/schema/test_server_test.go, core/telemetry_test.go)
updated for the new EnsureWorkspaceModules signature]

Signed-off-by: Yves Brissaud <[email protected]>
The runtime-codegen suite asserted the flag-based mechanism the previous
commits removed: TestMissingGeneratedFiles keeps its assertion (the
missing-files error now comes from the config format, not the opt-out
flag, so the stale codegen.automaticGitignore field goes away) and
TestVersionSkewFallsBackToCodegen is replaced by
TestLegacyConfigKeepsRuntimeCodegen — the version-skew fallback no
longer exists, what must hold instead is that legacy dagger.json
modules keep regenerating unconditionally, including with a stale
codegen.automaticGitignore=false opt-out from the flag-based era.

Existing suites that build toml Go modules from fixtures or in-test
configs (typedef source maps, include/exclude, call-by-name git roots,
client generation) now materialize the generated files first: nothing
regenerates them at load time anymore.

The migration hints test regenerates the fixture's committed generated
files with the current engine before migrating: the migrated module is
dagger-module.toml and builds from them as-is, and the version-skew
fallback that used to regenerate the stale fixture files at load is
gone.

The generators narrowing test asserted that generate across all modules
fails on the broken one; generator enumeration is now best-effort, so
it asserts the skip warning instead — the broken module is still
loaded, its failure just no longer fails the run.

Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie force-pushed the core-sdk-config-format-runtime-codegen-gate branch from fafef56 to eaca72d Compare July 13, 2026 13:37
@eunomie
eunomie merged commit 67a07c9 into dagger:main Jul 13, 2026
87 checks passed
@eunomie
eunomie deleted the core-sdk-config-format-runtime-codegen-gate branch July 13, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants