Skip to content

sdk/rust: name identifiers with engine-formatted names - #14675

Draft
vito wants to merge 3 commits into
naming/5a-go-codegenfrom
naming/5d-rust-codegen
Draft

vito wants to merge 3 commits into
naming/5a-go-codegenfrom
naming/5d-rust-codegen

Conversation

@vito

@vito vito commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

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

Refs #13668

Stacked on #14673 (shared cmd/codegen infra: codegen introspect --names-out, EngineDev.introspectionNames).

What it does

Rust codegen stops guessing word boundaries with convert_case and uses the names the engine formats with Query.formatIdentifiers. Acronyms and dictionary terms stay whole:

schema name before now
Container.experimentalWithAllGPUs experimental_with_all_gp_us experimental_with_all_gpus
GitBundle.prerequisiteSHAs prerequisite_sh_as prerequisite_shas
JSONValue, LLMTokenUsage JsonValue, LlmTokenUsage unchanged

Types and enum variants use PASCAL:CAPITALIZED, which matches what convert_case already produced for every core type and enum value. Functions, arguments and fields use SNAKE:UPPERCASE. So the regenerated core client changes only the two methods above.

How

  • Offline names file. The Rust generator runs without an engine connection, so it reads the names file that codegen introspect --names-out writes (codegen: name Go identifiers via formatIdentifiers #14673). dagger-bootstrap generate <introspection.json> --names <names.json> passes it in. rust-client-dev produces it with EngineDev.introspectionNames(["PASCAL:CAPITALIZED", "SNAKE:UPPERCASE"]).
  • Fallback. A schema without Query.formatIdentifiers (older engines, pre-v1 views), a missing --names, or a name missing from the file all fall back to the convert_case converter. Older schemas generate byte-identical code (dagger-codegen/src/naming.rs).
  • Deprecated aliases. When a method's Rust name changes, the old name stays as a #[deprecated(note = "use …")] method that forwards to the new one (with an _opts variant where there is one). When an options struct's name changes, the old name stays as a #[deprecated] type alias.
  • Wire names are unchanged. Selections and arguments use the schema names, enum variants keep their #[serde(rename)] to the schema value, and input object fields whose Rust name changes get a #[serde(rename)] that keeps the wire name they had before.

Breaking changes (for maintainers to decide)

  • dagger-sdk users: nothing breaks at compile time. experimental_with_all_gp_us and prerequisite_sh_as still work, but now emit deprecation warnings, which fail builds that use #![deny(warnings)]. Proposed: keep the aliases through 1.0.

  • Not covered by aliases (no current instances): types and enum variants whose Pascal name changes would get no alias. A type alias works for structs, but enum variants can't be aliased. No core type or enum value changes today, but a later dictionary addition could change one.

  • dagger-codegen crate (published): its public API changes:

    • RustGenerator gains a names field, so the RustGenerator {} literal no longer compiles. Use RustGenerator::default() or RustGenerator::with_names(..) instead.
    • FormatTypeFunc is no longer a unit struct. Use FormatTypeFunc::new(names).
    • The templates::*::render_* functions take &CommonFunctions.
    • enum_tmpl::format_name is removed.

    Only dagger-bootstrap is known to use these.

Not in it

  • Core renames (callID, shortSHA, parentSHAs, filterURI, …) and the Rust "old schema names" table that keeps those methods' Rust names (RENAMED_CORE_FIELDS in the final tree) are left to PR 6. This PR's generator doesn't need it, because those fields still have their old schema names here.
  • Runtime: the Rust SDK has no module runtime in this repo, so there's no engineVersion bump or runtime-side name formatting.

Testing

  • rust-client/test, which runs the new dagger-codegen tests:
    • names from the file;
    • wire names kept;
    • deprecated aliases;
    • the legacy fallback without formatIdentifiers or without names.
  • rust-client/cargo-check and rust-client/cargo-fmt.
  • rust-client/apiclient/stale: gen.rs was regenerated against a dev engine built from this branch.

vito added 3 commits October 14, 2026 02:59
dagger-codegen takes the schema's names as the engine formats them (a
names file from `codegen introspect --names-out`, with PASCAL:CAPITALIZED
for types and enum variants and SNAKE:UPPERCASE for functions, arguments
and fields), so acronyms and dictionary terms stay whole:
`prerequisiteSHAs` becomes `prerequisite_shas`, not `prerequisite_sh_as`.

- `dagger-bootstrap generate --names <file>` passes the names file in.
- A schema without Query.formatIdentifiers, an empty names file, or a
  name missing from it keeps the convert_case converter, so older
  schemas generate the same code.
- Methods and options structs whose Rust name changed keep their old
  name as a #[deprecated] alias; input object fields keep their old
  serde wire name.

Signed-off-by: Alex Suraci <[email protected]>
Generate the Rust client with the names file from
EngineDev.introspectionNames, in the formats Rust codegen uses.

Signed-off-by: Alex Suraci <[email protected]>
experimental_with_all_gp_us and prerequisite_sh_as become
experimental_with_all_gpus and prerequisite_shas; the old names stay as
deprecated aliases.

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

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Nov 6, 2026
@vito vito reopened this Nov 24, 2026
@vito vito removed the kind/stale label Nov 24, 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