@@ -70,6 +70,45 @@ class ConfigWithNestedTopology:
7070 nested : NestedTopology = field (default_factory = NestedTopology )
7171
7272
73+ @dataclass (frozen = True )
74+ class SpatialConfig :
75+ width : int = 12
76+
77+
78+ @dataclass (frozen = True )
79+ class VolumeConfig (SpatialConfig ):
80+ depth : int = 60
81+
82+
83+ @dataclass
84+ class ConfigWithSpatialDomain :
85+ spatial : SpatialConfig = field (default_factory = SpatialConfig )
86+
87+
88+ def test_nested_nominal_subtype_survives_raw_live_and_saved_reconstruction ():
89+ state = ObjectState (ConfigWithSpatialDomain (VolumeConfig ()), scope_id = "volume" )
90+ assert state .to_object ().spatial == VolumeConfig ()
91+ assert state .to_saved_resolved_object ().spatial == VolumeConfig ()
92+ assert state .to_resolved_object ().spatial == VolumeConfig ()
93+
94+ state .update_parameter ("spatial.depth" , 30 )
95+ assert state .to_object ().spatial == VolumeConfig (depth = 30 )
96+ assert state .to_resolved_object ().spatial == VolumeConfig (depth = 30 )
97+ assert state .to_saved_resolved_object ().spatial == VolumeConfig (depth = 60 )
98+
99+
100+ def test_nested_nominal_owner_changes_rebuild_parameter_topology ():
101+ state = ObjectState (ConfigWithSpatialDomain (), scope_id = "spatial" )
102+ state .update_object_instance (ConfigWithSpatialDomain (VolumeConfig (width = 24 )))
103+ assert state .to_saved_resolved_object ().spatial == VolumeConfig (width = 24 )
104+ assert "spatial.depth" in state .parameters
105+
106+ state .update_object_instance (ConfigWithSpatialDomain (SpatialConfig (width = 18 )))
107+ assert state .to_object ().spatial == SpatialConfig (width = 18 )
108+ assert state .to_saved_resolved_object ().spatial == SpatialConfig (width = 18 )
109+ assert "spatial.depth" not in state .parameters
110+
111+
73112class DelegatedHost :
74113 __objectstate_delegate__ = "config"
75114
0 commit comments