Skip to content

sdk/elixir: name identifiers via the engine (identifier casing 5e) - #14678

Closed
vito wants to merge 4 commits into
naming/5a-go-codegenfrom
naming/5e-elixir-codegen
Closed

vito wants to merge 4 commits into
naming/5a-go-codegenfrom
naming/5e-elixir-codegen

Conversation

@vito

@vito vito commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Part 5e/N of the stack splitting #14501 (identifier casing). Plan: #14501 (comment)

Refs #13668

Stacked on #14673.

What it does

The Elixir client and module codegen now take Elixir names from the engine (Query.formatIdentifiers), instead of converting schema names with Macro. Elixir codegen runs without an engine session, so it reads the names from a sidecar file next to the introspection JSON.

The formats it uses:

Elixir name format example
module (Dagger.X) PASCAL:UPPERCASE HTTPClient
function, argument, variable SNAKE:UPPERCASE prerequisiteSHAs → prerequisite_shas (was prerequisite_sh_as)

The gate is the schema being generated. A schema without Query.formatIdentifiers (pre-v1 views, older engines) gets no names, so codegen keeps the legacy Macro conversion and generates the same code as before. A name missing from the file also falls back to Macro.

What's in it

  • Codegen (sdk/elixir/dagger_codegen):
    • Names file: Dagger.Codegen.Naming reads the names file that codegen introspect --names-out writes (codegen: name Go identifiers via formatIdentifiers #14673). It's passed with mix dagger.codegen generate --names.
    • Gate: Schema.put_names/2 keeps the names only for a schema with Query.formatIdentifiers.
    • Formatter: Formatter.format_module/1, format_var_name/1 and format_function_name/1 look names up there, falling back to legacy_* (the old Macro conversion).
    • Deprecated aliases: object functions and enum value functions whose Elixir name changed keep their legacy name as @doc false @deprecated delegates. No alias is rendered when the legacy name is taken.
    • Input object struct keys keep the legacy conversion, because QueryBuilder sends them to the API as is.
    • Tests: a fixture schema with a names file, generated with names, without names, without Query.formatIdentifiers, and with a name missing from the file.
  • elixir-client-dev: passes engine-dev's introspectionNames(formats: ["PASCAL:UPPERCASE", "SNAKE:UPPERCASE"]) to codegen.
  • Regenerated client: the only change is GitBundle.prerequisite_shas/1, with prerequisite_sh_as/1 kept as a deprecated alias.
  • Runtime (sdk/elixir/runtime):
    • Names for module codegen: before running codegen, the runtime formats the module schema's names with Query.formatIdentifiers, passing the schema's __schemaVersion so they're parsed with that version's dictionary. It mounts them as the --names sidecar (internal/names). A schema without the API gets no sidecar.
    • Runtime engine version: the runtime's own engineVersion moves from v0.21.9 to v1.0.0, for the public formatIdentifiers with version.
    • Go bindings: updated to the v1 view. That covers formatIdentifiers with the Casing/AcronymStyle enums, nullable object getters taking a ctx, and the module's own names (ElixirSDK, withSDK, introspectionJSON).

Breaking changes for Elixir SDK users

Maintainers, please decide whether these are acceptable:

  1. Client function renames, with deprecated aliases. The published client is generated from the v1 schema, so every user gets the new names. Today that's only Dagger.GitBundle.prerequisite_sh_as/1 → prerequisite_shas/1. The old name still works, but it emits a deprecation warning at compile time, and --warnings-as-errors turns that into a failure.
  2. v1 modules regenerate their dagger_sdk client with engine names. This applies to modules declaring engineVersion ≥ v1.0.0-0. Renamed functions and enum value functions keep deprecated aliases, as in (1). Pre-v1 modules are unchanged.
  3. No aliases for Elixir module (type) names. If a dependency's type is renamed by engine module naming (core: name modules with engine/naming from v1.0.0-beta.21 #14669; e.g. DaggerCli → DaggerCLI), its Elixir module becomes Dagger.DaggerCLI, and Dagger.DaggerCli is gone. Code naming the old module has to be updated.
  4. Some aliases are invented. The alias name comes from the legacy conversion of the current schema name. For dependency names that core: name modules with engine/naming from v1.0.0-beta.21 #14669 renamed, it can produce an alias that never existed (getHTTPURL → a deprecated get_httpurl next to get_http_url). This only adds noise and breaks nothing. Core renames get an old-names table in PR 6.
  5. The runtime needs an engine with formatIdentifiers(version:). The SDK module now declares engineVersion: v1.0.0, so this version of sdk/elixir can't serve as a module runtime on older engines. Per ordering constraint 2 of the plan, it must ship with or after engine module naming (core: name modules with engine/naming from v1.0.0-beta.21 #14669).

Not in it

  • PR 6 material: the core renames (callID, shortSHA, filterURI, FunctionCachePolicy values, …) and Elixir's renamed-core-fields table (Formatter.legacy_field_name/2).
  • Abandoned designs from Centralize identifier casing in the engine and SDKs #14501: identifier words in schema JSON, the local word formatter and its vectors, and __formatIdentifiers.

Testing

  • Checks: elixir-client/codegen-test, elixir-client/lint, elixir-client/sdk-test and elixir-client/client-library/stale all pass.
  • Runtime: go test ./internal/names/ and go vet ./... in sdk/elixir/runtime.
  • Integration: TestElixir passes (23 tests). The existing modules are all pre-v1, so they cover the legacy path. The new TestElixir/TestNaming uses a v1.0.0 module and checks two things: its regenerated client has both prerequisite_shas/1 and the deprecated prerequisite_sh_as/1, which needs the runtime's names sidecar; and its http_url_for(host_name:) is callable as http-url-for --host-name.
  • Not verified: the runtime's Go bindings were hand-edited to the v1 view (from Centralize identifier casing in the engine and SDKs #14501's final tree), not regenerated with go-sdk/generate. They build and vet, and the engine regenerates them at load anyway.

vito added 4 commits October 14, 2026 03:14
Elixir codegen runs without an engine session, so it reads the schema's
names as the engine formatted them from the sidecar file `codegen introspect
--names-out` writes (`mix dagger.codegen generate --names`, see
Dagger.Codegen.Naming): PASCAL:UPPERCASE for modules, SNAKE:UPPERCASE for
functions, arguments and variables. The names are only used for a schema with
Query.formatIdentifiers; without them, or for a name missing from the file,
codegen keeps the legacy Macro conversion, so older schemas generate the same
code.

Functions and enum value functions whose name changes keep their legacy name
as a deprecated alias. Input object struct keys keep the legacy conversion:
they are sent to the API as is.

elixir-client-dev passes the names from engine-dev's IntrospectionNames.

Signed-off-by: Alex Suraci <[email protected]>
GitBundle.prerequisiteSHAs becomes prerequisite_shas/1, keeping
prerequisite_sh_as/1 as a deprecated alias. Nothing else changes.

Signed-off-by: Alex Suraci <[email protected]>
The runtime runs Elixir codegen on the module's introspection JSON in an exec
without an engine session. It now formats the schema's names with
Query.formatIdentifiers, passing the schema's __schemaVersion so they are
parsed with that version's naming dictionary, and hands them to codegen as
the --names sidecar. A schema without Query.formatIdentifiers gets no sidecar
and keeps the legacy conversion (internal/names).

The runtime moves from engineVersion v0.21.9 to v1.0.0 for the public
Query.formatIdentifiers. Its Go bindings are updated to the v1 view:
formatIdentifiers with the Casing and AcronymStyle enums, nullable object
getters taking a context, and the module's own names (ElixirSDK, withSDK,
introspectionJSON).

Signed-off-by: Alex Suraci <[email protected]>
A v1 Elixir module's generated client follows the engine's names, with the
legacy names as deprecated aliases, and its own snake_case functions and
arguments are callable under their engine names.

Signed-off-by: Alex Suraci <[email protected]>
@vito

vito commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Closing: the in-repo SDKs are now legacy. This work will be redone as a PR against github.com/dagger/elixir-sdk (identifier-casing branch) once the engine side (view-gated naming at v1.0.0-beta.20) lands. The branch is kept for reference.

@vito vito closed this Oct 22, 2026
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.

1 participant