Refactor sharding key rules
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=537678)
</details>
<!--IssueSummary end-->
### Why
Related to https://gitlab.com/gitlab-org/gitlab/-/issues/536752+ and https://gitlab.com/gitlab-org/gitlab/-/merge_requests/188873+
The initial implementation of set sharding key behavior runs on every validation check. Eventually we can use the suggestion in the MR to consolidate this but only after we add the sharding key logic for each layer (MR,Project, Group etc)
### What
Implement similar suggestion to https://gitlab.com/gitlab-org/gitlab/-/merge_requests/188873#note_2470099175
issue