Repository navigation
codegen: name module declarations through the engine - #120
Merged
Merged
Conversation
vito
force-pushed
the
format-identifiers
branch
from
October 30, 2026 16:06
5783b07 to
8acb191
Compare
vito
force-pushed
the
format-identifiers
branch
from
October 30, 2026 22:42
8acb191 to
097d177
Compare
1 task
vito
force-pushed
the
format-identifiers
branch
3 times, most recently
from
November 6, 2026 14:58
7ebc613 to
379b3e4
Compare
The generated entrypoints call a module through its own interfaces, send and receive its enums there, and pick the object of an [entrypoint] module that carries the constructor. They now take those names from the engine (Query.naming(version:).module(name:, originalName:)) instead of predicting them, given the served source's naming version, name and original name as --naming-version, --module-name and --module-original-name. The constructor goes only on the object mainObject names. TypeScript identifiers derived from schema names (enum member keys, enum converters, Opts types, dependency import aliases) are styled through Naming.formatIdentifiers with PascalCase and uppercase acronyms, in one up-front query plus direct calls on misses. toPascalCase and pascalize are removed. Names the engine cannot give or style fail generation; there is no fallback and no pre-filter. Signed-off-by: Alex Suraci <[email protected]>
typescript-sdk.dang reads naming.version, name and originalName from the final module source the engine loads and passes them as plain strings to the entrypoint generators, which run as nested clients. The SDK module declares engineVersion v1.0.0-beta.26, the first release serving ModuleSource.naming, and selects that view's core names (introspectionSchemaJson, clientSchemaIntrospectionJson, htmlRepoUrl). Nothing checks the floor in code. Being named by the engine's identifier rules renames the module's types (TypescriptSdk* -> TypescriptSDK*); the constructor stays typescriptSdk. Adds the e2e:naming calls check: a fixture generated at the bundle target (beta.28, past the cut), new and with an owned older dang.toml, selects NamingAppHTTPFetcher/e2eTest/getUrl and passes its self-call. Signed-off-by: Alex Suraci <[email protected]>
Regenerated on the released v1.0.0-beta.28 engine (packager:library-bindings then packager:library-bundle). Enum member keys and Opts types now take the engine's PascalCase styling with uppercase acronyms: NetworkProtocol.TCP/UDP, ImageMediaTypes.OCI, RegistryProtocol.HTTP/HTTPS, ArtifactURIOpts, ClientHTTPOpts, ClientSSHFSVolumeOpts, WorkspaceWithSDKOpts, WorkspaceWithoutSDKOpts, ModuleSourceClientSchemaIntrospectionJSONOpts. VENDOR.md records the divergence from upstream's bindings. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
format-identifiers
branch
from
November 23, 2026 18:49
379b3e4 to
564b723
Compare
vito
marked this pull request as ready for review
November 23, 2026 19:00
TomChv
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
TomChv
added a commit
that referenced
this pull request
Nov 25, 2026
`e2e/sdk/helper-tests-check` is red on main: `go test ./...` in helpers/codegen fails TestGenerateDangEntrypointCachePolicy (3 subtests) and TestGenerateEntrypointDispatchLoadsModuleCode. Neither is a regression in #120's code, and neither PR could have caught it. #120 made every generator that renders a module's own declarations ask the engine for their names, and added `Naming` to each test that builds a generator config. Its branch predates both of these tests: - dang_entrypoint_cache_policy_test.go arrived with #143. - TestGenerateEntrypointDispatchLoadsModuleCode arrived with #144. Both merged after #120's CI ran, git merged all three cleanly, and the combination was never tested. Without a naming context the dang entrypoint finds no main object among typedef_smoke.json's objects, and the dispatcher cannot name the fixture's own interface. Both now use `smokeNaming()`, as every other test on that fixture does. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Nov 25, 2026
sdk-helpers v1.0.13 (dagger/sdk-helpers#14) adopts the beta.26 identifier naming conventions in its source and declares v1.0.0-beta.26 as its floor. That is not a schema change: a beta.26+ caller was already served SDKHelpers*, loadToml and loadJson, which this SDK has selected since it took the same floor in #120. The one real rename, withLegacyPHPRuntime -> withLegacyPhpRuntime, has no caller here. So this is a pin bump only. Both lockfiles gain the tag's resolution; engine-e2e's workspace.lock is the playground's, refreshed by its own generator. dagger generate reports no changes to apply, and the module loads against the new pin. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Nov 25, 2026
sdk-helpers v1.0.13 (dagger/sdk-helpers#14) adopts the beta.26 identifier naming conventions in its source and declares v1.0.0-beta.26 as its floor. That is not a schema change: a beta.26+ caller was already served SDKHelpers*, loadToml and loadJson, which this SDK has selected since it took the same floor in #120. The one real rename, withLegacyPHPRuntime -> withLegacyPhpRuntime, has no caller here. So this is a pin bump only. Both lockfiles gain the tag's resolution; engine-e2e's workspace.lock is the playground's, refreshed by its own generator. dagger generate reports no changes to apply, and the module loads against the new pin. Signed-off-by: Tom Chauveau <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Current status: rebased onto
main724f572(v1.1.0, already paired with engine v1.0.0-beta.28 by #141) and squashed to three commits; head564b723. The engine-e2e pin stays main's v1.0.0-beta.28 tag commit, and the library bindings and bundle are regenerated on the released beta.28 engine. Since the bundle target (beta.28) is past the naming cut, generated entrypoints now select post-cut names end to end, and the e2e naming check exercises that.The generated entrypoints call a module through its own interfaces, send and receive its enums there, and pick which object of an
[entrypoint]module carries the constructor. They do all of this by the names the engine gives the module's own declarations. This PR stops predicting those names: it reads the served source's naming context throughModuleSource.namingand asksQuery.naming(version:).module(name:, originalName:)for the names, shipped in Dagger v1.0.0-beta.26 (dagger/dagger#14996).The engine answers by the rules of the version it names the module by: strcase before the identifier-casing cut (
v1.0.0-beta.26), and its identifier naming rules from the cut on. So nothing here mirrors a rule or compares versions locally, and no legacy prediction path is left.TypeScript's own identifiers made from schema names are styled by the engine too, through
Query.naming(version:).formatIdentifiers(see Identifiers styled by the engine below): enum member keys, enum converter functions,Optstypes and the client import aliases. Nothing in codegen styles a name locally.Mechanism
typescript-sdk.dangreadsnaming.version,naming.nameandnaming.originalNamefrom the same final-staged module source the engine loads (ws.moduleSource(scope)). It passes these plain strings as--naming-version,--module-nameand--module-original-nametocodegen entrypoint(__dagger.entrypoint.ts,entrypoint/__dagger.dispatch.ts) andcodegen dang-entrypoint(entrypoint/main.dang), running as nested clients of the session. No source ID or ID file travels into the codegen exec.The generators reconstruct that module naming, as Go does, and send one query for every name their typedef declares. The version is the source's resolved naming version, not the running engine, SDK floor or generated core version; both names are required to preserve aliasing and namespace behavior:
The constructor goes only on the object
mainObjectnames. A module with objects when the engine takes none of them for the main one fails generation, and the error lists the objects. No fallback is left.The typedef is parsed in one place, codegen, so there's no names file, no Dang-side typedef parsing and no request/lookup cross-check. That also means this PR has no Dang release dependency (no
JSON.decodeintoMap).No other name the entrypoints use is the engine's to give, which matters for the other SDKs:
core/enum.go,ConvertToSDKInput/ConvertFromSDKResultwithLocal), and patches enum defaults from original names (Module.Patch). So the dispatcher's enum coercion and the typedef defaults use declared names, which are right on both sides of the cut.parentName/receiverType,fnName, argument keys).What changes for users
The names were wrong on every engine before, and broke the module wherever they differed from the engine's. Output only changes where they were wrong (generated identifiers aside: see Identifiers styled by the engine).
getURLselectedgetURL, which the engine namesgetUrl. The e2e caught it:Cannot query field "getURL" on type "NamingAppHttpFetcher". Did you mean "getUrl"?.FooHTTPClientbecameFooFooHTTPClient, which strcase namesFooHttpclient;PondHttpClientin modulepondbecamePondPondHttpClient.[entrypoint]module was matched pascalized against the scanner's name.K8sToolsink8s-tools, which is how this SDK's own templates name the class, got no constructor. Now only the engine'smainObjectdecides. The other way round,K8SToolsin ak8s-toolsthat strcase names (K8sTools) used to get the constructor from that match, and it now fails generation. Under the new rules the engine takes it."arm64"), where the field takes the member's name. A result came back as the name, not the value. Arguments, results and lists of them, nullable ones included, now convert through the query builder's enum metadata.v1.0.0-beta.26or later is called by the engine's new names:NamingAppHTTPFetcher,e2eTest,ARM64.The SDK module declares
engineVersion = "v1.0.0-beta.26"indagger-module.tomlanddagger.json. That is the floor, the first release servingModuleSource.naming, and nothing checks it in code. Engines compare base versions only, so beta.12–25 engines aren't refused: they break wherever the SDK selects something they lack. Declaring it has two consequences:introspectionSchemaJson,clientSchemaIntrospectionJson,htmlRepoUrl).TypescriptSDK,TypescriptSDKClientTarget,TypescriptSDKModConfig,TypescriptSDKRuntimeandTypescriptSDKTemplate, where strcase gaveTypescriptSdk…. The constructor staystypescriptSdk, because field names write acronyms like words (Capitalized). Only the types are renamed. No caller in this repo names those types; they all go through the constructor.The README,
docs/module-sources.mdand thebundleEngineVersiondocs say so. Loading an unpinned generated module still needs only beta.18. A module the engine names by the new rules needs an engine at the cut to load, because an older engine would name it by strcase.Identifiers styled by the engine
The TypeScript identifiers the bindings derive from schema names follow two rules: TypeScript's convention, which is PascalCase for enum members and types, and the engine's styling, so no local casing helper is involved. The bindings generators (
codegen module,client,library) take them fromnaming(version: <the schema's __schemaVersion>) { formatIdentifiers(names:, casing: PASCAL, acronyms: UPPERCASE) }, as the Go SDK styles its names:NetworkProtocol.TCP);<Enum>ValueToName/<Enum>NameToValue, at their declarations, imports and call sites alike;<Parent><Field>Opts(the field part);__dag<Dep>/__mod<Dep>import aliases, in place ofstrcase.ToCamel.Details:
HTTPClient,LLMMessageRole).toPascalCaseand its LLM special case are deleted.User-visible renames: the library's core bindings and bundle are regenerated on the released v1.0.0-beta.28 engine (
packager:library-bindings, thenpackager:library-bundle). Where the engine's styling differs fromtoPascalCase(method names still mirror the schema's fields, e.g.withSdk,clientSchemaIntrospectionJson):NetworkProtocolTcp,UdpTCP,UDPImageMediaTypesOciOCIRegistryProtocolHttp,HttpsHTTP,HTTPSArtifact.urioptionsArtifactUriOptsArtifactURIOptsdag.httpoptionsClientHttpOptsClientHTTPOptsdag.sshfsVolumeoptionsClientSshfsVolumeOptsClientSSHFSVolumeOptsWorkspace.withSdkoptionsWorkspaceWithSdkOptsWorkspaceWithSDKOptsWorkspace.withoutSdkoptionsWorkspaceWithoutSdkOptsWorkspaceWithoutSDKOptsModuleSource.clientSchemaIntrospectionJsonoptionsModuleSourceClientSchemaIntrospectionJsonOptsModuleSourceClientSchemaIntrospectionJSONOptsTypescriptSdk,TypescriptSdkClientTarget,TypescriptSdkModConfig,TypescriptSdkRuntime,TypescriptSdkTemplateTypescriptSDK…(constructor staystypescriptSdk)Under
remoteCoreLiba scope takes@dagger.io/corefrom npm, which dagger/dagger publishes with its own (stilltoPascalCase) styling, so these names differ between the vendored and the published core until that catches up; the README says so.Every other core key, converter and
Optstype is unchanged (TypeDefKind.StringKind,FunctionCachePolicy.PerSession,LLMMessageRole.User,LLMContentBlockKindValueToName,ContainerWithExecOpts, …). All-caps words outside the engine's acronym dictionary stay words:DOCKER→Docker,VALUE→Value. Module and dependency bindings get the same styling, e.g. a memberhttp_only→HTTPOnly, a fieldasJson's optionsFileAsJSONOpts(wheretoPascalCasegaveFileAsJsonOpts).No aliases keep the old names: code written against
NetworkProtocol.TcporClientHttpOpts(including pre-1.0 source the compat shim otherwise keeps compiling) needs the new one.Commit history
Squashed on the rebase onto
724f572(the 24-commit development history is in the PR's timeline):4c2d99ccodegen: name module declarations through enginehelpers/codegen:Naming.modulelookups (types, fields, enum members,mainObject), enum conversion through own interfaces,formatIdentifiersstyling, the nested-session client, fake engine and tests05ddd5fsdk: pass module naming to codegen, floor beta.26typescript-sdk.dang, manifests, e2e naming check + fixture, packager nesting, docs564b723library: regenerate with engine-styled identifierslibrary/src/core/client.gen.ts+library/bundle/*on released beta.28; VENDOR.mdIntegration with what main gained since
b75eb1a(remoteCoreLib, globalClient/split clients, split runtime imports, bundle pruning, the beta.28 pairing): flag sets and configs merged,generateModuleDispatcher/generateDangEntrypointkeep main's--remote-core-lib/--split-runtime-importsarguments, the now-unusedpascalizehelper is removed, and when the core ships as it is (--core-file) the core enums' names join the one up-frontformatIdentifiersquery (their converters are imported by module clients). The remote-entrypoint fixture keeps main's real, taggedgithub.com/dagger/[email protected].If the cut moves
Nothing in the code compares versions: the engine decides which rules name a module, and the SDK only declares its floor (
engineVersion = "v1.0.0-beta.26"indagger-module.tomlanddagger.json; there is no module-rootdang.toml). The cut shipped in beta.26, so this section is reference only.If the API itself moves (a field or argument is renamed), the queries are in
templates/module_naming.go(namingQuery,LoadModuleNames,lookup) andtemplates/identifiers.go(formatIdentifiersQuery), and the fake engine isgenerator/namingtest(itsStylestable holds the engine's expected answers for the test schemas' names).Tests
At head
564b723, against the releasedregistry.dagger.io/engine:v1.0.0-beta.28(run as a service, driven by that image's CLI, with.dagger/modules/engine-e2e/workspace.tomlas the workspace config, as the playground uses):helpers/codegen:go test -count=1 ./...andgo vet ./...pass.dagger generate --auto-apply(all generators) writes nothing beyond the committed library regeneration.e2e:naming:calls-check(new and owned-older-config fixture both selectNamingAppHTTPFetcher/e2eTest/getUrl; the module's self-call check passes);packager:library-bindings/stale,library-bundle/stale,library-tests,layering-check;runtimes:*(all 18,interface-returnsandinterface-field-entrypointincluded; their inner failures are the deliberate ones they assert);e2e:generate:{generate-self-call, generate-dependency-bindings, generate-module-type-checks, generate-compat-shim-type-checks, generate-deno-module-type-checks, global-client, entrypoint-installs-dependencies, generate-idempotent}-check,e2e:client:{generate-client-compiles, module-scope-client-bindings}-check,e2e:version:{dang-config, entrypoint-regenerate-no-diff, core-from-bundle}-check,e2e:sdk:helper-tests-check,e2e:manifest:remote-entrypoint-replaced-check.dagger sdk listliststypescript;dagger module init typescript --legacy-runtimeandcall base-image-addresswork; an[entrypoint]init writesentrypoint/dang.tomlat beta.28 and its functions load; the SDK module's type isTypescriptSDK.Not run: the engine-e2e playground checks (
dev-sdk-check,dev-sdk-settings-check,checks-check), which build the beta.28 engine from source; and the rest ofe2e:*.The naming check's pinned case uses
v1.0.0-beta.26for the owned olderdang.toml: it is the oldest pin generation can load through to heal (seeVersionChecks.dangConfigCheck; older ones fail onkeyByContent). The check no longer readsModuleSource.namingitself, which the e2e module's pre-cut view of the API lacks; the post-cut names in the dispatcher stand in for it.Unit tests (fake engine,
helpers/codegen/generator/namingtest) cover: one up-front query plus a direct one on a miss (naming and styling); an unknown source and a name the engine can't give or style both fail; pre/post-cut naming versions distinct from the core version; renamed module identity plus original name; interface type/field names, enum conversions (lists, nullable lists), the main object from the engine's answer and the failure when it takes none; both entrypoint CLI modes against an HTTP fake.A pre-existing own-interface enum-alias issue (duplicate TypeScript object keys for equal enum values) was reported by an earlier review and is unchanged here.
Loading the SDK module on a pre-beta.26 engine fails: its Dang code selects post-cut core names. That is the declared floor.
Engine-side, not naming: the enum conversion through own interfaces is unit-tested only. A self-call whose schema holds an own interface with an own-enum argument fails at schema load,
interface "NamingAppHttpFetcher" function "getUrl" cannot accept arg "arch" of external type from dependency module "naming-app"(core/interface.go), so the e2e fixture's interface carries no enum.Follow-ups / open questions
TypeDefKind.StringKind,FunctionCachePolicy.Never), which the engine styles the same today.nameandoriginalNameof the served source used at generation. A workspace or toolchain that later loads the module under a different name namespaces its interfaces under that other name; the generated entrypoint does not anticipate a future alias. That's documented onModuleSource.namingin core: add ModuleSource.naming for SDK codegen dagger#14996.library/src/module/introspector/introspection_json.ts(not wired) still has strcase ports. Whoever wires it should ask the engine instead.ModuleSource.clientSchemaIntrospectionJson(clientVersion: <consumer>)(core: add clientVersion to client schemas dagger#14959) would serve core at the consumer's view; only the core part of a dependency client would change.