"Buy us some bread."
Translation:Купи нам какого-нибудь хлеба.
You are perfectly right, compare https://context.reverso.net/translation/russian-english/%D1%85%D0%BB%D0%B5%D0%B1%D0%B0 Купи хлеба у Томпсона на углу и молока "Well, get some bread from Thompson's on the corner and some milk".
какой/ого-нибудь is not the object but an attribute to the object noun хлеб; thus its case must be congruent with хлеб/а similar to an adjective. So the grammatical idea is "buy us [from an unspecified bread quantity]" rather than "buy us whatever [of bread]".
As you say, genitive makes the object an uncountable mass or a whole rather than a countable object among several similar objects.
Купи нам какой-нибудь хлеб = Buy us some kind of bread, for there are several types, but it doesn't matter which one you choose.
Купи нам какого-нибудь хлеба = Buy us some amount of bread, for it doesn't matter how much of that "substance" you buy.
The particle "-то" conveys uncertainty. Meaning that neither the speaker nor the listener knows what specific thing is being referred to.
Conversely, the particle "-нибудь" conveys indifference. Meaning that the speaker doesn't really care what specific thing the listener will consequently single out.
This implies that putting a "-то" pronoun into an imperative sentence makes it sound like the speaker doesn't have any idea what they're requesting.
To add: there is a Russian construction contained in "нибудь": ни+imperative verb. Meaning something like "whatever": какой хлеб ни купи, весь невкусный: whatever bread you buy, it's all tasteless. Same goes for где-нибудь (где ни будь, везде хорошо=wherever you are, anywhere is fine), как-нибудь etc.
P.S. I wish someone would write such comments on French and others for complex words and constructions which obviously carry certain logic.
That seems to contradict the Tips and notes:
"кто-нибудь and что-нибудь mean a "hypothetical" object. A slot you have in mind, not actually filled by anything in particular...Mostly useless in statements about the past (if you are sure it happened, then the object did exist)"
Without regard to tense, the speaker isn't asking for hypothetical bread, and doesn't appear to be contemplating the non-existence of bread at the store, it's just a matter of buying some kind of existing bread.
"кто-то and что-то refer to a specific but "unknown" object. You see/know that something exists (or you are sure of it) but you don't know its identity."
Тhe unknown thing is the kind of bread. The speaker and listener know it's bread, just not what kind.
Other exercises suggest that -то should be preferred, as in "Ученик/студент ждёт кого-то возле библиотеки." "The student is waiting for someone near the library."
The student is waiting for an unknown person, who clearly can't be hypothetical - we just don't know who it is. Presumably (but not necessarily), the student knows who it is.
I don't see how you can reconcile the logic in Ythinn's comment with the result in the exercise about the student. It seems highly unlikely that, while the speaker doesn't know who the student is waiting for, that the student also does not know who he/she is waiting for.
This can be easily resolved by me admitting that "-то" doesn't necessarily impart said uncertainty to the listener. The student in your suggested example may very well be aware of who he's waiting for.
But this all comes apart in imperative sentences. When the speaker doesn't tell you what kind of bread to buy (but they do have a specific kind of bread in mind), the listener finds themselves in a state of similar uncertainty, and is forced to ask for a clarification. They might very well know, ultimately, what kind of bread it is, but not at the point of hearing "какого-то".
I wasn't so much concerned with the uncertainty issue - both forms have some of that to them - but that -нибыдь implies indifference, suggesting that -то does not. Plus the idea in the Tips and Notes that -нибудь involves hypotheticals.
If my wife sends me to the store and ask me to get "some bread", I already have a good idea what to get, so that even if she says, "get whatever you like", I know that it means something for sandwiches without an exotic flavor - something I will know from prior experience that she will like. She certainly is not indifferent to the choice given to me, and we will both have a fairly firm idea of what kind of bread I'm to buy. The choices will actually be quite limited, even where there are dozens of possible selections of "any" bread.
There's also the exercise "Она всегда что-то делает." = "She is always doing something." We don't know what it is or will be, and she may not know what it will be until she actually starts doing something. Lots of unknowns, no indifference - kind of like me buying bread for my wife.
For contexts like that, it seems to me that какого-то would be applicable than Какого-нибудь - though I recognize that, if people just don't use какого-то in this kind of sentence, then that should be the "rule". Idiom and usage trump grammar almost every time. Or if there's a rule about imperatives and "something", then that trumps my logic.
As far as language is concerned, your missus is indeed indifferent towards the choice of bread at the time of making her request for "какого-нибудь хлеба". The fact that you might end up picking up the wrong kind of 'any bread you like' is beyond the scope of mortal grammar.
Or, more specifically, the missus is quite aware that you are already aware of the small subset of bread she is referring to, and she doesn't really care which specific kind of bread from that subset you'll end up picking. But, again, this is not conveyed by the language itself.
In the same vein, your second example ("Она всегда что-то делает") goes to illustrate how "-то" is a relatively weaker marker of indifference than the English 'some-'. The subtle implication that she is keeping herself busy with trivial stuff, just for the sake of keeping herself busy, is still there in Russian (as in, she might not even care what she's doing all the time), but it is pretty much overshadowed by the primary message that the speaker doesn't know what it is, exactly, that she does. This kind of 'something' is more of a 'something'.
Ultimately, this is what makes the use of "-то" in requests so awkward: the fact that it does convey an attempt to single out a specific instance from the existing breads, students, things to do, and suchlike. Asking for a "какого-то хлеба" means that you're both quite certain what kind of bread you're requesting (e.g. you remember the taste), and quite unsure of how to tell me what kind of bread it is.
I can't even just wave it off as idiomatic or idiosyncratic to the Russian language, it's just the kind of situation that calls for a preemptive explanation, rather than the use of 'some-' bits. It's the same thing in English when you've got a fancy-shaped lock in front of your eyes. You might think to yourself that you need 'some kind of a key'. But you won't be asking your wife (who for some reason can't see said lock) for 'some kind of a key'.
The logic seems off in this sentence. In English, buy me some bread and buy me some kind of bread are both different. If you are asking for a certain amount of a specific type of bread, I believe it should be specified, i.e. buy me some wheat bread or buy me bread... in general.