While trying to find a temporary hack to satisfy my own need, I realized what you said:
"This semantic isn't used only in tramp-sh-handle-get-home-directory, but everywhere in Tramp.
"
So it is not something as simple as changing this one function.
But regarding the concept of "user" and "home directory", I have some different opinions.
1. I support the idea of expanding the tramp syntax so it can cover wider cases, such as k8 namespace (or even context?) mentioned in your email. As much as I like kubel, it is a bit of a pain that only one name space can be used at one time.
2. However, that should not prevent us from handling the existing syntax better
3. "The point is, that in kubel the Tramp user is misused to be the (optional) container name.". We certainly can say that. But on the other hand, I think we also can ask: do we need to restrict the "user" part of the tramp syntax to an actual user name whose "echo ~<user_name>" must produce a valid home directory? What is the benefit of having that restriction? Do we gain anything by NOT returning the correct home directory simply for the sake of maintaining a "pure" definition of the "user" part of the tramp file syntax?
4. Even if for certain reasons (existing code, for example), changing the definition of "user" part in a tramp file name is not desired or practical (so we maintain the objection to the syntax "kubel" uses), we may still separate how the home directory is retrieved from the user itself. That's what Emacs 26.3 did (hence I noticed this "regression" while upgrading Emacs). It retrieves the home directory by sending "cd; pwd" to the shell process of the tramp connection.
I am speaking from the perspective of a regular user who does not really know the internals and history of tramp well, so I may well have missed some important design principles that invalidate my above points. But maybe an outsider sometimes can also give some fresh viewpoints? :-)
Best regards.
Warren