fix: refactor graphwriter to consume explicit projectnamemaps - #456
Merged
cdsap merged 1 commit intoSep 9, 2026
Merged
Conversation
cdsap
deleted the
issue/455-hermes-refactor-graphwriter-to-consume-expl-a1
branch
September 9, 2026 00:06
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
GraphWriter.render and GraphWriter.write read the mutable global NameMappings singleton instead of receiving name mappings explicitly (GraphWriter.kt:7-25). Tests must mutate and restore global state (GraphWriterTest.kt:19-64), creating hidden coupling and reducing isolation.
Why this matters
Graph rendering is an output concern, but its domain input is implicit global state. This makes concurrent generation and focused unit testing more fragile, and obscures the dependency between ProjectGenerator and GraphWriter.
Proposed change
Pass ProjectNameMaps explicitly to GraphWriter and GraphWriter.render. Have ProjectGenerator retain the maps returned by ProjectNameMappingFactory.create and provide them when constructing each GraphWriter. Update GraphWriterTest to construct ProjectNameMaps directly instead of mutating NameMappings. Preserve NameMappings for the existing module-generation path.
Notes
This establishes an explicit application-to-infrastructure boundary: ProjectGenerator owns mapping creation, while GraphWriter consumes an immutable domain value. It is a small first step toward reducing global coupling without requiring a broad rewrite.
Fixes #455
Changes
project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/ProjectGenerator.ktproject-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriter.ktproject-generator/src/test/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriterTest.ktVerification
./gradlew :project-generator:unitTest./gradlew :cli:test./gradlew ktlintCheck