Port instance-data and single-quote LML fixes - #3
Open
HassanAkbar wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR ports multiple parser/data-processing fixes into lutaml-lml to improve LML instance-data correctness and round-trip serialization, including repeated block accumulation, correct empty-body handling, map-valued attribute preservation, and support for single-quoted strings.
Changes:
- Accumulate repeated
collection/import/exportblocks in instance data instead of overwriting prior blocks. - Fix instance attribute typing/processing to preserve map keys and avoid serialization type errors (e.g.,
to_yaml). - Extend the grammar to parse single-quoted strings (validated via
require '...').
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| spec/lutaml/lml/parser_spec.rb | Updates expectations for multiple collection blocks; adds regression coverage for map-valued attributes and serialization. |
| spec/lutaml/lml/grammar_spec.rb | Adds a test ensuring single-quoted require statements parse correctly. |
| spec/lutaml/lml/data_processor_spec.rb | Adds regression tests for empty attribute bodies and repeated instance block accumulation. |
| spec/fixtures/mixed_lml/instances.lml | Extends fixture instance data with a second collection block. |
| lib/lutaml/lml/models/top_element_attribute.rb | Retypes TopElementAttribute#value to a value wrapper to preserve map keys and avoid type issues. |
| lib/lutaml/lml/models/instance_collection.rb | Changes collections to a true collection attribute (array) to support repeated collection blocks. |
| lib/lutaml/lml/grammar/concerns/primitives.rb | Extends quoted_string to accept both double- and single-quoted strings. |
| lib/lutaml/lml/data_processor/instance_processing.rb | Refactors instance block processing to append/accumulate results across repeated blocks. |
| lib/lutaml/lml/data_processor/attribute_processing.rb | Ensures empty attribute arrays return [] (avoids phantom/incorrect structures). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Ports 4 verified fixes into the LML parser:
collection/import/exportblocks accumulate instead of keeping only the last{}→[], not a phantom attributevalue— now typedLutaml::Lml::LiteralValue(fixes serialization crash + map-key data loss)view X { import '...' }Map values now serialize for real
valuefirst moved toType::Value. That kept the map keys but broke serialization.to_jsonraisedArgumentError.to_yamlemitted a!ruby/objecttag.Document.from_yamlthen refused to load it. That's the CLI'syamlinput path.The cause is upstream. lutaml-model's key-value serializer tests
attribute_type < Type::Value, strictly.Type::Valueisn't a strict subclass of itself, so it fell through to the raw-object branch.LiteralValueis that subclass. It overrides#valueto see through the wrapper the serializer adds.to_jsonandto_yaml.Document.from_yamlandDocument.from_json.Round-trip claim, corrected
The earlier "round-trips cleanly" line only held for LML text and in-memory access. Map-valued documents now round-trip through JSON and YAML too.
Two limits stay, both pre-existing and unchanged:
Document.from_yaml.Full suite: 490 examples, 0 failures.