Context is incorrect after new scene created

Actually, some operators seem cumbersome to translate to data operations.
For example grouping the selected nodes. The operator will automatically create all the links, inputs and outputs.
To my understanding, if I were to do this with scene data, I would have to script moving the nodes in the group, adding the input/output sockets and making the links, which is Quite inefficient in comparison.

Apparently I’m not the first one to run into a similar issue but @lewis2e didn’t get a response: