Repository navigation
engine/naming: add identifier case conversion - #14659
Merged
Merged
Conversation
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
force-pushed
the
naming/1-engine-naming
branch
from
October 14, 2026 01:07
93af4c3 to
22100e8
Compare
vito
marked this pull request as ready for review
October 14, 2026 14:14
sipsma
approved these changes
Oct 14, 2026
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 1/N of the stack splitting #14501 (identifier casing). Plan: #14501 (comment)
Refs #13668
Stack
engine/naming(this PR)formatIdentifiersAPI, on 1cmd/codegen+ Go, on 4naming/5-sdks-combined(5a–5h combined, no PR of its own); retarget to main once 5a–5h mergeWhat'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 asPASCAL,CAMEL,SNAKE,SCREAMING_SNAKE,KEBABorFLAT, inUPPERCASE(HTTPClient) orCAPITALIZED(HttpClient) acronym style.APIv1→API · v1,UUIDV7→UUID · v7,APIS3→API · s3), and a suffix is digits then an optional pluralsthat ends the word (HTTP2s→HTTP+2s). No dictionary entries are needed for versions or product names like S3.naming.MaxLength) fail withErrTooLong, and the lookups are capped by the longest dictionary entry, sinceformatIdentifiersparses whatever a client sends.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.TestInitialDictionaryFrozenpinsInitialentry by entry, so a released dictionary can't change by accident.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.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.goallowlists 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 vetandgo test ./engine/naming/...golangci-lint/lint-allandmarkdown-lint/lintchecks