lutaml-model 0.8.203 → 0.8.204

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +5 -0
  3. data/.github/workflows/lml-conformance.yml +71 -0
  4. data/.gitignore +7 -0
  5. data/README.adoc +1 -0
  6. data/docs/_guides/lml-cross-language.adoc +128 -0
  7. data/docs/_references/lml-conformance.adoc +78 -0
  8. data/docs/_references/lml-contract.adoc +290 -0
  9. data/lib/lutaml/model/lml/artifact_verifier.rb +205 -0
  10. data/lib/lutaml/model/lml/bundle.rb +171 -0
  11. data/lib/lutaml/model/lml/document.rb +46 -10
  12. data/lib/lutaml/model/lml/document_validator.rb +840 -0
  13. data/lib/lutaml/model/lml/exporter/v1_projector.rb +102 -0
  14. data/lib/lutaml/model/lml/exporter/v2_projector.rb +401 -0
  15. data/lib/lutaml/model/lml/exporter.rb +223 -87
  16. data/lib/lutaml/model/lml/graph_exporter.rb +248 -0
  17. data/lib/lutaml/model/lml/importer.rb +180 -0
  18. data/lib/lutaml/model/lml/mapping_compiler.rb +401 -0
  19. data/lib/lutaml/model/lml/materialization.rb +257 -0
  20. data/lib/lutaml/model/lml/ordered_content.rb +577 -0
  21. data/lib/lutaml/model/lml/portable_json.rb +385 -0
  22. data/lib/lutaml/model/lml/rejected_error.rb +64 -15
  23. data/lib/lutaml/model/lml/round_trip.rb +86 -0
  24. data/lib/lutaml/model/lml/value_declarations.rb +84 -0
  25. data/lib/lutaml/model/lml.rb +61 -0
  26. data/lib/lutaml/model/schema/definitions/attribute.rb +4 -2
  27. data/lib/lutaml/model/schema/registry_generator.rb +1 -1
  28. data/lib/lutaml/model/schema/renderers/member_decls.rb +1 -0
  29. data/lib/lutaml/model/schema/xml_compiler/spec_builder/members.rb +10 -0
  30. data/lib/lutaml/model/sequence.rb +7 -0
  31. data/lib/lutaml/model/version.rb +1 -1
  32. data/lib/lutaml/xml/leptris/native_emission.rb +4 -0
  33. data/lib/lutaml/xml/leptris/plan_serializer.rb +14 -9
  34. data/schema/lml/document.schema.json +179 -0
  35. data/scripts/lml/export_choices.rb +57 -0
  36. data/scripts/lml/export_conformance.rb +23 -0
  37. data/scripts/lml/export_mml.rb +253 -0
  38. data/scripts/lml/export_preservation.rb +421 -0
  39. data/scripts/lml/verify_artifacts.rb +31 -0
  40. data/spec/fixtures/lml_artifacts/model.json +1 -0
  41. data/spec/fixtures/lml_artifacts/valid.json +1 -0
  42. data/spec/fixtures/lml_artifacts/valid.sha256 +1 -0
  43. data/spec/fixtures/lml_conformance/core/index.json +1 -0
  44. data/spec/fixtures/lml_conformance/core/manifest.json +1 -0
  45. data/spec/fixtures/lml_conformance/core/schema.json +1 -0
  46. data/spec/fixtures/lml_conformance/core/schema.yaml +79 -0
  47. data/spec/fixtures/lml_conformance/float_vectors.generator.rb +60 -0
  48. data/spec/fixtures/lml_conformance/float_vectors.json +21550 -0
  49. data/spec/fixtures/lml_conformance/preservation/index.json +1 -0
  50. data/spec/fixtures/lml_conformance/preservation/manifest.json +1 -0
  51. data/spec/fixtures/lml_conformance/preservation/schema.json +1 -0
  52. data/spec/fixtures/lml_conformance/preservation/schema.yaml +319 -0
  53. data/spec/fixtures/lml_conformance/r2_refusals.generator.rb +153 -0
  54. data/spec/fixtures/lml_conformance/r2_refusals.json +1662 -0
  55. data/spec/fixtures/lml_conformance/ruby_portable_interop.generator.rb +40 -0
  56. data/spec/fixtures/lml_conformance/ruby_portable_interop.json +1 -0
  57. data/spec/fixtures/lml_contract/bundle.json +81 -0
  58. data/spec/fixtures/lml_contract/manifest.json +30 -0
  59. data/spec/fixtures/lml_contract/v1_unit.canonical.json +1 -0
  60. data/spec/fixtures/lml_contract/v1_unit.json +1 -0
  61. data/spec/fixtures/lml_contract/v2_node.canonical.json +1 -0
  62. data/spec/fixtures/lml_contract/v2_node.json +32 -0
  63. data/spec/fixtures/lml_mml/inventory.json +1 -0
  64. data/spec/fixtures/lml_mml/manifest.json +1 -0
  65. data/spec/fixtures/lml_mml/oracle.json +1 -0
  66. data/spec/fixtures/lml_mml/v3-mi-mixed.json +1 -0
  67. data/spec/fixtures/lml_mml/v3-mi-mixed.yaml +970 -0
  68. data/spec/fixtures/lml_mml/v4-mi-mixed.json +1 -0
  69. data/spec/fixtures/lml_mml/v4-mi-mixed.yaml +1516 -0
  70. data/spec/fixtures/lml_mml_materialization/replay.rb +37 -0
  71. data/spec/lutaml/model/lml_any_attribute_spec.rb +91 -0
  72. data/spec/lutaml/model/lml_artifact_verifier_spec.rb +86 -0
  73. data/spec/lutaml/model/lml_builtin_types_spec.rb +49 -0
  74. data/spec/lutaml/model/lml_conformance_spec.rb +178 -0
  75. data/spec/lutaml/model/lml_document_spec.rb +279 -0
  76. data/spec/lutaml/model/lml_export_validation_spec.rb +96 -0
  77. data/spec/lutaml/model/lml_exporter_spec.rb +127 -5
  78. data/spec/lutaml/model/lml_graph_exporter_spec.rb +205 -0
  79. data/spec/lutaml/model/lml_importer_spec.rb +290 -0
  80. data/spec/lutaml/model/lml_input_hardening_spec.rb +156 -0
  81. data/spec/lutaml/model/lml_mapping_compiler_spec.rb +256 -0
  82. data/spec/lutaml/model/lml_materialization_spec.rb +138 -0
  83. data/spec/lutaml/model/lml_mml_materialization_spec.rb +54 -0
  84. data/spec/lutaml/model/lml_mml_pilot_spec.rb +150 -0
  85. data/spec/lutaml/model/lml_model_choices_spec.rb +88 -0
  86. data/spec/lutaml/model/lml_ordered_content_spec.rb +243 -0
  87. data/spec/lutaml/model/lml_portable_json_spec.rb +310 -0
  88. data/spec/lutaml/model/lml_preservation_spec.rb +211 -0
  89. data/spec/lutaml/model/lml_review_export_spec.rb +247 -0
  90. data/spec/lutaml/model/lml_review_import_spec.rb +390 -0
  91. data/spec/lutaml/model/lml_review_misc_spec.rb +152 -0
  92. data/spec/lutaml/model/lml_review_round4_spec.rb +200 -0
  93. data/spec/lutaml/model/lml_review_round5_spec.rb +194 -0
  94. data/spec/lutaml/model/lml_ruby_interop_fixture_spec.rb +37 -0
  95. data/spec/lutaml/model/lml_shared_corpus_spec.rb +132 -0
  96. data/spec/lutaml/model/lml_value_declarations_spec.rb +128 -0
  97. data/spec/lutaml/model/schema/class_loader_spec.rb +51 -0
  98. data/spec/lutaml/model/schema/xml_compiler_runtime_spec.rb +20 -0
  99. data/spec/lutaml/model/sequence_spec.rb +48 -0
  100. data/spec/lutaml/xml/cdata_emission_spec.rb +68 -0
  101. data/spec/support/lml_any_attribute_fixtures.rb +26 -0
  102. data/spec/support/lml_conformance.rb +292 -0
  103. data/spec/support/lml_corpus.rb +75 -0
  104. data/spec/support/lml_export_fixtures.rb +190 -0
  105. data/spec/support/lml_graph_fixtures.rb +108 -0
  106. data/spec/support/lml_import_fixtures.rb +52 -0
  107. data/spec/support/lml_mapping_fixtures.rb +170 -0
  108. data/spec/support/lml_materialization_fixtures.rb +53 -0
  109. data/spec/support/lml_model_choices_fixtures.rb +150 -0
  110. data/spec/support/lml_order_fixtures.rb +151 -0
  111. metadata +92 -2
  112. data/lib/lutaml/model/schema/schema_builder/nokogiri.rb +0 -41
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "optparse"
4
+ require_relative "../../lib/lutaml/model/lml/artifact_verifier"
5
+
6
+ if $PROGRAM_NAME == __FILE__
7
+ options = {}
8
+ parser = OptionParser.new do |cli|
9
+ cli.banner = "Usage: verify_artifacts.rb --manifest FILE --expected-sha256 DIGEST"
10
+ cli.on("--manifest FILE") { |value| options[:manifest] = value }
11
+ cli.on("--expected-sha256 DIGEST") { |value| options[:expected_sha256] = value }
12
+ cli.on("--root DIRECTORY") { |value| options[:root] = value }
13
+ end
14
+ begin
15
+ parser.parse!
16
+ raise OptionParser::MissingArgument, "--manifest" unless options[:manifest]
17
+ raise OptionParser::MissingArgument, "--expected-sha256" unless options[:expected_sha256]
18
+
19
+ manifest = JSON.parse(File.read(options[:manifest], encoding: "UTF-8"))
20
+ root = options[:root] || File.dirname(File.expand_path(options[:manifest]))
21
+ verifier = Lutaml::Model::Lml::ArtifactVerifier.new(root: root,
22
+ expected_sha256: options[:expected_sha256])
23
+ verifier.verify(manifest)
24
+ puts JSON.generate("verified" => true, "target" => manifest["target"],
25
+ "files" => manifest["files"].length)
26
+ rescue OptionParser::ParseError, JSON::ParserError, SystemCallError,
27
+ Lutaml::Model::Lml::ArtifactVerifier::Error => e
28
+ warn JSON.generate("verified" => false, "error" => e.message.scrub)
29
+ exit 1
30
+ end
31
+ end
@@ -0,0 +1 @@
1
+ {"capabilities":["json"],"lml_bundle":1,"models":{"Fixture::Record@default":{"attributes":[],"lml":2,"mappings":{},"model":"Fixture::Record","register":"default"}},"roots":["Fixture::Record@default"],"value_types":{}}
@@ -0,0 +1 @@
1
+ {"capabilities":["json"],"corpora":[{"generation":"fixture-1","sha256":"sha256:114304fa714674f948f4dbb8e903424bf9e9a0d44acddc5a6f81e13f6318f612"}],"dependencies":[{"name":"fixture-dependency","revision":"fixture-v1","sha256":"sha256:c670d63b817369af3647eecbe067fb48b4d5ae6e7867dd25f425e1dbe570cb81"}],"files":[{"path":"model.json","sha256":"sha256:dc9cd182d5db91c9e2e3f36c0d114c1fccb980412cf3535e12ab5f1a91fd7ec5"}],"generator_version":"fixture-v1","lml_checksum":"sha256:dc9cd182d5db91c9e2e3f36c0d114c1fccb980412cf3535e12ab5f1a91fd7ec5","manifest":1,"schema_version":2,"target":"ruby"}
@@ -0,0 +1 @@
1
+ sha256:6c8a922b3cf88601400dc07905925157cd9fb85b7ca3e9d682bb672c372b9324
@@ -0,0 +1 @@
1
+ {"cases":[{"comparison":"data","data_profile":"exact-values-decimal-v1","expected_data":{"count":"42","enabled":false,"label":"café & tea"},"expected_error":null,"expected_output":"{\"label\":\"café & tea\",\"count\":42,\"enabled\":false}","format":"json","id":"core-json","input":"{\"label\":\"café & tea\",\"count\":42,\"enabled\":false}","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","model_id":"LmlConformance::Record@default","wire_profile":"ruby-native-v1"},{"comparison":"xml_tree","data_profile":"exact-values-decimal-v1","expected_data":{"count":"42","enabled":false,"label":"café & tea"},"expected_error":null,"expected_output":"<record enabled=\"false\">\n <label>café &amp; tea</label>\n <count>42</count>\n</record>","format":"xml","id":"core-xml-tree","input":"<record enabled=\"false\"><label>café &amp; tea</label><count>42</count></record>","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","model_id":"LmlConformance::Record@default","wire_profile":"ruby-native-v1"},{"comparison":"bytes","data_profile":"exact-values-decimal-v1","expected_data":{"count":"7","enabled":true,"label":"plain"},"expected_error":null,"expected_output":"<record enabled=\"true\">\n <label>plain</label>\n <count>7</count>\n</record>","format":"xml","id":"core-xml-bytes","input":"<record enabled=\"true\"><label>plain</label><count>7</count></record>","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","model_id":"LmlConformance::Record@default","wire_profile":"ruby-native-v1"},{"comparison":"data","data_profile":"exact-values-decimal-v1","expected_data":null,"expected_error":{"format":"json","location":"/input","model_id":"LmlConformance::Record@default","reason":"invalid_document"},"expected_output":null,"format":"json","id":"core-json-invalid","input":"{","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","model_id":"LmlConformance::Record@default","wire_profile":"ruby-native-v1"},{"comparison":"data","data_profile":"exact-values-decimal-v1","expected_data":{"count":"9007199254740993","enabled":false,"label":"beyond binary64"},"expected_error":null,"expected_output":"{\"label\":\"beyond binary64\",\"count\":\"9007199254740993\",\"enabled\":false}","format":"json","id":"core-json-portable-exact","input":"{\"label\":\"beyond binary64\",\"count\":\"9007199254740993\",\"enabled\":false}","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","model_id":"LmlConformance::Record@default","wire_profile":"portable-exact-json-v1"}],"corpus":1,"generation":"core-v2","profiles":{"portable-exact-json-v1":{"required_case_ids":["core-json-portable-exact"]},"ruby-native-v1":{"required_case_ids":["core-json","core-xml-tree","core-xml-bytes","core-json-invalid"]}},"source_revision":"8a8ef040963b7965388b01b58af33af2b0995f91","target_profiles":{"ruby":["ruby-native-v1","portable-exact-json-v1"],"rust":["portable-exact-json-v1"],"ts":["portable-exact-json-v1"]},"xml_canon_profile":"expanded-names-text-v1"}
@@ -0,0 +1 @@
1
+ {"capabilities":["json","xml"],"corpora":[{"generation":"core-v2","sha256":"sha256:fd1de9747a78a71d737a4076ebfb0cf4a561d96dba9156a43afb5a337ebad0d2"}],"dependencies":[{"name":"lutaml-model","revision":"8a8ef040963b7965388b01b58af33af2b0995f91","sha256":"sha256:14c85f76a3cf2ebb18aa3c97186840897bf2147c886818a5c73670d3a6db170a"}],"files":[{"path":"index.json","sha256":"sha256:fd1de9747a78a71d737a4076ebfb0cf4a561d96dba9156a43afb5a337ebad0d2"},{"path":"schema.json","sha256":"sha256:ce5cc1c61e4a97bc71b2683b71e56c5488dbd3f41fdfa2802c01c4c2cd34fa1e"},{"path":"schema.yaml","sha256":"sha256:5c6f2cf9ddb907bd2aaff813711a6ed0d35e0ff1563d5b4f893301f803dac8e0"}],"generator_version":"ruby-core-oracle-v2","lml_checksum":"sha256:a7fac433ca7be94a6a66f6b8d0dab8134747860cf8076dffc4aaa92a24d1cb34","manifest":1,"schema_version":2,"target":"ruby"}
@@ -0,0 +1 @@
1
+ {"capabilities":["json","xml"],"lml_bundle":1,"models":{"LmlConformance::Record@default":{"attributes":[{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"label","required":false,"type":{"kind":"builtin","name":"string"}},{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"count","required":false,"type":{"kind":"builtin","name":"integer"}},{"collection":false,"default":{"present":false},"initialize_empty":false,"name":"enabled","required":false,"type":{"kind":"builtin","name":"boolean"}}],"lml":2,"mappings":{"json":{"rules":[{"key":["label"],"to":"label"},{"key":["count"],"to":"count"},{"key":["enabled"],"to":"enabled"}]},"xml":{"namespace":{"mode":"inherit"},"root":{"element":"record"},"rules":[{"kind":"attribute","name":["enabled"],"namespace":{"mode":"inherit"},"to":"enabled"},{"kind":"element","name":["label"],"namespace":{"mode":"inherit"},"to":"label"},{"kind":"element","name":["count"],"namespace":{"mode":"inherit"},"to":"count"}]}},"model":"LmlConformance::Record","register":"default"}},"provenance":{"source_revision":"8a8ef040963b7965388b01b58af33af2b0995f91"},"roots":["LmlConformance::Record@default"],"value_types":{}}
@@ -0,0 +1,79 @@
1
+ ---
2
+ capabilities:
3
+ - json
4
+ - xml
5
+ lml_bundle: 1
6
+ models:
7
+ LmlConformance::Record@default:
8
+ attributes:
9
+ - collection: false
10
+ default:
11
+ present: false
12
+ initialize_empty: false
13
+ name: label
14
+ required: false
15
+ type:
16
+ kind: builtin
17
+ name: string
18
+ - collection: false
19
+ default:
20
+ present: false
21
+ initialize_empty: false
22
+ name: count
23
+ required: false
24
+ type:
25
+ kind: builtin
26
+ name: integer
27
+ - collection: false
28
+ default:
29
+ present: false
30
+ initialize_empty: false
31
+ name: enabled
32
+ required: false
33
+ type:
34
+ kind: builtin
35
+ name: boolean
36
+ lml: 2
37
+ mappings:
38
+ json:
39
+ rules:
40
+ - key:
41
+ - label
42
+ to: label
43
+ - key:
44
+ - count
45
+ to: count
46
+ - key:
47
+ - enabled
48
+ to: enabled
49
+ xml:
50
+ namespace:
51
+ mode: inherit
52
+ root:
53
+ element: record
54
+ rules:
55
+ - kind: attribute
56
+ name:
57
+ - enabled
58
+ namespace:
59
+ mode: inherit
60
+ to: enabled
61
+ - kind: element
62
+ name:
63
+ - label
64
+ namespace:
65
+ mode: inherit
66
+ to: label
67
+ - kind: element
68
+ name:
69
+ - count
70
+ namespace:
71
+ mode: inherit
72
+ to: count
73
+ model: LmlConformance::Record
74
+ register: default
75
+ provenance:
76
+ source_revision: 8a8ef040963b7965388b01b58af33af2b0995f91
77
+ roots:
78
+ - LmlConformance::Record@default
79
+ value_types: {}
@@ -0,0 +1,60 @@
1
+ # rubocop:disable all
2
+ # Generates float_vectors.json: IEEE-754 doubles with the LML `float` wire
3
+ # string Ruby's Lutaml::Model::Lml::DocumentValidator.float_wire produces.
4
+ # Ruby owns this corpus; the TS and Rust ports must reproduce every wire.
5
+ # ruby -Ilib spec/fixtures/lml_conformance/float_vectors.generator.rb OUT.json
6
+ require "json"
7
+ require "lutaml/model"
8
+ require "lutaml/model/lml"
9
+
10
+ DV = Lutaml::Model::Lml::DocumentValidator
11
+
12
+ def from_bits(bits) = [bits].pack("Q>").unpack1("G")
13
+ def bits_of(float) = [float].pack("G").unpack1("Q>")
14
+
15
+ values = []
16
+ add = ->(f) { values << f if f.finite? }
17
+
18
+ # fixed landmarks
19
+ [0.0, -0.0, 1.0, -1.0, 0.5, 0.1, 0.2, 0.3, 1.5, 100.0, 123456.789,
20
+ 1e14, 1e15, 1e16, 1e17, 1e21, 1e22, 1e100, 1e300, 1e-4, 1e-5, 1e-6, 1e-10, 1e-100,
21
+ 9.999999999999998e14, 9.999999999999999e14, 1234567890123456.0, 1151450203773890.8,
22
+ 123456789012345.6, 9007199254740991.0, 9007199254740992.0, 0.00011, 0.000099999,
23
+ Float::MAX, -Float::MAX, Float::MIN, -Float::MIN, Float::EPSILON,
24
+ 5.0e-324, -5.0e-324, 2.2250738585072009e-308, 2.225073858507201e-308].each(&add)
25
+
26
+ # every notation boundary and its immediate neighbours (bit steps)
27
+ [1e-5, 1e-4, 1e15, 1e16, 1e-323, Float::MIN, Float::MAX, 1.0, 10.0, 1e22].each do |b|
28
+ (-20..20).each { |d| add.(from_bits(bits_of(b) + d)); add.(-from_bits(bits_of(b) + d)) }
29
+ end
30
+
31
+ # smallest/largest subnormals and the subnormal/normal seam
32
+ (1..32).each { |n| add.(from_bits(n)); add.(-from_bits(n)) }
33
+ (-16..16).each { |d| add.(from_bits(0x0010000000000000 + d)) }
34
+
35
+ # every power of ten and of two
36
+ (-323..308).each { |e| add.(Float("1e#{e}")) }
37
+ (-1074..1023).each { |e| add.(2.0**e) }
38
+
39
+ rng = Random.new(1033)
40
+ # [1e15, 1e16): 16 and 17 significant digits (integers, .5 and arbitrary fractions)
41
+ 300.times { add.(1e15 + rng.rand * 9e15) }
42
+ 200.times { add.((1e15 + rng.rand(9e15)).floor.to_f) }
43
+ 200.times { add.((1e15 + rng.rand(9e15)).floor + 0.5) }
44
+ 200.times { add.((1e15 + rng.rand(9e14)).floor + rng.rand(10) / 10.0) }
45
+ # around the small boundary
46
+ 200.times { add.(1e-5 * (0.5 + rng.rand * 20)) }
47
+ 200.times { add.(1e-4 * (0.5 + rng.rand * 20)) }
48
+ # uniformly random bit patterns (all magnitudes, both signs)
49
+ 600.times { add.(from_bits(rng.rand(2**64))) }
50
+
51
+ seen = {}
52
+ out = values.filter_map do |f|
53
+ bits = format("%016x", bits_of(f))
54
+ next if seen[bits]
55
+
56
+ seen[bits] = true
57
+ { "bits" => bits, "wire" => DV.float_wire(f) }
58
+ end
59
+ File.binwrite(ARGV.fetch(0), JSON.pretty_generate(out) + "\n")
60
+ puts out.size