Skip to content

fix: refactor graphwriter to consume explicit projectnamemaps - #456

Merged
cdsap merged 1 commit into
mainfrom
issue/455-hermes-refactor-graphwriter-to-consume-expl-a1
Sep 9, 2026
Merged

fix: refactor graphwriter to consume explicit projectnamemaps#456
cdsap merged 1 commit into
mainfrom
issue/455-hermes-refactor-graphwriter-to-consume-expl-a1

Conversation

@cdsap

@cdsap cdsap commented Sep 8, 2026

Copy link
Copy Markdown
Owner

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.kt
  • project-generator/src/main/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriter.kt
  • project-generator/src/test/kotlin/io/github/cdsap/projectgenerator/writer/GraphWriterTest.kt

Verification

  • ./gradlew :project-generator:unitTest
  • ./gradlew :cli:test
  • ./gradlew ktlintCheck

@cdsap
cdsap merged commit 26e8953 into main Sep 9, 2026
18 of 28 checks passed
@cdsap
cdsap deleted the issue/455-hermes-refactor-graphwriter-to-consume-expl-a1 branch September 9, 2026 00:06
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.

Refactor GraphWriter to consume explicit ProjectNameMaps

1 participant