Apparently it’s possible to set the default view of how folders are open/closed in the sidebar, so that when you go back to the same perspective, the view is reset to your personal default. I’m looking for how to do this, specifically in the project perspective but I guess it’s possible in all perspectives.
Not possible. Each Perspective will preserve its last altered state only.
You can use elaborate Keyboard Maestro macros to load your OmniFocus windows to your exact specifications like window size, perspective, search, focus mode, sidebar views, and basic expand/collapse states.
If you need a highly intricate folder scheme, consider making a “clone” Perspective and setting up the folder open/close structure how you like. It will always be how you last left it.
I tested in MacOS OF3 and MacOS OF4 test build, it’s as you described for custom perspectives and at a minimum that’s what I need. But for the basic perspectives (projects, tags, flagged), the folders are always fully developed when I come back to them, whatever the state I left them. Is it the same for you?
If this behaviour is as intended, I might consider creating a clone perspective like you indicated.