One thing that I’ve started to do, and would apply here, is to define variables from folders’ pre-scripts, and to update the stored variables. I use it to set certain common variables to specifics needed for tests/APIs within a given folder structure. I have tests that are similar, but some values need to be set specific to the tests being run. This lets me use a single environment, and flip values dynamically from the folder level.
The way this could apply here is to combine folder variable definition with setting global level variables to contain functions - this lets a folder level applied value to be used anywhere. It also allows for global variables to be portable - by copying and moving folders, or sharing collections.
I’m in the process of trying to simplify the mess of code and variables and environments I use day to day, in to a compact standalone and easy to use Collection - which sets itself up via folder level environment setup and inheritance of pre/post scripts at the folder level so as others use and enhance this setup - their calls just automatically use the framework/code that is stored in folders/globals/active-environment.