Upgradeability and adding new members to structs

Hi, sorry if this has been asked before.

Do struct definitions count as storage variables on the smart contract? For example, I have a struct

struct s { uint256 a; uint256 b; }

I do not use this struct in any mappings, nor do I ever explicitly declare a state variable for it. I'm only using this struct to get around the function call stack variable limit, so whenever I actually instantiate a struct s within a function, I use the memory keyword.

Now I want to upgrade my contract, and I want to add extra members to my struct s definition (including a new struct that will be used in in a similar fashion as my struct s). Is this viable? Or will it interfere with the storage layout of the previous state variables?

If you only use the struct in memory and it is never stored in a storage variable then it's generally fine to add a new field. The only possible caveat is if you return the struct from some external function and other contracts may depend on your API being stable. In that case you want to make sure that the encoded structure that you return remains backwards compatible.

If you use the OpenZeppelin Upgrades Plugins it will alert you when a change to a struct has an impact on storage layout.