fix: refactor project naming setup to isolate generated name mappings - #434
Merged
cdsap merged 1 commit intoSep 1, 2026
Merged
Conversation
cdsap
deleted the
issue/431-hermes-refactor-project-naming-setup-to-iso-a1
branch
September 1, 2026 17:10
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.
Summary
Problem
ProjectGenerator.write currently owns both generation orchestration and the rules for mutating the global NameMappings singleton in project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.kt. NameMappings itself is just mutable storage in project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/NameMappings.kt, while writers and planners consume it implicitly from many locations such as project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ProjectWriter.kt and project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/ModulesWriter.kt.
Why this matters
The module and layer naming policy is core generation behavior, but it is hidden inside the application service and applied through global mutable state. That makes naming harder to test directly, increases coupling between graph generation and file-writing infrastructure, and leaves tests vulnerable to state leakage when NameMappings is changed by previous runs.
Proposed change
Extract the name-map calculation from ProjectGenerator.write into a small internal naming component, for example ProjectNameMappings or ProjectNameMappingFactory, that returns immutable layer and module maps from layers, nodes, configured layer names, module name parts, and app-layer rules. Keep NameMappings as the existing compatibility access point for now, but have ProjectGenerator call one configure/apply method with the computed maps instead of building them inline.
Notes
This is a small clean-architecture step: keep file generation infrastructure unchanged, but move a core naming policy out of the orchestration method and make the boundary around global mutable state explicit.
Fixes #431
Changes
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/NameMappings.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectNameMappingFactory.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/ProjectGeneratorTest.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/ProjectNameMappingFactoryTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck