Skip to content

engine/naming: add identifier case conversion - #14659

Merged
vito merged 5 commits into
mainfrom
naming/1-engine-naming
Oct 14, 2026
Merged

vito merged 5 commits into
mainfrom
naming/1-engine-naming

Conversation

@vito

@vito vito commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Refs #13668

Stack

  1. engine/naming: add identifier case conversion #14659 engine/naming (this PR)
  2. core: add formatIdentifiers naming API #14667 additive formatIdentifiers API, on 1
  3. dagql: accept hidden transition aliases #14668 dagql hidden transition aliases, on 2 (ship in the same engine release as 2)
  4. core: name modules with engine/naming from v1.0.0-beta.21 #14669 engine module naming, on 3
  5. SDK codegen:
  6. core: rename non-canonical core names from beta.21 #14681 core renames, on naming/5-sdks-combined (5a–5h combined, no PR of its own); retarget to main once 5a–5h merge

What's in it

  • engine/naming: the single implementation of identifier case conversion. It parses a name in any casing into words tagged WORD / ACRONYM / TERM, using a dictionary of acronyms and terms first and a case heuristic as fallback, then formats them as PASCAL, CAMEL, SNAKE, SCREAMING_SNAKE, KEBAB or FLAT, in UPPERCASE (HTTPClient) or CAPITALIZED (HttpClient) acronym style.
  • Versions and digit suffixes: a lone letter with digits after an acronym is its own word (APIv1 → API · v1, UUIDV7 → UUID · v7, APIS3 → API · s3), and a suffix is digits then an optional plural s that ends the word (HTTP2s → HTTP+2s). No dictionary entries are needed for versions or product names like S3.
  • Bounded work: names over 256 bytes (naming.MaxLength) fail with ErrTooLong, and the lookups are capped by the longest dictionary entry, since formatIdentifiers parses whatever a client sends.
  • Versioned dictionary: DictionaryFor(engineVersion) picks the dictionary a module or client gets from the engine version it declares, so adding a term later never renames anything in an existing module. TestInitialDictionaryFrozen pins Initial entry by entry, so a released dictionary can't change by accident.
  • Test vectors: testdata/vectors.json (the cases from the design doc), plus tests that check idempotence and round-tripping across the vectors and every name in the current core schema.
  • Design doc: hack/designs/identifier-casing.md, landed whole. It describes the end state of the whole stack (core API, engine module naming, SDK integration, aliases, versioning), not just this PR.

No behaviour change

Nothing imports the package yet. Later PRs in the stack add the core API (formatIdentifiers), the hidden transition aliases, engine module naming, SDK codegen and the core renames.

Changes from the final tree in #14501: the version, digit-suffix and length rules above (from review), and schema_test.go allowlists the 7 core names main still serves (asSdkName, callId, filterUri, parentShas, pushUrl, shortSha, withoutUri). The core-renames PR at the end of the stack empties that list again.

Testing

  • go build, go vet and go test ./engine/naming/...
  • golangci-lint/lint-all and markdown-lint/lint checks

vito added 2 commits October 13, 2026 21:07
Add engine/naming, the single implementation of identifier case conversion
described in hack/designs/identifier-casing.md: parse a name in any casing
into WORD/ACRONYM/TERM words using a versioned dictionary of acronyms and
terms with a case heuristic as fallback, and format them as PASCAL, CAMEL,
SNAKE, SCREAMING_SNAKE, KEBAB or FLAT in UPPERCASE or CAPITALIZED acronym
style.

Nothing uses it yet. The design doc describes the end state of the whole
stack split out of #14501.

Refs #13668

Signed-off-by: Alex Suraci <[email protected]>
TestCoreSchemaCanonical expected the core schema as it is after the
renames at the end of the stack. On main, asSdkName, callId, filterUri,
parentShas, pushUrl, shortSha and withoutUri are still served, so list
them as known non-canonical. The core-renames PR empties the list again.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito force-pushed the naming/1-engine-naming branch from 93af4c3 to 22100e8 Compare October 14, 2026 01:07
@vito
vito added this pull request to stack #14670 October 14, 2026 02:32
@vito
vito marked this pull request as ready for review October 14, 2026 14:14
vito added 3 commits October 14, 2026 21:22
A known acronym followed by a version came apart: APIv1 parsed as AP · iv1,
and its PASCAL form APIV1 as one word apiv1, so json_v2_schema and
JSONV2Schema got different names. A one-letter word with digits is now a word
of its own after a run of capitals (APIv1 → API · v1), and inside a run that
entries otherwise cover (APIV1, UUIDV7, APIR2); its letter counts as
uncovered, so M3U8 stays whole.

Suffixes now follow digits-then-plural order, and the plural ends the word.
The S of S3 is no longer read as a plural (APIS3 was API+s3, now API · s3),
and a plural after digits is now recognized (HTTP2s was HTTP · 2s, now
HTTP+2s). No product-name entries such as S3 are needed.

Core schema names and existing vectors are unchanged. The design doc, test
vectors and vectors.json cover the new rules.

Signed-off-by: Alex Suraci <[email protected]>
Parsing time grew roughly with the cube of a name's length: 9-12s for a 4KB
name, which formatIdentifiers would parse for any client. Reject names over
MaxLength (256 bytes) with ErrTooLong, and avoid the superlinear work
underneath:

- dictionary matching stops extending once a span has more letters than the
  longest entry plus a plural "s";
- covering a run of capitals only looks up spans as long as the longest
  entry;
- heuristic words are scored from an incremental letter count and only built
  when they would win.

The worst names found now parse in under 0.3ms at the limit (4.7ms before).
Without the limit, 4KB takes 58ms instead of 11.6s. Results are unchanged.

Signed-off-by: Alex Suraci <[email protected]>
Stable names depend on a released dictionary never changing: an added entry
renames every module name that contains it. Nothing enforced that, since the
shared vectors only cover their own inputs, so adding AWS would have passed.

TestInitialDictionaryFrozen compares Initial, entry by entry, against a
frozen copy of its spellings and capitalized forms, and reports each entry
gained, lost or changed with a pointer to version.go's releases.

Signed-off-by: Alex Suraci <[email protected]>
@vito
vito merged commit 4e10422 into main Oct 14, 2026
94 checks passed
@vito
vito deleted the naming/1-engine-naming branch October 14, 2026 23:28
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