Repository navigation
yaml: back YAML with the go-ruby-yaml library - #43
Merged
Merged
Conversation
Rewire rbgo's YAML/Psych standard library onto the standalone github.com/go-ruby-yaml/yaml emitter+loader (itself ported from rbgo's own internal yaml*.go, so it is behavior-compatible by construction), exactly as rbgo already binds go-ruby-regexp and go-ruby-erb. - Delete the duplicated in-tree YAML logic (yaml_dump.go, yaml_load.go, yaml_object.go: ~1568 lines) and its white-box test (yaml_internal_test.go). - Add yaml_bind.go: the thin binding that maps rbgo's object graph to and from the library's value model (object.Value <-> any), preserving shared / cyclic reference identity on both directions so anchors/aliases round-trip, plus the class-resolution helper. - Rewrite yaml.go to call yaml.Dump / yaml.Load / yaml.SafeLoad; thread safe_load's permitted_classes: through WithPermittedClasses; surface library SyntaxError as Psych::SyntaxError and the dump error as TypeError. The Ruby-facing API (YAML.dump/load/safe_load/load_file/safe_load_file and Object#to_yaml) is unchanged; Puppet's state.yaml round-trip and report write still converge with zero errors. 100.0% cross-package coverage retained. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Rewire rbgo's YAML/Psych standard library so its emitter and loader are the standalone
github.com/go-ruby-yaml/yamllibrary — itself ported from rbgo's own internalyaml*.go, so it is behavior-compatible by construction — exactly as rbgo already bindsgo-ruby-regexpandgo-ruby-erb.What changed
internal/vm/yaml_dump.go,internal/vm/yaml_load.go,internal/vm/yaml_object.go(~1568 lines), plus its white-boxyaml_internal_test.go.internal/vm/yaml_bind.go: the thin binding mapping rbgo's object graph to and from the library's value model (object.Value⇄any). It preserves shared / cyclic reference identity in both directions (a per-operation identity cache) so the library's anchor/alias emission and load round-trip work, and carries the!ruby/object:/!ruby/class/!ruby/moduleclass-resolution helper.internal/vm/yaml.goto callyaml.Dump/yaml.Load/yaml.SafeLoad; threadssafe_load'spermitted_classes:throughWithPermittedClasses; surfaces the library'sSyntaxErrorasPsych::SyntaxErrorand the dump error asTypeError.The Ruby-facing API (
YAML.dump/load/safe_load/load_file/safe_load_fileandObject#to_yaml) is identical.Verification
applyclean-exit probe:grep -c "Error:"prints 0 — the state.yaml round-trip and report write still converge (catalog compiled,notifyfired, catalog applied).gofmt+go vetclean.Library depended on:
github.com/go-ruby-yaml/yaml v0.0.0-20260629093916-8035038027bd.🤖 Generated with Claude Code