Skip to content

Port instance-data and single-quote LML fixes - #3

Open
HassanAkbar wants to merge 5 commits into
mainfrom
fix/port-branch-lml-fixes
Open

Port instance-data and single-quote LML fixes#3
HassanAkbar wants to merge 5 commits into
mainfrom
fix/port-branch-lml-fixes

Conversation

@HassanAkbar

@HassanAkbar HassanAkbar commented Jul 23, 2026

Copy link
Copy Markdown
Member

Ports 4 verified fixes into the LML parser:

  • Repeated blocks — multiple collection/import/export blocks accumulate instead of keeping only the last
  • Empty instance body{}[], not a phantom attribute
  • Attribute value — now typed Lutaml::Lml::LiteralValue (fixes serialization crash + map-key data loss)
  • Single-quoted strings — now parse, including view X { import '...' }

Map values now serialize for real

value first moved to Type::Value. That kept the map keys but broke serialization.

  • to_json raised ArgumentError.
  • to_yaml emitted a !ruby/object tag.
  • Document.from_yaml then refused to load it. That's the CLI's yaml input path.

The cause is upstream. lutaml-model's key-value serializer tests attribute_type < Type::Value, strictly. Type::Value isn't a strict subclass of itself, so it fell through to the raw-object branch.

LiteralValue is that subclass. It overrides #value to see through the wrapper the serializer adds.

  • Maps survive to_json and to_yaml.
  • They reload through Document.from_yaml and Document.from_json.
  • Scalars, lists and nil behave exactly as before.

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:

  • Array-valued attributes still fail Document.from_yaml.
  • Four known map bugs are untouched: CSV column mapping, adapter stringification, quoted map keys, hydrate. Measured identical before and after.

Full suite: 490 examples, 0 failures.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/export blocks 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.

Comment thread lib/lutaml/lml/models/instance_collection.rb

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@HassanAkbar
HassanAkbar requested a review from ronaldtse July 28, 2026 14:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated no new comments.

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.

2 participants