Skip to content

Replace the in-tree YAML emitter with the yaml-flock dependency - #156

Merged
ctgnz merged 2 commits into
masterfrom
chore/155-replace-yaml-emitter-with-yaml-flock
Oct 1, 2026
Merged

ctgnz merged 2 commits into
masterfrom
chore/155-replace-yaml-emitter-with-yaml-flock

Conversation

@ctgnz

@ctgnz ctgnz commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Replaces jmsfx-generator's in-tree YAML emitter with a dependency on yaml-flock.

Five files go — JmsfxYamlFactory, JmsfxYamlGenerator, JmsfxPrettyPrinter, YamlFlowStyle, YamlForceQuote. JmsfxParser stays, rebuilt on FlockYamlFactory, since it configures a mapper for jmsfx's own model.

The swap is mechanical because the library's API is compatible by construction: YamlForceQuote is identical, YamlFlowStyle widens @Target from TYPE to {TYPE, FIELD, METHOD} so every existing use still compiles, and the factory constructor signature matches. Import swap plus one class name, across 19 files.

⚠️ This cannot pass CI yet, by design

yaml-flock is still 1.0.0-SNAPSHOT and exists only in a local .m2. A GitHub runner has no way to resolve it, so the build here will fail on dependency resolution until one of:

  1. yaml-flock 1.0.0 is published to Central and this PR switches yaml.flock.version to 1.0.0 — this is what Replace the in-tree YAML emitter with the yaml-flock dependency #155 always planned, and the simplest path. The PR waits.
  2. yaml-flock snapshots get published to Central's snapshot repository and jmsfx adds that <repository> — more moving parts, and it makes jmsfx's build depend on a snapshot, which is not something to carry long-term.

Option 1 unless there's a reason to prefer otherwise. The version sits behind a yaml.flock.version property so that switch is one line.

Correcting a premise in #155

The issue anticipated replacing JmsfxPrettyPrinter's two hardcoded field lists with a @YamlBlockStyle annotation, and described country as a latent trap that removing one @YamlFlowStyle would spring.

Neither holds. JmsfxPrettyPrinter has zero references anywhere in the project — never instantiated, never installed on a mapper. Jackson consults a DefaultPrettyPrinter for JSON output only, and YAMLGenerator emits through SnakeYAML without ever asking it. So both field lists were unreachable, not merely inert, and country was never going to spring: removing that @YamlFlowStyle would change nothing.

So this adds no annotation at all. Adding one would introduce behaviour that never existed. (This is the same discovery that killed the equivalent class in yaml-flock itself, where a probe showed identical output for every shape with the printer installed and removed.)

Acceptance criteria, both verified

All three model.yml files round-trip byte-identically through the swapped emitter:

IDENTICAL  jmsfx-standard     (451788 bytes)
IDENTICAL  jmsfx-historical   (40018 bytes)
IDENTICAL  jmsfx-battleorder  (1043 bytes)

Checked by reading each real file and calling writeLibraryModel in memory, comparing bytes — deliberately nothing written into the repo. Their on-disk SHA-256 hashes are also unchanged after a full regeneration of all three libraries.

Regeneration plus one spotless:apply lands on the committed sources. Regenerating left 133 files differing in raw output; one spotless:apply returned every one to the committed source, leaving a clean tree. That is the property #127 established, still holding.

Build

  • mvn -Pstandard verify — BUILD SUCCESS
  • mvn -Phistorical verify — BUILD SUCCESS

Spotless check included in both, so the re-sorted imports are compliant (io.github.ctgnz.jmsfx.* sorts before io.github.ctgnz.yamlflock.* in the trailing group).

Addresses #155 — not closing it, since the switch to 1.0.0 from Central is part of the same issue.

🤖 Generated with Claude Code

jmsfx-generator carried its own mixed flow/block YAML emitter, duplicated in
another ctgnz project. It now depends on io.github.ctgnz:yaml-flock, which is
that code extracted and specified in its own right.

Five files go: JmsfxYamlFactory, JmsfxYamlGenerator, JmsfxPrettyPrinter and the
two annotations. JmsfxParser stays and is rebuilt on FlockYamlFactory, since it
configures a mapper for jmsfx's own model, which is not shared and should not
be.

The swap is mechanical because the library's API is compatible by construction:
YamlForceQuote is identical, YamlFlowStyle widens @target from TYPE to {TYPE,
FIELD, METHOD} so every existing use still compiles, and the factory's
constructor signature matches. So this is an import swap plus one class name.

Corrects a premise in the issue. #155 anticipated replacing
JmsfxPrettyPrinter's two hardcoded field lists with a @YamlBlockStyle
annotation, and called `country` a latent trap that removing one @YamlFlowStyle
would spring. Neither holds: JmsfxPrettyPrinter has zero references anywhere in
the project - never instantiated, never installed on a mapper - so both lists
were unreachable rather than merely inert. Jackson consults a
DefaultPrettyPrinter for JSON output only, and YAMLGenerator emits through
SnakeYAML without ever asking it. The faithful migration therefore adds no
annotation at all, since adding one would introduce behaviour that never
existed.

Verified against both of the issue's acceptance criteria:

- all three model.yml files round-trip byte-identically through the swapped
  emitter - 451788, 40018 and 1043 bytes - checked in memory so that nothing
  was written into the repo, and their on-disk hashes are unchanged after a
  full regeneration
- regenerating all three libraries left 133 files differing in raw output, and
  one spotless:apply returned every one of them to the committed source, which
  is the property #127 established

Both library profiles build: mvn -Pstandard verify and mvn -Phistorical verify,
Spotless check included.

The dependency is 1.0.0-SNAPSHOT behind a yaml.flock.version property, and
moves to 1.0.0 from Central once that is published.

Addresses #155

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
io.github.ctgnz:yaml-flock:1.0.0 is published, so the dependency moves off the
locally installed snapshot and the comment stops describing a future that has
happened.

This is what CI was waiting for: the build here failed only because a GitHub
runner had no way to resolve a snapshot that existed in one local repository,
which was expected and deliberate rather than a problem to fix.

Addresses #155

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ctgnz
ctgnz merged commit 91705a5 into master Oct 1, 2026
1 check passed
@ctgnz
ctgnz deleted the chore/155-replace-yaml-emitter-with-yaml-flock branch October 1, 2026 09:15
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.

1 participant