Skip to content

Name identifiers through the engine - #72

Merged
eunomie merged 20 commits into
mainfrom
format-identifiers
Nov 18, 2026
Merged

eunomie merged 20 commits into
mainfrom
format-identifiers

Conversation

@vito

@vito vito commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What

The Python SDK names identifiers the way the engine does, by asking it, with no casing converters of its own. Follows dagger/go-sdk#90 and dagger/typescript-sdk#120. Supersedes #62.

  • Styling. Generation spells each Python identifier styled from a schema with naming(version:) { formatIdentifiers(casing: SNAKE) } at the schema's version: one call up front for every name in the schema, then a direct call for any name not in that map. No converter is kept, even for schemas before the cut: experimental_with_all_gp_us becoming experimental_with_all_gpus is an intended 1.0 break. The codegen execs reach the session as nested clients.
  • Predictions. At run time the module asks CurrentModule.naming (core: add ModuleSource.naming for SDK codegen dagger#14996), once per call, for the names of its own interfaces, their functions and arguments, and its enum members. Those are the names that calls through its own interfaces select. No prediction mirror is kept.
  • Main object. The module build sets DAGGER_MAIN_OBJECT, for every SDK version a module vendors, from ModuleNaming.mainObject over the classes its source decorates with @object_type. A short ast script lists those classes without importing the module. The build fails when the engine takes none of them. The naming used is modSource.naming in the runtime, currentModule.naming in the generated entrypoint, and at generation the naming of the source generation writes (the runtime's new installed function). The final generated config and manifest are staged before main-class selection and entrypoint rendering, including direct generation. No naming ID crosses into the Python exec. The strcase mainObjectName is gone.
  • New modules. dagger module init names a new module's class with ModuleNaming.typeNames of the module as generation writes it, so http-server gets HTTPServer.
  • Clients. A client schema is read with clientSchemaIntrospectionJson(clientVersion:). withEngineVersion renamed a module's own declarations: a pinned module's client said NamingAppHttpFetcher where the engine serves NamingAppHTTPFetcher.
  • Input fields. The generator records every input field's GraphQL name, and the query builder sends that name instead of converting the Python one back.
  • Fixed along the way. Arguments of calls through an own interface were looked up by API name, so from_ or a Name() override raised KeyError.
  • Not changed. Package and project names are still lowercased locally (packageNameFor in runtime/build.dang, packageName in render-template, partition.package_name in codegen). These are Python package names, not schema identifiers.

Pin range decision

  • Engine floor. v1.0.0-beta.26, the first release that answers formatIdentifiers, CurrentModule.naming and ModuleNaming. It is declared, not checked: engineVersion in the SDK's, the runtime's and the e2e module's manifests, and [imports.Dagger] dagger in the SDK's and the runtime's dang.toml. The SDK's own engine refusal (engineRefusal, checkEngine) and engine-floor-refusal-check are removed. An engine from v1.0.0-beta.18 to v1.0.0-beta.25 fails while it loads the SDK, before generation writes anything. Users on those engines pin v1.8.0; users on v1.0.0-beta.14 to v1.0.0-beta.17 pin v1.1.1.
  • Generated entrypoint. It needs v1.0.0-beta.26 or later to run, like generation: it hands the build currentModule.naming. Its header says so.
  • Pins. targetVersion may name v1.0.0-beta.26 to v1.0.0-beta.27; main allows v1.0.0-beta.18 and later. A released engine serves ModuleNaming only to a module that declares v1.0.0-beta.26 or later (AfterVersion("v1.0.0-beta.26") in dagger/dagger core/schema/modulenaming.go). A pinned module's dang.toml declares its pin, so a module pinned below v1.0.0-beta.26 could not load its generated entrypoint. targetFloor in python-sdk.dang (formerly engineFloor) is now v1.0.0-beta.26. Generation refuses a lower pin before it writes anything; target-version-check covers that with v1.0.0-beta.25.
  • Target. The default target stays v1.0.0-beta.27. Both allowed releases are past the identifier casing cut, so modules and their clients get the new names (HTTPServer, NamingAppHTTPFetcher, ARM64). On a v1.0.0-beta.27 engine, core reads the same in both views: no field is gated on v1.0.0-beta.27.
  • e2e module. It declares v1.0.0-beta.26 so that it can load the SDK and the runtime, whose functions take a ModuleNaming. At that version it reads ModuleSource.clientSchemaIntrospectionJson.

Testing

On the released v1.0.0-beta.27 engine and CLI:

  • cd sdk && uv run --frozen pytest -q -m "not slow": 581 passed.
  • dagger check -m .dagger/modules/e2e <check>, one at a time, all pass: init-naming-check, naming-check, dang-config-check, target-version-check, target-version-cli-check, generate-scope-pins-check, generate-scope-stale-target-check, generate-scope-view-check, generate-scope-init-check, runtime-call-check, sdk-test-check, remote-entrypoint-replaced-check, resources-generate-check, static-scope-init-check, generate-scope-clients-check, generate-scope-existing-check, entrypoint-client-call-check, root-init-ignores-check, client-target-manifest-check, collections-check, collection-kinds-check, collections-client-check, cli-sdk-check.
  • cli-sdk-check expects class SDKSettings: for a module named sdk-settings, as the engine names it past the identifier casing cut; main expects SdkSettings.

Several checks finished in seconds, so cached steps cannot be ruled out.

Before merge

  • CI's dagger check passes on v1.0.0-beta.27.

Known limitations

  • runtime/build.dang scans only decorators literally named object_type, so an aliased decorator (from dagger import object_type as obj) fails main-object selection.
  • The committed sdk/src/dagger/client/gen.py has no _graphql_names, so serializing an input such as BuildArg raises until it is regenerated on the floor engine.

Engine issues (not worked around)

  • An own interface whose function takes an own enum makes the module's own session refuse to load its schema (core/interface.go:369). Enum conversion through interfaces is covered by unit tests only.
  • Naming.formatIdentifiers styles with the engine's rules on both sides of the cut: every v1 prerelease shares one naming dictionary, so version: doesn't bring back the old rules. So dagger module init names a new module's class with typeNames of the module as generation writes it.

If the floor moves

  • The declared floor: dagger-module.toml, dang.toml, runtime/dagger-module.toml, runtime/dang.toml, .dagger/modules/e2e/dagger.json.
  • The pin bound: targetFloor in python-sdk.dang, floorVersion in .dagger/modules/e2e/main.dang.
  • sdk/src/dagger/mod/_entrypoint.py: the generated entrypoint's header, and the goldens under sdk/tests/mod/golden/.
  • README.md, docs/collections.md, and cut comments in python-sdk.dang and sdk/tests/mod/test_naming.py.

@vito
vito force-pushed the format-identifiers branch 5 times, most recently from ba59016 to b9994f7 Compare November 4, 2026 20:59
@vito
vito changed the base branch from main to python-dang-config November 4, 2026 21:00
@vito
vito added this pull request to stack #81 November 4, 2026 21:00
Base automatically changed from python-dang-config to main November 5, 2026 13:33
@eunomie
eunomie force-pushed the format-identifiers branch from b9994f7 to 917b459 Compare November 5, 2026 13:48
@vito
vito force-pushed the format-identifiers branch from 997b0a6 to 154cbf9 Compare November 6, 2026 17:59
vito and others added 17 commits November 17, 2026 17:49
A call through one of the module's own interfaces binds its arguments by
their Python names, but looked their schema names up by the API name, so an
argument renamed with Name() or a trailing underscore (from_) failed with a
KeyError.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Calls through the module's own interfaces select the schema names the engine
gave the module's declarations, which the runtime used to guess: the main
class's name followed by the interface's, function and argument names
camelCased by snake_to_camel, and the module's enum members by their Python
names. The engine names them by the rules of the version it names the
module by, so the guesses were wrong past the identifier casing cut
(NamingAppHTTPFetcher, ARM64) and before it too (strcase writes e2e_test
e2ETest, arm64 ARM_64, FooHTTPClient FooHttpclient).

Now the runtime asks: one CurrentModule.naming query per call, before
anything is invoked, for the interfaces' type names, their functions' and
arguments' names, and the members of the module's enums. A module without
interfaces asks nothing. A name the engine wasn't asked about, or can't
name, fails the call. Own enum members go over the wire by the engine's
names and come back by them.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The generator spelled Python names with a converter of its own: acronym
runs title-cased, then graphql-core's camel_to_snake, which cuts
experimentalWithAllGPUs into experimental_with_all_gp_us. The engine knows
where its names' words are, so it spells them now: formatIdentifiers(casing:
SNAKE) at the schema's version, asked once up front for every type, field,
argument and input field name of the schema, and directly for any other
name the generator styles (a name a deprecation notice refers to). A name
the engine can't format fails the generation. No converter is kept, so
schemas before the identifier casing cut get the engine's spelling too
(experimental_with_all_gpus): an intended break of 1.0.

The generator reaches the engine as a nested client of the session, with
the standard library's HTTP client, so the codegen execs run with
experimentalPrivilegedNesting. The keyword and builtin suffix stays the
SDK's. The unit tests style made-up schemas with a stand-in, since they run
no engine; the e2e checks generate with one.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Generation asks the engine how to spell the schema's Python names
(formatIdentifiers) and a module asks it what it named its own declarations
(CurrentModule.naming). v1.0.0-beta.26, the floor dagger-module.toml already
declares, is the first release that answers both.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
naming-check generates naming-app, a static entrypoint module with an own
interface and enum whose schema names differ between the legacy rules and
the engine's identifier naming rules, without a dang.toml (named by
v1.0.0-beta.20) and with one pinning v1.0.0-beta.22. It generates
naming-caller with a client of it, checks the Python names generation wrote
and the names the client has for naming-app's declarations, and runs
naming-caller's check, which calls naming-app through its client so that
naming-app's runtime calls its own interface by the names the engine gave
it.

The caller is a second module, as a module calls itself through a client
of its own. The interface takes no own enum: the engine refuses an own
interface whose function takes one in the module's own session, so the
module could not load its schema at all.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The runtime picked the main class by a strcase port, in Dang, of the
engine's builtin Python runtime: DAGGER_MAIN_OBJECT, the module's name
converted with strcase.ToCamel. Which class is the main object is the
engine's to say, by the naming rules it names the module by, so the
runtime asks it (ModuleNaming.mainObject), with every object type the
module's code registers as a candidate, in the query that asks for its
interfaces' names: one query per call. A module the engine names no main
object for fails to load, saying which classes it had.

The module is the one the runtime runs in (CurrentModule.naming), except
when generation renders a module's static entrypoint, which runs in the
SDK's own module: mod.dang hands the renderer, as a nested client, the
ID of the module source the engine will name (ModuleSource.naming). It
is asked from Python so that this module, which an engine before the
floor still loads in order to refuse it, names no field such an engine
lacks.

The code is imported as the default package, or through a configured
entry point, without a class name to import.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
A client's schema was read with withEngineVersion(view), which makes the
module declare the scope's version, and since the identifier casing cut
that also names its declarations by that version's rules: the client of a
module the engine names by v1.0.0-beta.22 had NamingAppHttpFetcher where
the engine serves NamingAppHTTPFetcher. clientSchemaIntrospectionJson's
clientVersion describes core at the scope's view and leaves the module at
the version it declares.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
A new module's main class was named with strcase.ToCamel of the module's
name, a casing converter of the SDK's own. The engine spells it now
(formatIdentifiers, PASCAL), asked by the template renderer as a nested
client: k8s-tools is K8sTools, as the engine's naming rules name it. The
unused ModuleImport (strcase.ToKebab) and mod._utils.to_pascal_case go
too.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The query builder derived an input field's GraphQL name from its Python
name with snake_to_camel, and the generator recorded only the names that
conversion missed. Python names are the engine's spelling now, so nothing
converts them back: the generator records every field's GraphQL name and
the query builder sends that one, refusing a field without one.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The runtime declares engineVersion v1.0.0-beta.26, as the SDK already does,
and both declare it in dang.toml, which decides a Dang module's version. The
SDK's own engine refusal and its check go: no engine that loads the SDK is
below the floor. engineFloor becomes targetFloor, the oldest release a
targetVersion pin may name, and moves to v1.0.0-beta.26: the generated
entrypoint needs ModuleNaming, which an older view does not serve.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The Python runtime asked the engine for the main object itself, which only
an SDK new enough to ask could do: a module vendoring an older SDK reads
DAGGER_MAIN_OBJECT and found it unset. The build sets it again, for every
SDK version, from ModuleNaming.mainObject over the classes the module's
source decorates with @object_type, which a short ast script lists without
importing the module. The build fails when the engine takes none of them.

The naming is the module's: the runtime's modSource.naming, the
entrypoints' currentModule.naming, and at generation the naming of the
source generation writes, through the runtime's new installed function.
The Python side goes back to asking only for its interfaces' names, and
generation no longer hands the renderer a module source ID.

The e2e module declares engineVersion v1.0.0-beta.26: a released engine
hides ModuleNaming, which the runtime's functions now take, from a module
that declares an older version. At that version it reads
clientSchemaIntrospectionJSON as clientSchemaIntrospectionJson.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
- The code generator reaches its session without a proxy: urllib honored
  the HTTP_PROXY an exec inherits, and a non-JSON error reply escaped as a
  traceback.
- The main object scan skips a file this Python can't parse, which the
  module may never import.
- experimentalPrivilegedNesting goes from the execs that reach the session:
  nesting is the default of the v1 API, which ignores the flag.
- The generated entrypoint's header names the beta.22 floor, and the README
  says which rules name a module's own declarations.
- A comment no longer points at the deleted engine refusal.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The template named a new module's class with formatIdentifiers, which
spells by the newest rules whatever the version. A new module has no
dang.toml, so the engine names it by v1.0.0-beta.20's legacy rules, and
takes HTTPServer, the class of `http-server`, for no main object: the module
did not load. Generation now asks the engine how it will name the module
(ModuleNaming.typeNames of the module name), of the manifest it writes,
before the template renders, and hands the name to render-template.

init-naming-check generates http-server without a version and pinned past
the cut, and loads it.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The shared entrypoint and the runtime name a new module by its manifest
alone, a path of generation's main class naming that no other init check
took.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
The engine, from dagger/dagger 9e25570 on, names a module's main object
pre-cut by what typeNames answers, so init-naming-check now takes k8s-tools
and e2e-test, which strcase spells differently on a second read, on both
sides of the cut. Interface members are named once there, so the naming
check's note about the legacy double normalization goes.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Beta.22 to beta.25 ship without the naming APIs. Move the entrypoint
header, goldens and e2e naming pins to beta.26, and document beta.25 as the
unpinned entrypoint fallback.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
dagger#14996 moved formatIdentifiers under Query.naming(version:), so the
generator now asks naming(version: $v) { formatIdentifiers(...) }, or naming
without a version where it passed none.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Integrate the naming port with generated dang.toml and targetVersion. Stage
the final manifest and config before main-class selection and entrypoint
rendering, while retaining a runtime staging source for the build.

Exercise new configs, the released target, a pin at the beta.26 floor and
owned-config upgrades without resurrecting removed shared settings.

Signed-off-by: Alex Suraci <alex@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
Signed-off-by: Yves Brissaud <yves@dagger.io>
@eunomie
eunomie marked this pull request as ready for review November 18, 2026 10:33
@eunomie
eunomie merged commit a013e36 into main Nov 18, 2026
64 checks passed
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