step-examples/12-13-writer-pathology/Wr039.stp
Sources
- OCCT forum "complex entity attribute order changed"
- bug-reporter language: "round-trip reorders attributes in compound entity"
Sender
Writers that build complex records by iterating an unordered set of supertype names
Description
A complex (subtype-stack) record like `(LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.))` is re-emitted on round-trip as `(SI_UNIT(.MILLI.,.METRE.) NAMED_UNIT(*) LENGTH_UNIT())`; the same complex entity but with the supertype list reordered. Spec-conforming (the order within `(... ..)` is supertype-significant per ISO 10303-21 §11 but only by inheritance hierarchy, not by emission order); receivers that build canonical hash strings see the file as different. Bug-reporter language: "subtype-stack reordered", "complex entity attribute order changed", "STEP round-trip permutes inheritance order".
Reproducer recipe
`#20=(SI_UNIT(.MILLI.,.METRE.) NAMED_UNIT(*) LENGTH_UNIT());` (canonical ordering would be `LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(..)`).
Expected kernel behavior
Heal and accept: normalize / emit complex-record supertype lists in a canonical order (e.g., alphabetic or schema-declaration-order) deterministically.
Notes
Subtle: parsers handle either order, but file-equivalence tests fail. Provenance tier: writer-side (Q5 reclassification 2026-07-01).
Expected validation
occt=empty/empty gmsh=empty ifc=schema_n/a
Provenance tier
writer-side — defect not fully embodied in fixture bytes.
Byte assertions
matches(rb'\(\s*SI_UNIT\([^)]+\)\s+NAMED_UNIT\(\*\)\s+LENGTH_UNIT\(\)\s*\)')matches(rb'\(\s*SI_UNIT\(')
Tier-3 assertions
load == "ok"
Live oracle output
No live oracle data — run _run_corpus to populate.
Fixture content
Show fixture bytes (with defect highlighting)
1ISO-10303-21; 2/* Wr039: re-export re-orders attributes within complex (subtype-stack) records */ 3/* Canonical: (LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.)) */ 4/* DEFECT: (SI_UNIT(.MILLI.,.METRE.) NAMED_UNIT(*) LENGTH_UNIT()) */ 5/* Writer iterated an unordered set of supertype names; SI_UNIT happened first */ 6/* Parsers accept both orders; byte-hash comparators report the file as changed */ 7HEADER; 8FILE_DESCRIPTION(('Wr039: non-canonical complex-entity supertype ordering'),'2;1'); 9FILE_NAME('Wr039.stp','2026-06-17T00:00:00',(''),(''),'cad-research-suite','',''); 10FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 3 1 1 }')); 11ENDSEC; 12DATA; 13#1=CARTESIAN_POINT('origin',(0.,0.,0.)); 14#2=CARTESIAN_POINT('corner',(1.,1.,0.)); 15#3=DIRECTION('xdir',(1.,0.,0.)); 16#4=DIRECTION('zdir',(0.,0.,1.)); 17/* DEFECT: supertype order is SI_UNIT first, then NAMED_UNIT, then LENGTH_UNIT */ 18/* Canonical schema-declaration order is: LENGTH_UNIT NAMED_UNIT SI_UNIT */ 19#20=(SI_UNIT(.MILLI.,.METRE.) NAMED_UNIT(*) LENGTH_UNIT()); 20#21=GEOMETRIC_CURVE_SET('reordered-complex-entity-shape',(#1,#2)); 21ENDSEC; 22END-ISO-10303-21;