lutaml-model 0.8.166 → 0.8.168

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e26cb512515f146956b2f1f1b601a9fd810ef0fdf606e98963001e28b6fe249
4
- data.tar.gz: 72e5bbd3f54f084abb92c34d63442cb0dee383851a1f4a78580b48bdf3651b8f
3
+ metadata.gz: dccd6b591db573af7a95aedba2d2ee63b0b63c8f7d5dc728e9eea3e3f783a201
4
+ data.tar.gz: 9c305247097d0d3dd7c680022e1890caaa5116aad634f0c2b518fc0b3995deea
5
5
  SHA512:
6
- metadata.gz: 682c8dd4ea109bd97314cc01f32a4ea32f489176603e4a0a115679d2c6cd3f517490da31f72c6df6c5059389f12037827d9933cf35eeb7b8e33eb86cb31d1657
7
- data.tar.gz: 98beef43e550b5cd69d76824a0c3a0a5cd266477aefd6382315ef0fdb06026b8fea0662e7f76b774c5094efe396140305f2b4146d82596c7d3f5b1e8969c92a7
6
+ metadata.gz: c714643359a9bea977fd832fe5893d848fc367f88a064d98f9534091b1bbf1c38876d1398b7ae1d252bc318eee485cb481ab9e350fede9c6fbf1f9da2456c795
7
+ data.tar.gz: 8c8182e6387347352ec8982adbcb3294d714b17c74b72aa28dd8f2ee9f5a17a2eedd3867e40504d63e813a357ff38d2846e58504961115336f9d64e7659498b5
@@ -180,6 +180,16 @@ jobs:
180
180
  needs: benchmark
181
181
  runs-on: ubuntu-latest
182
182
  if: github.event_name == 'push' && github.ref == 'refs/heads/main'
183
+ # The baseline PR step pushes with the job's GITHUB_TOKEN; the
184
+ # workflow default is contents:read, so without this grant the
185
+ # create-pull-request push 403s on every main push (#1128).
186
+ permissions:
187
+ contents: write
188
+ # create-pull-request opens the baseline PR through the API —
189
+ # the git push (contents:write) authenticates, but PR creation
190
+ # needs its own grant ("Resource not accessible by
191
+ # integration").
192
+ pull-requests: write
183
193
  steps:
184
194
  # persist-credentials: false — checkout's persisted Authorization
185
195
  # extraheader collides with create-pull-request's own token on the
data/Gemfile CHANGED
@@ -49,7 +49,7 @@ gem "rexml"
49
49
  # exact-URI attribute rows, nested-attribute capture, wildcard rows,
50
50
  # walk-side ns retention and leniency, :unqualified rows, and the
51
51
  # address-based text attach all ride it.
52
- gem "leptris", ">= 1.9.406.0" # RAW op (leptris#1941): the packet fast path needs PLAN_OP_RAW + row identity
52
+ gem "leptris", ">= 1.9.406.0" # RAW op (leptris#1941) — matches MIN_LEPTRIS_VERSION, the single capability line; the emission lane additionally version-gates namespaced trees to >= 1.9.407.0 (attr ns_prefix deep-copy, leptris#1967/#1968)
53
53
  gem "teptris"
54
54
  gem "yeptris" unless Gem.win_platform?
55
55
  # TODO: revert rng branch to main when lutaml/rng#32 is merged
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lutaml
4
4
  module Model
5
- VERSION = "0.8.166"
5
+ VERSION = "0.8.168"
6
6
  end
7
7
  end
@@ -35,6 +35,7 @@ module Lutaml
35
35
  ORDERED_ROW_KINDS = %i[scalar collection_native collection_cb
36
36
  nested ordered_deferred].freeze
37
37
  DEFERRED_ROW_KINDS = %i[raw ordered_deferred].freeze
38
+ PLANNED_ROW_KINDS = %i[nested ordered_deferred].freeze
38
39
  NESTED_ROW_KINDS = %i[nested ordered_deferred].freeze
39
40
  NS_EMITTABLE_ROW_KINDS = %i[scalar collection nested
40
41
  collection_native
@@ -52,58 +53,123 @@ module Lutaml
52
53
  :lutaml_model_leptris_native_emission_op_buffer_base
53
54
 
54
55
  class << self
55
- # The RAW-splice capability rides engine 1.9.406.0: the gem
56
- # maps PLAN_OP_RAW and the :raw row-op kind (both ship in
57
- # the same release). Probing the public constant tracks the
58
- # LOADED gem — a bundle pinned to an older engine (the
59
- # metanorma consumer matrix resolves 1.9.405.0) takes the
60
- # DOM lane instead of splicing :raw ops the engine cannot
61
- # parse (which emitted empty fragments and died on the
62
- # round-trip parse).
63
- def raw_op_supported?(ffi = ::Leptris::XML::FFI)
64
- ffi.const_defined?(:PLAN_OP_RAW)
65
- end
66
-
67
56
  # plan: the compiled plan; instance: the emitting instance.
68
57
  # A nil instance runs the static checks only.
69
58
  def compatible?(plan, instance = nil, register = nil)
70
59
  return false if plan.nil?
71
- return false unless raw_op_supported?
72
- return false unless ordered_ns_emittable?(plan)
60
+ return false if namespaced_tree?(plan[:tree]) &&
61
+ !engine_ns_prefix_safe?
62
+ return false unless ordered_ns_emittable?(plan, instance)
73
63
  return false if plan[:ordered] && instance.is_a?(::Lutaml::Model::Serialize) &&
74
64
  instance.element_order.nil?
75
65
 
76
66
  subtree_gate_ok?(plan, instance, register)
77
67
  end
78
68
 
69
+ # The engine's attr-row ns_prefix deep-copy fix rides
70
+ # 1.9.407.0 (leptris#1967, fixed by leptris#1968): earlier
71
+ # engines keep the binding's freed FFI anchor pointer in the
72
+ # built plan and read freed heap bytes at serialize time —
73
+ # garbage prefixes (CT_RPr:val) and empty output (the
74
+ # lutaml-model#1126 uniword signatures) on every EXACT-ns
75
+ # row the ops lane emits. A pure bugfix release ships no
76
+ # capability constant, so this is a version-floor gate like
77
+ # MIN_LEPTRIS_VERSION — the floor is the capability line.
78
+ # Namespace-less trees never consult the descriptor's ns
79
+ # rows and stay on the lane regardless.
80
+ def engine_ns_prefix_safe?(version = ::Leptris::VERSION)
81
+ Gem::Version.new(version.to_s) >=
82
+ Gem::Version.new("1.9.407.0")
83
+ rescue ArgumentError
84
+ false
85
+ end
86
+
87
+ # Whether any tree in the emission graph carries an EXACT
88
+ # namespace Hash (tree, attribute rows, or child rows,
89
+ # recursively through nested plans) — the rows whose
90
+ # ns_prefix the pre-1.9.407 engine fails to retain.
91
+ def namespaced_tree?(tree)
92
+ return false unless tree.is_a?(::Hash)
93
+
94
+ return true if tree[:ns].is_a?(::Hash)
95
+ return true if (tree[:attributes] || []).any? do |a|
96
+ a[:ns].is_a?(::Hash)
97
+ end
98
+
99
+ (tree[:children] || []).any? do |r|
100
+ next true if r[:ns].is_a?(::Hash)
101
+ next false unless r[:plan] &&
102
+ PLANNED_ROW_KINDS.include?(r[:kind])
103
+
104
+ namespaced_tree?(r[:plan])
105
+ end
106
+ end
107
+
108
+ # Prefixed spelling is only faithful when the ROOT instance
109
+ # preserves a prefixed source: the DOM lane inherits the
110
+ # root's prefix spelling down the tree (nested children
111
+ # spell through the hoisted prefix), so one root-level fact
112
+ # governs every EXACT row in the emission graph. Constructed
113
+ # and default-parsed roots pin the default-xmlns form,
114
+ # which the ops lane cannot express (uniword bold/custprops
115
+ # format regressions when admitted).
116
+ def prefixed_source?(instance)
117
+ instance.is_a?(::Lutaml::Model::Serialize) &&
118
+ !instance.xml_namespace_prefix.to_s.empty?
119
+ end
120
+
79
121
  # The emission graph is a DAG: Descriptor.flatten_plan
80
122
  # memoizes child plans by object identity, so a shared
81
123
  # subtree keeps ONE plan slot and every parent references
82
124
  # it. The identity map mirrors that numbering exactly —
83
125
  # op plan_index values are these absolute slots.
84
126
  def emission_graph_for(plan, register)
127
+ slot_map(emission_tree_for(plan, register))
128
+ end
129
+
130
+ # THE slot numbering (leptris#1966 SSOT): every consumer
131
+ # numbering the tree — the emission graph, the flat layout,
132
+ # the ruby gem's flatten_plan — must derive from THIS walk:
133
+ # identity-memoized pre-order over planned rows. Shared
134
+ # subtrees (memoized plans reachable from many parents —
135
+ # the theme docx's clrScheme/fontScheme shapes) get ONE
136
+ # slot at first encounter; occurrence-arithmetic (counting
137
+ # a shared subtree's size at every reference) drifts 70/75
138
+ # nodes on that document and handed the engine op streams
139
+ # whose plan_index pointed at the wrong plan.
140
+ def slot_map(tree)
85
141
  map = {}.compare_by_identity
86
142
  counter = [0]
87
- walk = lambda do |tree|
88
- return map[tree] if map.key?(tree)
143
+ walk = lambda do |t|
144
+ return map[t] if map.key?(t)
89
145
 
90
146
  idx = counter[0]
91
147
  counter[0] += 1
92
- map[tree] = idx
93
- (tree[:children] || []).each do |r|
94
- walk.call(r[:plan]) if r[:kind] == :nested && r[:plan]
148
+ map[t] = idx
149
+ (t[:children] || []).each do |r|
150
+ walk.call(r[:plan]) if r[:plan] &&
151
+ PLANNED_ROW_KINDS.include?(r[:kind])
95
152
  end
96
153
  idx
97
154
  end
98
- walk.call(emission_tree_for(plan, register))
155
+ walk.call(tree)
99
156
  map
100
157
  end
101
158
 
102
159
  # A plan whose tree defers subtrees verbatim (:raw rows —
103
- # ordered children, e.g. uniword's document → body).
160
+ # ordered children, e.g. uniword's document → body), at any
161
+ # depth. The DEFERRED rows of NESTED descendants defer too:
162
+ # an unordered root whose grandchildren defer (uniword
163
+ # clrScheme → color → ordered srgbClr) must ride the
164
+ # emission descriptor + identity graph — ops against the
165
+ # parse descriptor reference child plans the compiled tree
166
+ # never materialized (:raw rows carry no plan).
104
167
  def deferred_rows?(tree)
105
168
  (tree[:children] || []).any? do |r|
106
- DEFERRED_ROW_KINDS.include?(r[:kind])
169
+ next true if DEFERRED_ROW_KINDS.include?(r[:kind])
170
+ next false unless r[:kind] == :nested && r[:plan]
171
+
172
+ deferred_rows?(r[:plan])
107
173
  end
108
174
  end
109
175
 
@@ -131,7 +197,7 @@ module Lutaml
131
197
 
132
198
  return true unless instance.is_a?(::Lutaml::Model::Serialize)
133
199
 
134
- plan[:rows].each do |(rule, attr, kind, _sp, delegate, type)|
200
+ plan[:rows].each do |(rule, attr, kind, _sp, delegate, _type)|
135
201
  next unless rule.name
136
202
  next if kind == :child_deferred
137
203
  next unless NESTED_ROW_KINDS.include?(kind)
@@ -140,13 +206,11 @@ module Lutaml
140
206
  Array(value).each do |item|
141
207
  next unless item
142
208
 
143
- child_type = begin
144
- type || attr.type(register)
145
- rescue StandardError
146
- nil
147
- end
148
- child_plan = child_type.is_a?(Class) &&
149
- PlanCompiler.compile(child_type, register)
209
+ # leptris#1966: the emit compiles the ITEM CLASS's
210
+ # plan (nested_plans[[item.class, name]]) — the gate
211
+ # must gate exactly what emit emits. Unknown classes
212
+ # refuse here: the doc takes the DOM lane.
213
+ child_plan = PlanCompiler.compile(item.class, register)
150
214
  return false unless child_plan
151
215
  return false unless subtree_gate_ok?(child_plan, item,
152
216
  register)
@@ -182,26 +246,44 @@ module Lutaml
182
246
  # emits text; wildcards bail in subtree_gate_ok?), so the
183
247
  # check covers the tree ns, attribute rows, and the
184
248
  # named-element rows only.
185
- def ordered_ns_emittable?(plan)
249
+ def ordered_ns_emittable?(plan, instance_or_flag = nil)
250
+ flag = if instance_or_flag.is_a?(::Lutaml::Model::Serialize)
251
+ prefixed_source?(instance_or_flag)
252
+ else
253
+ instance_or_flag
254
+ end
186
255
  tree = plan[:tree]
187
- return false unless ns_emittable?(tree[:ns])
256
+ return false unless ns_emittable?(tree[:ns], flag)
188
257
  return false if (tree[:attributes] || []).any? do |a|
189
- !ns_emittable?(a[:ns])
258
+ !ns_emittable?(a[:ns], flag)
190
259
  end
191
260
 
192
261
  (tree[:children] || []).all? do |row|
193
262
  next true unless NS_EMITTABLE_ROW_KINDS.include?(row[:kind])
194
263
 
195
- ns_emittable?(row[:ns])
264
+ ns_emittable?(row[:ns], flag)
196
265
  end
197
266
  end
198
267
 
199
- # nil (:none/:unqualified — unwritten) and {exact:, prefix:}
200
- # spell; :any and :none-symbol bail to the DOM lane.
201
- def ns_emittable?(ns_form)
202
- ns_form.nil? || ns_form == :unqualified ||
203
- (ns_form.is_a?(Hash) && ns_form[:prefix] &&
204
- !ns_form[:prefix].empty?)
268
+ # Only two shapes ride the ops lane: nil (:none) and
269
+ # :unqualified — the unwritten local spelling, nothing to
270
+ # declare — and EXACT Hash forms, ONLY under a
271
+ # prefixed-preserved root. The engine's plan serializer
272
+ # spells prefix:local for every EXACT row and cannot
273
+ # express the default-xmlns form (a prefix-less EXACT row
274
+ # emits a bare name with NO declaration, changing element
275
+ # identity), so admitting constructed or default-parsed
276
+ # instances flipped the pinned output format (uniword
277
+ # bold `<b xmlns=...>` and custprops `<property>`
278
+ # regressions). A prefixed-parsed root pins the prefixed
279
+ # form itself — Priority 1 format preservation — and the
280
+ # ops spelling matches it, inherited down the tree.
281
+ def ns_emittable?(ns_form, prefixed_source = nil)
282
+ return true if ns_form.nil? || ns_form == :unqualified
283
+ return false unless ns_form.is_a?(Hash) && ns_form[:prefix] &&
284
+ !ns_form[:prefix].empty?
285
+
286
+ prefixed_source ? true : false
205
287
  end
206
288
 
207
289
  # len is the logical length of the buffer: slots [base, len) hold
@@ -215,6 +297,7 @@ module Lutaml
215
297
  buf = (Thread.current[OP_BUFFER_KEY] ||= [])
216
298
  base = (Thread.current[OP_BUFFER_BASE_KEY] ||= 0)
217
299
  len = base
300
+ result = nil
218
301
  begin
219
302
  op_slot(buf, len)
220
303
  buf[len][:kind] = :element
@@ -230,20 +313,31 @@ module Lutaml
230
313
  emit_element(buf, len + 1, instance, plan, register,
231
314
  root_index, graph)
232
315
  end
233
- op_slot(buf, len)
234
- buf[len][:kind] = :end
235
- len += 1
236
- d = if emission_lane?(plan, instance)
237
- emission_descriptor_for(plan, register)
238
- else
239
- plan[:descriptor]
240
- end
241
- compact = d.serialize(d.build_result(buf[base, len - base]))
242
- ::Leptris::XML.parse(compact).to_xml(indent: 2, no_decl: true)
316
+ # A nil walk is the bail signal: a valued cycle-point or
317
+ # type-only row the ops lane cannot spell (#1130).
318
+ # Reset the buffer tail and hand the instance back to
319
+ # the caller's DOM-lane fallback. The ensure's trim uses
320
+ # the last known-good length.
321
+ if len.nil?
322
+ len = base
323
+ else
324
+ op_slot(buf, len)
325
+ buf[len][:kind] = :end
326
+ len += 1
327
+ d = if emission_lane?(plan, instance)
328
+ emission_descriptor_for(plan, register)
329
+ else
330
+ plan[:descriptor]
331
+ end
332
+ compact = d.serialize(d.build_result(buf[base, len - base]))
333
+ result = ::Leptris::XML.parse(compact).to_xml(indent: 2,
334
+ no_decl: true)
335
+ end
243
336
  ensure
244
337
  buf.slice!(len..) if buf.size > len
245
338
  Thread.current[OP_BUFFER_BASE_KEY] = base
246
339
  end
340
+ result
247
341
  end
248
342
 
249
343
  # The emission graph is needed when the plan replays an
@@ -276,7 +370,20 @@ module Lutaml
276
370
  # materialize without a register).
277
371
  return build.call if register.nil?
278
372
 
279
- plan[:emission_tree] ||= build.call
373
+ # leptris#1966: a memoized tree whose planned-children
374
+ # count no longer matches the plan's rows is STALE — the
375
+ # first build ran while the plan's rows were still
376
+ # filling. Rebuild and invalidate the memos derived from
377
+ # the tree.
378
+ cached = plan[:emission_tree]
379
+ if cached && (cached[:children] || []).length == plan[:rows].length
380
+ return cached
381
+ end
382
+
383
+ plan[:emission_tree] = build.call
384
+ plan[:emission_descriptor] = nil
385
+ plan[:flat_layout_emission] = nil
386
+ plan[:emission_tree]
280
387
  end
281
388
 
282
389
  def emission_descriptor_for(plan, register)
@@ -402,7 +509,7 @@ module Lutaml
402
509
  end
403
510
  next unless entry
404
511
 
405
- _rule, attr, kind, _spelling, delegate, _row_ns,
512
+ rule, attr, kind, _spelling, delegate, _row_ns,
406
513
  row_index = entry
407
514
  value = value_of(instance, attr, delegate)
408
515
  case kind
@@ -433,7 +540,7 @@ module Lutaml
433
540
  tree = emission_tree_for(child_plan, register)
434
541
  graph[tree]
435
542
  else
436
- flat_layout_for(plan, register)[row_index]&.last
543
+ flat_layout_for(plan, instance, register)[row_index]&.last
437
544
  end
438
545
  next unless child_index
439
546
 
@@ -449,9 +556,36 @@ module Lutaml
449
556
  emit_element(buf, len, item, child_plan, register,
450
557
  child_index, graph)
451
558
  end
559
+ return nil if len.nil?
560
+
452
561
  op_slot(buf, len)
453
562
  buf[len][:kind] = :end
454
563
  len += 1
564
+ when :child_deferred
565
+ # Valued cycle-point rows splice the child's own
566
+ # serialization verbatim under the SAME name-match
567
+ # guard as the unordered lane. Without this case
568
+ # the ordered replay silently dropped the subtree
569
+ # (the <b:Author/> empty-shell loss,
570
+ # lutaml-model#1130: Author's self-referential row
571
+ # is a cycle point INSIDE an ordered plan).
572
+ Array(value).each do |item|
573
+ next unless item
574
+
575
+ root = item.class.mappings_for(:xml, register)
576
+ &.root_element
577
+ return nil if root.nil? || root.to_s != rule.name.to_s
578
+
579
+ fragment = serialize_fragment(item, register)
580
+ return nil if fragment.nil?
581
+ next if fragment.empty?
582
+
583
+ op_slot(buf, len)
584
+ buf[len][:kind] = :raw
585
+ buf[len][:plan_index] = my_index
586
+ buf[len][:value] = fragment
587
+ len += 1
588
+ end
455
589
  when :scalar
456
590
  len = scalar_op(buf, len, my_index, row_index, attr,
457
591
  value, register)
@@ -499,7 +633,7 @@ module Lutaml
499
633
  def emit_element(buf, len, instance, plan, register, plan_index,
500
634
  graph = nil)
501
635
  my_index = plan_index
502
- layout = flat_layout_for(plan, register)
636
+ layout = flat_layout_for(plan, instance, register)
503
637
 
504
638
  len = emit_attributes(buf, len, instance, plan, my_index, register)
505
639
 
@@ -531,12 +665,24 @@ module Lutaml
531
665
  # the child model through its own best lane (the plan
532
666
  # serializer — native or DOM) and splices the fragment
533
667
  # verbatim through the RAW op; the empty value emits
534
- # nothing (the DOM lane's rule).
668
+ # nothing (the DOM lane's rule). The splice serves
669
+ # only children whose own root element IS the row's
670
+ # wire name — type-only models and role wrappers
671
+ # (b:Performer wrapping an Author-typed value) need
672
+ # the parent's row-name wrapping, which only the
673
+ # interpretive writer performs — so anything else
674
+ # bails the lane (the DOM ordered lane bails on
675
+ # valued cycle points identically).
535
676
  Array(value).each do |item|
536
677
  next unless item
537
678
 
679
+ root = item.class.mappings_for(:xml, register)
680
+ &.root_element
681
+ return nil if root.nil? || root.to_s != rule.name.to_s
682
+
538
683
  fragment = serialize_fragment(item, register)
539
- next if fragment.nil? || fragment.empty?
684
+ return nil if fragment.nil?
685
+ next if fragment.empty?
540
686
 
541
687
  op_slot(buf, len)
542
688
  buf[len][:kind] = :raw
@@ -585,6 +731,8 @@ module Lutaml
585
731
  emit_element(buf, len, item, child_plan,
586
732
  register, child_index, graph)
587
733
  end
734
+ return nil if len.nil?
735
+
588
736
  op_slot(buf, len)
589
737
  buf[len][:kind] = :end
590
738
  len += 1
@@ -611,8 +759,15 @@ module Lutaml
611
759
  # {nested row_index => [child tree, relative flat index]} —
612
760
  # children of this plan occupy slots my_index+1 .. in row
613
761
  # order, each nested row's subtree sized once.
614
- def flat_layout_for(plan, register = nil)
615
- if plan[:ordered] || deferred_rows?(plan[:tree])
762
+ # leptris#1966 SSOT: the layout world MUST be the same
763
+ # world the ops' descriptor comes from — emission_lane?
764
+ # picks `d` in emit, so it picks the layout here too. The
765
+ # old plan-only predicate let an ordered plan with a
766
+ # built (element_order-less) instance number ops against
767
+ # the EMISSION tree while build_result ran on the PARSE
768
+ # descriptor (75 vs 93 slots — the theme-docx -5).
769
+ def flat_layout_for(plan, instance = nil, register = nil)
770
+ if instance && emission_lane?(plan, instance)
616
771
  # Never memoize a nil-register build: child types can
617
772
  # only materialize with a register (an early nil-register
618
773
  # call would cache an EMPTY layout and every later
@@ -631,21 +786,29 @@ module Lutaml
631
786
 
632
787
  def build_flat_layout(tree)
633
788
 
789
+ slots = slot_map(tree)
634
790
  layout = {}
635
- rel = 1
636
791
  (tree[:children] || []).each_with_index do |row, i|
637
- next unless row[:kind] == :nested && row[:plan]
792
+ next unless row[:plan] &&
793
+ PLANNED_ROW_KINDS.include?(row[:kind])
638
794
 
639
- layout[i] = [row[:plan], rel]
640
- rel += subtree_size(row[:plan])
795
+ layout[i] = [row[:plan], slots[row[:plan]]]
641
796
  end
642
797
  layout
643
798
 
644
799
  end
645
800
 
646
801
  def subtree_size(tree)
802
+ # Mirror flatten_plan's allocation: every planned row kind
803
+ # costs its full subtree (:nested AND :ordered_deferred —
804
+ # counting deferred children as 1 shifted every later slot
805
+ # after the first deferred subtree, leptris#1966).
647
806
  1 + (tree[:children] || []).sum do |row|
648
- row[:kind] == :nested && row[:plan] ? subtree_size(row[:plan]) : 0
807
+ if row[:plan] && PLANNED_ROW_KINDS.include?(row[:kind])
808
+ subtree_size(row[:plan])
809
+ else
810
+ 0
811
+ end
649
812
  end
650
813
  end
651
814
 
@@ -669,6 +832,10 @@ module Lutaml
669
832
  attr_rows.each do |rule, attr, _sp, delegate|
670
833
  value = value_of(instance, attr, delegate)
671
834
  next if value.nil?
835
+ # The DOM lane's write_attribute contract: render_default:
836
+ # false suppresses an attribute whose value is still the
837
+ # default (a parse that omitted it), derived rules excepted.
838
+ next unless rule.render?(value, instance)
672
839
 
673
840
  name = rule.name.to_s
674
841
  row_index = row_indices[name]
@@ -697,9 +864,11 @@ module Lutaml
697
864
  entry = by_name[name]
698
865
  next unless entry
699
866
 
700
- _rule, attr, delegate = entry
867
+ rule, attr, delegate = entry
701
868
  value = value_of(instance, attr, delegate)
702
869
  next if value.nil?
870
+ # Same render_default contract as the plain path.
871
+ next unless rule.render?(value, instance)
703
872
 
704
873
  row_index = row_indices[name]
705
874
  next unless row_index
@@ -343,15 +343,6 @@ module Lutaml
343
343
  attributes: plan_attrs, children: rows }
344
344
  tree[:ns] = model_ns if model_ns
345
345
  tree[:flags] = flags unless flags.empty?
346
- begin
347
- # Lazy: the Opal boot loads this file, and leptris is a
348
- # native gem there — the require only belongs on the
349
- # engines-enabled path.
350
- require "leptris/xml/descriptor"
351
- descriptor = ::Leptris::XML::Descriptor.build(**tree)
352
- rescue StandardError
353
- return nil
354
- end
355
346
 
356
347
  return opt_out!(:attr_ns_claim_conflict) if attr_local_claims
357
348
  .any? { |_, c| c[:ns].positive? && c[:plain].positive? }
@@ -379,6 +370,23 @@ module Lutaml
379
370
  type_tag: wildcard_tag }
380
371
  end
381
372
 
373
+ # leptris#1966: the descriptor freezes the tree's slot
374
+ # table — it must see the tree FINAL. The wildcard
375
+ # catch-all above used to append to `rows` AFTER this
376
+ # build, so every slot past the wildcard shifted one and
377
+ # the ops lane wrote children into leaf slots (status=-5
378
+ # on the theme docx). The tree is complete here; freeze
379
+ # now.
380
+ begin
381
+ # Lazy: the Opal boot loads this file, and leptris is a
382
+ # native gem there — the require only belongs on the
383
+ # engines-enabled path.
384
+ require "leptris/xml/descriptor"
385
+ descriptor = ::Leptris::XML::Descriptor.build(**tree)
386
+ rescue StandardError
387
+ return nil
388
+ end
389
+
382
390
  { descriptor: descriptor, tree: tree, rows: compiled,
383
391
  attr_rows: attr_rows, mapping: mapping,
384
392
  row_tags: row_tags, namespaced: namespaced,
@@ -16,10 +16,14 @@ module Lutaml
16
16
  # form (#1560, 1.9.323), build_result with the address-based
17
17
  # text attach (#408, 1.9.334/1.9.336), and the plan-value
18
18
  # attributes batch face (PlanValue#attributes_snapshot,
19
- # leptris-ruby#447). Bundles resolving an older gem keep the
20
- # interpretive path — PlanCompiler.compile answers nil — the
21
- # opt-out protocol.
22
- MIN_LEPTRIS_VERSION = "1.9.366.2"
19
+ # leptris-ruby#447), and — the binding addition — the RAW op +
20
+ # emission row identity the ordered/deferred splice rides
21
+ # (leptris#1941, 1.9.406). Bundles resolving an older gem keep
22
+ # the interpretive path — PlanCompiler.compile answers nil —
23
+ # the opt-out protocol; a bundle pinned below the floor (e.g.
24
+ # the metanorma consumer matrix at 1.9.405.0) never sees the
25
+ # ops lane, so it cannot splice ops the engine cannot parse.
26
+ MIN_LEPTRIS_VERSION = "1.9.406.0"
23
27
 
24
28
  # Memoized: the compiler consults this on every cache hit (per
25
29
  # child row per node), and the comparison minted a Gem::Version
@@ -322,6 +322,7 @@ module Lutaml
322
322
  mixed_content_option, xml_mapping,
323
323
  instance_is_serialize)
324
324
  set_schema_location(instance, doc, xml_mapping, effective_register)
325
+ set_root_namespaces(instance, doc)
325
326
 
326
327
  defaults_used = []
327
328
 
@@ -620,6 +621,27 @@ instance_is_serialize = nil)
620
621
  instance.raw_schema_location = schema_location.value
621
622
  end
622
623
 
624
+ # Retain the document element's own xmlns declarations on the
625
+ # instance (#1131): prefix → URI, with the default xmlns under
626
+ # the nil key. Qualified QNames (xs:element/@ref, xsi:type,
627
+ # identity-constraint xpath) resolve exactly against the
628
+ # prefixes the document actually declared — the declaration
629
+ # plan's registry is URI-keyed and planner-derived, so it
630
+ # collapses documents that bind several prefixes to one URI.
631
+ def set_root_namespaces(instance, doc)
632
+ return unless instance.is_a?(Lutaml::Model::Serialize)
633
+
634
+ root = doc.is_a?(::Lutaml::Xml::Document) ? doc.root : doc
635
+ own = root&.own_namespaces
636
+ return if own.nil? || own.empty?
637
+
638
+ declarations = {}
639
+ own.each do |prefix, ns_data|
640
+ declarations[prefix] = ns_data.uri
641
+ end
642
+ instance.xmlns_declarations = declarations.freeze
643
+ end
644
+
623
645
  def apply_processing_instruction_deserialization(doc, instance, xml_mapping,
624
646
  _effective_register)
625
647
  pi_mappings = xml_mapping.processing_instruction_mappings
@@ -24,6 +24,13 @@ module Lutaml
24
24
  # Released after plan is built to allow GC of the DOM tree.
25
25
  attr_accessor :pending_plan_root_element
26
26
 
27
+ # The parsed document element's own xmlns declarations, keyed by
28
+ # prefix (the default xmlns sits under the nil key). Captured at
29
+ # deserialization so qualified QNames — xs:element/@ref,
30
+ # xsi:type, identity-constraint xpath — resolve exactly against
31
+ # the prefixes the document actually declared (#1131).
32
+ attr_accessor :xmlns_declarations
33
+
27
34
  # Clear all internal XML parse state on this instance.
28
35
  #
29
36
  # Call before re-serializing a previously-parsed instance when the
@@ -202,6 +209,7 @@ module Lutaml
202
209
  # Extend INTERNAL_ATTRIBUTES with XML-specific ones
203
210
  def pretty_print_instance_variables
204
211
  xml_internals = %i[@import_declaration_plan @pending_plan_root_element
212
+ @xmlns_declarations
205
213
  @__xml_namespace_prefix
206
214
  @__xml_ns_prefixes @__xml_original_namespace_uri
207
215
  @xml_declaration @raw_schema_location]
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # leptris#1966 root cause: the emission graph numbered :nested rows
4
+ # only, but emission_rows_for materializes :ordered_deferred rows
5
+ # WITH child :plan trees (the deferred subtree is fully materialized
6
+ # — the recursive gate guarantees it). A valued deferred row under
7
+ # an ordered parent (uniword's theme/styles shapes) then looked up
8
+ # graph[tree] at emit time, got nil, and the element op carried
9
+ # plan_index=nil — the engine rejected the stream with -5. The
10
+ # graph must number every row kind that carries a plan.
11
+ RSpec.describe Lutaml::Xml::Leptris::NativeEmission,
12
+ ".emission_graph_for numbers deferred subtrees" do
13
+ let(:child_tree) do
14
+ { name: "p", children: [{ name: "t", kind: :scalar }] }
15
+ end
16
+ let(:tree) do
17
+ { name: "root", children: [
18
+ { name: "body", kind: :ordered_deferred, plan: child_tree },
19
+ ] }
20
+ end
21
+ let(:fake_row) do
22
+ rule = Struct.new(:name).new("body")
23
+ [rule, nil, :scalar]
24
+ end
25
+ let(:plan) do
26
+ { ordered: true, tree: tree, emission_tree: tree, rows: [fake_row] }
27
+ end
28
+
29
+ it "assigns the deferred subtree a graph slot" do
30
+ graph = described_class.emission_graph_for(plan, :register)
31
+ expect(graph[tree]).to eq(0)
32
+ expect(graph[child_tree]).to eq(1)
33
+ end
34
+ end
@@ -0,0 +1,152 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The uniword clrScheme class of shape: an UNORDERED root whose
4
+ # grandchildren defer (each color choice carries an ORDERED srgbClr
5
+ # child beside a shared sysClr nested child). Two ways this broke the
6
+ # native emission lane before the graph-numbering fix:
7
+ #
8
+ # - ops against the parse descriptor referenced child plans the
9
+ # compiled tree never materialized (:raw rows carry no plan) — the
10
+ # engine rejected the program (plan result build, INVALID_ARG -5);
11
+ # - the per-parent relative-offset layout crossed depth boundaries,
12
+ # sending children of later rows onto earlier rows' plan slots
13
+ # (accent2's slot carrying dk1's sysClr).
14
+ #
15
+ # The shared SysColor plan (one compiled tree under every color row —
16
+ # the [class, register] compile cache) pins the identity-deduped
17
+ # numbering both halves depend on.
18
+
19
+ require "lutaml/model"
20
+ require "lutaml/xml/leptris"
21
+
22
+ RSpec.describe "native emission with nested deferral and shared plans" do
23
+ let(:theme_ns) do
24
+ Class.new(Lutaml::Xml::Namespace) do
25
+ uri "http://example.com/theme"
26
+ prefix_default "a"
27
+ end
28
+ end
29
+
30
+ let(:sys_color_class) do
31
+ ns = theme_ns
32
+ klass = Class.new(Lutaml::Model::Serializable) do
33
+ attribute :val, :string
34
+ attribute :last_clr, :string
35
+
36
+ xml do
37
+ namespace ns
38
+ element "sysClr"
39
+ map_attribute "val", to: :val
40
+ map_attribute "lastClr", to: :last_clr
41
+ end
42
+ end
43
+ stub_const("ClrScheme::SysColor", klass)
44
+ klass
45
+ end
46
+
47
+ let(:srgb_color_class) do
48
+ ns = theme_ns
49
+ sys = sys_color_class
50
+ klass = Class.new(Lutaml::Model::Serializable) do
51
+ attribute :val, :string
52
+ attribute :sys, sys
53
+
54
+ xml do
55
+ namespace ns
56
+ ordered
57
+ element "srgbClr"
58
+ map_attribute "val", to: :val
59
+ map_element "sysClr", to: :sys
60
+ end
61
+ end
62
+ stub_const("ClrScheme::SrgbColor", klass)
63
+ klass
64
+ end
65
+
66
+ let(:color_class) do
67
+ ns = theme_ns
68
+ srgb = srgb_color_class
69
+ sys = sys_color_class
70
+ klass = Class.new(Lutaml::Model::Serializable) do
71
+ attribute :srgb, srgb
72
+ attribute :sys, sys
73
+
74
+ xml do
75
+ namespace ns
76
+ element "color"
77
+ map_element "srgbClr", to: :srgb
78
+ map_element "sysClr", to: :sys
79
+ end
80
+ end
81
+ stub_const("ClrScheme::Color", klass)
82
+ klass
83
+ end
84
+
85
+ let(:scheme_class) do
86
+ ns = theme_ns
87
+ color = color_class
88
+ klass = Class.new(Lutaml::Model::Serializable) do
89
+ attribute :name, :string
90
+ attribute :colors, color, collection: true
91
+
92
+ xml do
93
+ namespace ns
94
+ element "clrScheme"
95
+ map_attribute "name", to: :name
96
+ map_element "color", to: :colors
97
+ end
98
+ end
99
+ stub_const("ClrScheme::Scheme", klass)
100
+ klass
101
+ end
102
+
103
+ let(:source) do
104
+ colors = %w[dk1 lt1 dk2 lt2 accent1 accent2 accent3 accent4 accent5
105
+ accent6 hlink folHlink].each_with_index.map do |_name, i|
106
+ if i.even?
107
+ %(<a:color><a:srgbClr val="C#{i}"/></a:color>)
108
+ else
109
+ %(<a:color><a:sysClr val="windowText" lastClr="00000#{i}"/></a:color>)
110
+ end
111
+ end.join
112
+
113
+ <<~XML
114
+ <a:clrScheme xmlns:a="http://example.com/theme" name="Office">
115
+ #{colors}
116
+ </a:clrScheme>
117
+ XML
118
+ end
119
+
120
+ let(:register) { Lutaml::Model::Config.default_register }
121
+
122
+ around do |example|
123
+ Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
124
+ end
125
+
126
+ it "emits parsed unordered schemes with deferred grandchildren" do
127
+ instance = scheme_class.from_xml(source)
128
+ expect(Lutaml::Xml::Leptris::NativeEmission.compatible?(
129
+ Lutaml::Xml::Leptris::PlanCompiler.compile(scheme_class,
130
+ register),
131
+ instance,
132
+ register,
133
+ )).to be(true)
134
+ xml = instance.to_xml
135
+ expect(xml).to include('val="C0"')
136
+ expect(xml).to include('val="windowText"')
137
+ expect(xml.scan("<a:color>").size).to eq(12)
138
+ end
139
+
140
+ it "round-trips every color entry through the emission" do
141
+ instance = scheme_class.from_xml(source)
142
+ restored = scheme_class.from_xml(instance.to_xml)
143
+ expect(restored.name).to eq("Office")
144
+ expect(restored.colors.size).to eq(12)
145
+ expect(restored.colors[0].srgb.val).to eq("C0")
146
+ expect(restored.colors[0].srgb.sys.nil?).to be(true)
147
+ expect(restored.colors[1].sys.val).to eq("windowText")
148
+ expect(restored.colors[1].sys.last_clr).to eq("000001")
149
+ expect(restored.colors[10].srgb.val).to eq("C10")
150
+ expect(restored.colors[11].sys.last_clr).to eq("0000011")
151
+ end
152
+ end
@@ -1,11 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # leptris#1941: namespaced trees must emit through the native ops
4
- # lane byte-identically to the DOM lane. The engine's ops builder
5
- # copies each row's ns binding onto the built values and the plan
6
- # serializer collects (prefix, uri) declarations from the result
7
- # tree itself — so the lane's namespace-less restriction was a
8
- # Ruby-side gate, not an engine limit.
3
+ # The engine's ops lane spells prefix:local for every EXACT row and
4
+ # cannot express the default-xmlns form — so namespaced trees ride
5
+ # the lane only under a prefixed-preserved root (Priority 1 format
6
+ # preservation; the DOM lane inherits the root prefix down the
7
+ # tree). Constructed and default-parsed roots pin the default-xmlns
8
+ # form and MUST take the DOM lane (uniword bold/custprops format
9
+ # regressions when the lane admitted them).
9
10
 
10
11
  require "lutaml/model"
11
12
  require "lutaml/xml/leptris"
@@ -40,17 +41,29 @@ RSpec.describe Lutaml::Xml::Leptris::NativeEmission do
40
41
  end
41
42
  end
42
43
 
43
- let(:instance) { model_class.new(id: "7", value: "hello") }
44
44
  let(:register) { Lutaml::Model::Config.default_register }
45
45
  let(:plan) { Lutaml::Xml::Leptris::PlanCompiler.compile(model_class, register) }
46
46
 
47
- it "emits a namespaced tree byte-identically to the DOM lane" do
48
- native = described_class.emit(instance, plan, register)
49
- dom = Lutaml::Xml::Leptris::PlanSerializer.call(instance, plan, register)
50
- expect(native).to eq(dom)
47
+ it "rejects a constructed namespaced tree in the compatibility gate" do
48
+ expect(described_class.compatible?(plan)).to be(false)
49
+ end
50
+
51
+ it "serializes constructed namespaced models in the default-xmlns format" do
52
+ xml = model_class.new(id: "7", value: "hello").to_xml
53
+ expect(xml).to include('<element xmlns="http://example.com/ns"')
54
+ expect(xml).not_to include("ex:")
51
55
  end
52
56
 
53
- it "accepts namespaced trees in the compatibility gate" do
54
- expect(described_class.compatible?(plan)).to be(true)
57
+ it "admits a namespaced tree under a prefixed-preserved root" do
58
+ source = '<ex:element xmlns:ex="http://example.com/ns">' \
59
+ "<ex:id>7</ex:id><ex:value>hello</ex:value></ex:element>"
60
+ instance = model_class.from_xml(source)
61
+ expect(instance.xml_namespace_prefix).to eq("ex")
62
+ expect(described_class.compatible?(plan, instance, register)).to be(true)
63
+ native = described_class.emit(instance, plan, register)
64
+ expect(native).to include("ex:element")
65
+ reparsed = model_class.from_xml(native)
66
+ expect(reparsed.id).to eq("7")
67
+ expect(reparsed.value).to eq("hello")
55
68
  end
56
69
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lutaml-model#1136: the native emission lane ignored the DOM lane's
4
+ # render contract for attributes — an attribute whose value is still
5
+ # the default (a parse that omitted it from the source) must not
6
+ # emit when the mapping declares render_default: false. uniword's
7
+ # Style round-trip caught it: a parsed style without w:default came
8
+ # back with the ghost `w:default="0"` (the custom boolean type's
9
+ # serialization of its default).
10
+
11
+ require "lutaml/model"
12
+ require "lutaml/xml/leptris"
13
+
14
+ RSpec.describe "native emission honors the attribute render contract" do
15
+ let(:flag_type) do
16
+ Class.new(Lutaml::Model::Type::Value) do
17
+ def self.cast(value)
18
+ return true if ["1", true].include?(value)
19
+ return false if ["0", false].include?(value)
20
+
21
+ value
22
+ end
23
+
24
+ def serialize(_format, _register = nil)
25
+ self.class.cast(@value) ? "1" : "0"
26
+ end
27
+
28
+ def self.name
29
+ "EmissionRenderFlag"
30
+ end
31
+ end
32
+ end
33
+
34
+ let(:model_class) do
35
+ flag = flag_type
36
+ klass = Class.new(Lutaml::Model::Serializable) do
37
+ attribute :name, :string
38
+ attribute :default, flag
39
+ attribute :custom_style, flag
40
+
41
+ xml do
42
+ element "style"
43
+ map_attribute "name", to: :name
44
+ map_attribute "default", to: :default, render_default: false,
45
+ render_nil: false
46
+ map_attribute "customStyle", to: :custom_style,
47
+ render_default: false
48
+ end
49
+
50
+ def self.name
51
+ "EmissionRenderStyle"
52
+ end
53
+ end
54
+ stub_const("EmissionRender::Style", klass)
55
+ klass
56
+ end
57
+
58
+ let(:source) do
59
+ '<style xmlns="http://example.com/style" name="H1"/>'
60
+ end
61
+
62
+ around do |example|
63
+ Lutaml::Model::Config.with_adapter(xml: :leptris) { example.run }
64
+ end
65
+
66
+ it "omits parsed-omitted attributes that carry render_default: false" do
67
+ instance = model_class.from_xml(source)
68
+ xml = instance.to_xml
69
+ expect(xml).to include("name=\"H1\"")
70
+ expect(xml).not_to include("default")
71
+ expect(xml).not_to include("customStyle")
72
+ end
73
+
74
+ it "still emits attributes the source actually carried" do
75
+ xml = model_class.from_xml(
76
+ '<style xmlns="http://example.com/style" name="H1" default="1"/>',
77
+ ).to_xml
78
+ expect(xml).to include("default=")
79
+ end
80
+
81
+ it "keeps the DOM lane's contract on the recorded-order path" do
82
+ instance = model_class.from_xml(
83
+ '<style xmlns="http://example.com/style" customStyle="1" name="A"/>',
84
+ )
85
+ xml = instance.to_xml
86
+ expect(xml).to include("customStyle=")
87
+ expect(xml).not_to include("default=")
88
+ end
89
+ end
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+
3
+ # lutaml-model#1131: parsed schemas retain the document's xmlns
4
+ # declarations so qualified QNames resolve exactly. particlesQ032's
5
+ # chameleon-import class imports three documents each declaring a
6
+ # global `e2`; the content model references foo:e2 / x:e2 / bar:e2 —
7
+ # the prefixes ARE the semantics, and the declaration plan's
8
+ # URI-keyed registry cannot represent several prefixes bound to one
9
+ # URI.
10
+
11
+ require "lutaml/model"
12
+ require "lutaml/xml/schema/xsd"
13
+
14
+ RSpec.describe "xmlns declarations retained on parsed Schema" do
15
+ let(:xsd) do
16
+ <<~XML
17
+ <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
18
+ xmlns:foo="http://example.com/foo"
19
+ xmlns:x="http://example.com/foo"
20
+ xmlns:bar="http://example.com/bar"
21
+ targetNamespace="http://example.com/main"
22
+ elementFormDefault="qualified">
23
+ <xs:import namespace="http://example.com/foo"/>
24
+ <xs:import namespace="http://example.com/bar"/>
25
+ <xs:element name="root">
26
+ <xs:complexType>
27
+ <xs:sequence>
28
+ <xs:element ref="foo:e2"/>
29
+ <xs:element ref="x:e2"/>
30
+ <xs:element ref="bar:e2"/>
31
+ </xs:sequence>
32
+ </xs:complexType>
33
+ </xs:element>
34
+ </xs:schema>
35
+ XML
36
+ end
37
+
38
+ let(:schema) do
39
+ Lutaml::Xml::Schema::Xsd.parse(xsd, location: "particles_q032.xsd")
40
+ end
41
+
42
+ it "retains every declared prefix with its URI" do
43
+ declarations = schema.xmlns_declarations
44
+ expect(declarations["xs"]).to eq("http://www.w3.org/2001/XMLSchema")
45
+ expect(declarations["foo"]).to eq("http://example.com/foo")
46
+ expect(declarations["x"]).to eq("http://example.com/foo")
47
+ expect(declarations["bar"]).to eq("http://example.com/bar")
48
+ end
49
+
50
+ it "keeps prefixes the declaration plan's URI-keyed registry collapses" do
51
+ # foo: and x: bind the SAME URI — an exact prefix→URI map must
52
+ # carry both spellings; the plan registry keeps only the last.
53
+ expect(schema.xmlns_declarations.fetch("foo"))
54
+ .to eq(schema.xmlns_declarations.fetch("x"))
55
+ end
56
+
57
+ it "resolves the particlesQ032 reference prefixes exactly" do
58
+ declarations = schema.xmlns_declarations
59
+ %w[foo x bar].each do |prefix|
60
+ expect(declarations).to have_key(prefix)
61
+ expect(declarations[prefix]).to start_with("http://example.com/")
62
+ end
63
+ end
64
+
65
+ it "captures a plain XML document's declarations with the default under nil" do
66
+ ns = Class.new(Lutaml::Xml::Namespace) do
67
+ uri "http://example.com/doc"
68
+ prefix_default "d"
69
+ end
70
+ model = Class.new(Lutaml::Model::Serializable) do
71
+ attribute :child, :string
72
+
73
+ xml do
74
+ namespace ns
75
+ element "doc"
76
+ map_element "child", to: :child
77
+ end
78
+ end
79
+
80
+ instance = model.from_xml(
81
+ '<doc xmlns="http://example.com/doc" ' \
82
+ 'xmlns:p="http://example.com/p"><child>x</child></doc>',
83
+ )
84
+ expect(instance.xmlns_declarations[nil]).to eq("http://example.com/doc")
85
+ expect(instance.xmlns_declarations["p"]).to eq("http://example.com/p")
86
+ end
87
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lutaml-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.166
4
+ version: 0.8.168
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -2018,9 +2018,11 @@ files:
2018
2018
  - spec/lutaml/xml/general_namespace_spec.rb
2019
2019
  - spec/lutaml/xml/html_entities_spec.rb
2020
2020
  - spec/lutaml/xml/indent_spec.rb
2021
+ - spec/lutaml/xml/leptris/emission_graph_deferred_spec.rb
2022
+ - spec/lutaml/xml/leptris/native_emission_nested_sharing_spec.rb
2021
2023
  - spec/lutaml/xml/leptris/native_emission_ns_parity_spec.rb
2022
2024
  - spec/lutaml/xml/leptris/native_emission_ordered_spec.rb
2023
- - spec/lutaml/xml/leptris/native_emission_raw_gate_spec.rb
2025
+ - spec/lutaml/xml/leptris/native_emission_render_contract_spec.rb
2024
2026
  - spec/lutaml/xml/leptris/plan_hydrator_ns_snapshot_spec.rb
2025
2027
  - spec/lutaml/xml/leptris_string_encoding_spec.rb
2026
2028
  - spec/lutaml/xml/line_ending_spec.rb
@@ -2101,6 +2103,7 @@ files:
2101
2103
  - spec/lutaml/xml/schema/xsd/schema_helper_methods_spec.rb
2102
2104
  - spec/lutaml/xml/schema/xsd/schema_mapping_spec.rb
2103
2105
  - spec/lutaml/xml/schema/xsd/schema_validator_spec.rb
2106
+ - spec/lutaml/xml/schema/xsd/schema_xmlns_declarations_spec.rb
2104
2107
  - spec/lutaml/xml/schema/xsd/spec_helper.rb
2105
2108
  - spec/lutaml/xml/schema/xsd/unresolvable_schema_location_spec.rb
2106
2109
  - spec/lutaml/xml/schema/xsd/validation_error_spec.rb
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # leptris#1941 consumer-gap law: the RAW-splice capability rides
4
- # engine 1.9.406.0 (PLAN_OP_RAW + row identity). A bundle resolving
5
- # an OLDER leptris gem — e.g. the metanorma consumer matrix pinned to
6
- # 1.9.405.0 — must take the DOM lane, not the ops lane: splicing
7
- # :raw without the engine constant emitted EMPTY fragments and the
8
- # round-trip parse died on "empty input". The gate probes the FFI
9
- # constant, so capability tracks the loaded gem, not a version
10
- # table that drifts.
11
- RSpec.describe Lutaml::Xml::Leptris::NativeEmission, ".raw_op_supported?" do
12
- it "is false for an FFI surface without the RAW op" do
13
- plain = Class.new
14
- expect(described_class.raw_op_supported?(plain)).to be(false)
15
- end
16
-
17
- it "is true when PLAN_OP_RAW is defined" do
18
- with_raw = Class.new
19
- with_raw.const_set(:PLAN_OP_RAW, 4)
20
- expect(described_class.raw_op_supported?(with_raw)).to be(true)
21
- end
22
-
23
- it "probes the loaded gem by default (harness runs 1.9.406.0)" do
24
- expect(described_class.raw_op_supported?).to be(true)
25
- end
26
- end