Skip to content

core: add formatIdentifiers naming API - #14667

Merged
vito merged 6 commits into
mainfrom
naming/2-identifier-api
Oct 15, 2026
Merged

vito merged 6 commits into
mainfrom
naming/2-identifier-api

Conversation

@vito

@vito vito commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Refs #13668

Stacked on #14659, now merged; this PR targets main.

What's in it

  • Core API (@experimental, served at v1.0.0 views only, prereleases included):
    • Query.identifier(name): parse a name in any casing into Identifier { name, words, format(casing, acronyms) }, with IdentifierWord { text, suffix, kind, term }.
    • Query.formatIdentifiers(names, casing, acronyms, version): format many names at once and return plain strings in input order. This is the call SDK codegen will use. version picks the naming dictionary of the schema being generated, and defaults to the caller's. It's DoNotCache: formatting ~960 names takes about a millisecond, but publishing a result with a list argument that big to the cache took over 200 ms.
    • Query.namingDictionary: the acronyms and terms (NamingTerm { spelling, capitalized }) of the caller's dictionary.
    • The enums Casing, AcronymStyle and IdentifierWordKind.
    • Identifiers persist their words instead of re-parsing, so a cached value formats the same way after a dictionary change.
  • dagql perf (dagql: render leaf list elements directly, cherry-picked from Centralize identifier casing in the engine and SDKs #14501): a list of plain values whose elements are query leaves is now rendered straight from the list. Before, each element got its own result: a deep copy of the list's call frame, plus a cache entry per element when the list was cached. That cost grows quadratically with a large list argument, and a ~1000-name formatIdentifiers call took ~780 ms instead of ~11 ms.
  • Regenerated output: schema snapshot and API reference docs, plus the Go, Python, TypeScript, Rust, Elixir and PHP core client bindings. All of these are pure additions.

No behaviour change for existing names

This PR adds API and renames nothing. core.IdentifierNamingVersion (v1.0.0-0) and core.CallerView sit in core/gqlformat.go, where the final tree has them, but here they only gate and parameterize the new API. Module naming (core.Namer) comes later in the stack.

Left for later PRs: hidden transition aliases (PR 3), engine module naming (PR 4), SDK codegen that uses formatIdentifiers (PRs 5x), and core renames (PR 6).

Release ordering

This should ship in an engine release, together with PR 3 (hidden aliases), before the rest of the stack. The external SDK ports can start once that release is out. SDK codegen only formats names through the engine when the schema it generates from has Query.formatIdentifiers, and otherwise falls back to its old converter.

Testing

  • go build, go vet; go test ./dagql/... ./core/schema/ ./engine/naming/..., plus the persisted-metadata tests in ./core
  • TestLeafListElements (dagql): leaf list elements render correctly, nulls included, and add no cache entries
  • TestFormatIdentifiersVersion (core/schema): the version argument
  • TestIdentifier integration suite: words, format, formatIdentifiers, errors (non-ASCII, no letters or digits, over 256 bytes), the dictionary, v0.21.0 clients not seeing the API, and every core schema name formatting the same way as engine/naming
  • golangci-lint/lint-all

API changes

go -C hack/sdl-diff run . 4e1042289bc6ed9fe44b440703fe49d379c285ec:docs/docs-graphql/schema.graphqls 0aa86018c35403febf5ebabe7ef72653f7b260d2:docs/docs-graphql/schema.graphqls

# Added
"""
How acronyms and terms are written where a word starts with a capital.
"""
enum AcronymStyle {
  """
  HTTPClient, IPv6Address, GitHubRepo
  """
  UPPERCASE
  """
  HttpClient, Ipv6Address, GitHubRepo
  """
  CAPITALIZED
}

# Added
"""
A convention for joining words into an identifier.
"""
enum Casing {
  """
  HTTPClient
  """
  PASCAL
  """
  httpClient
  """
  CAMEL
  """
  http_client
  """
  SNAKE
  """
  HTTP_CLIENT
  """
  SCREAMING_SNAKE
  """
  http-client
  """
  KEBAB
  """
  httpclient (output only: drops word boundaries)
  """
  FLAT
}

# Added
"""
A name parsed into words, which can be formatted in any casing.
"""
type Identifier implements Node {
  """
  A unique identifier for this Identifier.
  """
  id: ID!
  """
  Format the identifier in a casing.
  """
  format(
    """
    The casing to format the identifier in.
    """
    casing: Casing!

    """
    How to write acronyms and terms where a word starts with a capital.
    """
    acronyms: AcronymStyle = UPPERCASE
  ): String!
  """
  The name as given.
  """
  name: String!
  """
  The words that make up the name, in order.
  """
  words: [IdentifierWord!]!
}

# Added
"""
One word of an identifier.
"""
type IdentifierWord implements Node {
  """
  A unique identifier for this IdentifierWord.
  """
  id: ID!
  """
  The dictionary entry this word matched, if any.
  """
  term: NamingTerm
  """
  Standard spelling: "client" (WORD), "HTTP" (ACRONYM), "GitHub" (TERM).
  """
  text: String!
  """
  Trailing digits and/or a plural "s", in that order: SHA+"s", OAuth+"2", HTTP+"2s".
  """
  suffix: String!
  """
  The kind of word.
  """
  kind: IdentifierWordKind!
}

# Added
"""
The kind of a word in an identifier.
"""
enum IdentifierWordKind {
  """
  An ordinary word.
  """
  WORD
  """
  An acronym, from the dictionary or a run of capitals.
  """
  ACRONYM
  """
  A dictionary term with a fixed mixed-case spelling (GitHub, IPv6).
  """
  TERM
}

# Added
"""
An entry in the naming dictionary.
"""
type NamingTerm implements Node {
  """
  A unique identifier for this NamingTerm.
  """
  id: ID!
  """
  Standard spelling: "HTTP", "IPv6", "GitHub", "iOS".
  """
  spelling: String!
  """
  Spelling in the CAPITALIZED style: "Http", "Ipv6", "GitHub", "Ios".
  """
  capitalized: String!
}

extend type Query {
  # Added
  """
  Parse a name in any casing into words.

  Known acronyms and terms come from the naming dictionary; everything else
  falls back to the case heuristic. Errors on non-ASCII input, input with no
  letters or digits, or input over 256 bytes.
  """
  identifier(
    """
    The name to parse.
    """
    name: String!
  ): Identifier! @experimental(reason: "Identifier casing APIs are likely to change.")
  # Added
  """
  Format many names at once, for codegen. Returns them in input order.
  """
  formatIdentifiers(
    """
    The names to format, in any casing.
    """
    names: [String!]!

    """
    The casing to format the names in.
    """
    casing: Casing!

    """
    How to write acronyms and terms where a word starts with a capital.
    """
    acronyms: AcronymStyle = UPPERCASE

    """
    The engine version whose naming dictionary to parse the names with, e.g. the
    __schemaVersion of a schema being generated. Defaults to the caller's engine
    version.
    """
    version: String
  ): [String!]! @experimental(reason: "Identifier casing APIs are likely to change.")
  # Added
  """
  The acronyms and terms used to parse and format identifiers.
  """
  namingDictionary: [NamingTerm!]! @experimental(reason: "Identifier casing APIs are likely to change.")
}
Detailed diff
+"""
+How acronyms and terms are written where a word starts with a capital.
+"""
+enum AcronymStyle {
+  """
+  HttpClient, Ipv6Address, GitHubRepo
+  """
+  CAPITALIZED
+  """
+  HTTPClient, IPv6Address, GitHubRepo
+  """
+  UPPERCASE
+}

+"""
+A convention for joining words into an identifier.
+"""
+enum Casing {
+  """
+  httpClient
+  """
+  CAMEL
+  """
+  httpclient (output only: drops word boundaries)
+  """
+  FLAT
+  """
+  http-client
+  """
+  KEBAB
+  """
+  HTTPClient
+  """
+  PASCAL
+  """
+  HTTP_CLIENT
+  """
+  SCREAMING_SNAKE
+  """
+  http_client
+  """
+  SNAKE
+}

+"""
+A name parsed into words, which can be formatted in any casing.
+"""
+type Identifier implements Node {
+  """
+  Format the identifier in a casing.
+  """
+  format(
+    """
+    How to write acronyms and terms where a word starts with a capital.
+    """
+    acronyms: AcronymStyle = UPPERCASE
+
+    """
+    The casing to format the identifier in.
+    """
+    casing: Casing!
+  ): String!
+  """
+  A unique identifier for this Identifier.
+  """
+  id: ID!
+  """
+  The name as given.
+  """
+  name: String!
+  """
+  The words that make up the name, in order.
+  """
+  words: [IdentifierWord!]!
+}

+"""
+One word of an identifier.
+"""
+type IdentifierWord implements Node {
+  """
+  A unique identifier for this IdentifierWord.
+  """
+  id: ID!
+  """
+  The kind of word.
+  """
+  kind: IdentifierWordKind!
+  """
+  Trailing digits and/or a plural "s", in that order: SHA+"s", OAuth+"2", HTTP+"2s".
+  """
+  suffix: String!
+  """
+  The dictionary entry this word matched, if any.
+  """
+  term: NamingTerm
+  """
+  Standard spelling: "client" (WORD), "HTTP" (ACRONYM), "GitHub" (TERM).
+  """
+  text: String!
+}

+"""
+The kind of a word in an identifier.
+"""
+enum IdentifierWordKind {
+  """
+  An acronym, from the dictionary or a run of capitals.
+  """
+  ACRONYM
+  """
+  A dictionary term with a fixed mixed-case spelling (GitHub, IPv6).
+  """
+  TERM
+  """
+  An ordinary word.
+  """
+  WORD
+}

+"""
+An entry in the naming dictionary.
+"""
+type NamingTerm implements Node {
+  """
+  Spelling in the CAPITALIZED style: "Http", "Ipv6", "GitHub", "Ios".
+  """
+  capitalized: String!
+  """
+  A unique identifier for this NamingTerm.
+  """
+  id: ID!
+  """
+  Standard spelling: "HTTP", "IPv6", "GitHub", "iOS".
+  """
+  spelling: String!
+}

 extend type Query {
+  """
+  Format many names at once, for codegen. Returns them in input order.
+  """
+  formatIdentifiers(
+    """
+    How to write acronyms and terms where a word starts with a capital.
+    """
+    acronyms: AcronymStyle = UPPERCASE
+
+    """
+    The casing to format the names in.
+    """
+    casing: Casing!
+
+    """
+    The names to format, in any casing.
+    """
+    names: [String!]!
+
+    """
+    The engine version whose naming dictionary to parse the names with, e.g. the
+    __schemaVersion of a schema being generated. Defaults to the caller's engine
+    version.
+    """
+    version: String
+  ): [String!]! @experimental(reason: "Identifier casing APIs are likely to change.")
+  """
+  Parse a name in any casing into words.
+  
+  Known acronyms and terms come from the naming dictionary; everything else
+  falls back to the case heuristic. Errors on non-ASCII input, input with no
+  letters or digits, or input over 256 bytes.
+  """
+  identifier(
+    """
+    The name to parse.
+    """
+    name: String!
+  ): Identifier! @experimental(reason: "Identifier casing APIs are likely to change.")
+  """
+  The acronyms and terms used to parse and format identifiers.
+  """
+  namingDictionary: [NamingTerm!]! @experimental(reason: "Identifier casing APIs are likely to change.")
 }

@vito
vito added this pull request to stack #14670 October 14, 2026 02:32
@vito vito changed the title Part 2/N of the stack splitting #14501 core: add formatIdentifiers naming API Oct 14, 2026
@vito
vito marked this pull request as ready for review October 14, 2026 14:44
@vito
vito requested review from a team as code owners October 14, 2026 14:44
Base automatically changed from naming/1-engine-naming to main October 14, 2026 23:28
vito added 4 commits October 14, 2026 19:28
A list of plain values (Array, DynamicArrayOutput) gave each element a result
of its own when resolving the response: a deep copy of the list's call frame,
and for a cached list, a cache entry per element. For a call with a large list
argument that is quadratic: formatIdentifiers with the core schema's 961 names
spent ~250ms on per-element cache entries, and ~100ms copying frames when
uncached. Leaf elements need no result, so read them straight from the list.

Signed-off-by: Alex Suraci <[email protected]>
Expose engine/naming through Query.identifier, Query.formatIdentifiers and
Query.namingDictionary, with the Identifier, IdentifierWord, NamingTerm,
IdentifierWordKind, Casing and AcronymStyle types. The API is experimental
and only served at v1.0.0 views (IdentifierNamingVersion, v1.0.0-0),
prereleases included.

formatIdentifiers returns plain strings so SDK codegen can format thousands
of names in one round trip, takes the engine version whose dictionary to use
(codegen passes the __schemaVersion it generates for), and skips the cache:
formatting is far cheaper than publishing a result with a large list
argument.

Identifiers persist their words rather than re-parsing, so a cached value
keeps formatting the same way if the dictionary changes.

Signed-off-by: Alex Suraci <[email protected]>
Add the identifier casing API to the GraphQL schema snapshot and the API
reference pages.

Signed-off-by: Alex Suraci <[email protected]>
Pure additions: the Go, Python, TypeScript, Rust, Elixir and PHP core
bindings for Query.identifier, Query.formatIdentifiers,
Query.namingDictionary and their types.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/2-identifier-api branch from 90158af to 0aa9651 Compare October 14, 2026 23:28
vito added 2 commits October 14, 2026 23:35
engine/naming now orders a suffix as digits then a plural "s" (HTTP+"2s"),
so describe IdentifierWord.suffix that way, and regenerate the schema
snapshot and the SDK clients that carry the description.

engine/naming also rejects names over 256 bytes; cover that error in the
API's error tests, for Query.identifier and Query.formatIdentifiers.

Signed-off-by: Alex Suraci <[email protected]>
Query.identifier listed its errors as non-ASCII input and input with no
letters or digits; it now also rejects names over 256 bytes. Say so, in the
API, the design doc's schema sketch, and the regenerated schema snapshot and
SDK clients.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit cbef9c9 into main Oct 15, 2026
94 checks passed
@vito
vito deleted the naming/2-identifier-api branch October 15, 2026 20:39
vito added a commit to dagger/typescript-sdk that referenced this pull request Oct 22, 2026
Released beta.19 and beta.20 engines already serve Query.formatIdentifiers on
v1 views (dagger/dagger#14667 shipped in beta.20) but still name modules with
strcase, and their __schemaVersion ("v1.0.0") compares past the cut, so
neither tells them apart from beta.21. The SDK registry resolves this SDK to
@main, so those engines run this codegen.

Engine naming now needs both: the schema has formatIdentifiers AND the
engine's own version (Query.version, build metadata ignored, dev builds as
their release) is v1.0.0-beta.21 or later. Codegen is engine-free, so the Dang
layer reads `version` in its session and passes --engine-version to codegen
module, client, entrypoint (both modes), and the packager's library step. An
empty or unparseable version keeps the legacy names.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit to dagger/go-sdk that referenced this pull request Oct 22, 2026
Released v1.0.0-beta.19 and v1.0.0-beta.20 engines already serve
Query.formatIdentifiers at every v1.0.0 view (dagger/dagger#14667), but
still name modules with strcase, and report each of those views as v1.0.0,
so neither the field nor the schema version can tell them apart. Since the
SDK registry resolves the SDK at main, old engines run this codegen.

Identifiers now follow the engine's rules only when the schema has
formatIdentifiers and the engine that served it (Query.version, without
build metadata, dev builds as their release) is v1.0.0-beta.21 or later;
an unknown engine keeps the legacy names. The generators run without an
engine, so go-sdk.dang passes Dagger.version as --engine-version to
module-codegen and the client generator; the core generator queries its
engine. This replaces the schema-version check and NamingVersion.

The source-link catalog now names declarations with the generator's own
configuration, so it no longer drifts from the generated code, and unified
clients keep core's legacy names without a special configuration.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Oct 28, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Oct 28, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Oct 28, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Oct 29, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Oct 29, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Nov 2, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Nov 4, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Nov 5, 2026
#14669 moved Query.identifier, formatIdentifiers, namingDictionary and their
types to the views that name modules by engine/naming (beta.21+), so SDK
codegen could gate on the field's presence. SDKs will instead gate on the
version the target module declares plus the engine's version, and call
formatIdentifiers themselves from their generator execs, which may run at a
pre-cut view. So restore the visibility #14667 shipped: from v1.0.0-0 on.
formatIdentifiers' version argument still selects the dictionary, and module
naming keeps its own gate (core.IdentifierNamingView, beta.21).

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
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