It is well known that Proto-Indo-Aryan *s had an allophone *z in voiced contexts. Due to some phonetic changes (i.e. RUKI law and the shift *śt > ṣṭ), they both could undergo retroflexion, thus producing two new allophones *ṣ, *ẓ. My question concerns the reflexes of the latter allophone in Sanskrit. It seems that the reflexes of *ẓ have a somewhat strange distribution.
Most grammars of Sanskrit agree that this *ẓ was eliminated from the phonetic inventory of the language in several ways depending on the contest: (1) In internal sandhi, it either was completely lost when it occurred before a consonant of the dental or retroflex series with compensatory lengthening of the preceding vowel, as in नीड nīḍá- < *niẓḍá- 'nest' (cf. OHG nest, Lith. lìzdas, OArm. նիստ nist, OCS гнѣздо gnězdo), or it was substituted by ḍ before other kinds of consonants, as in विप्रुड्भ्यः vipruḍ-bhyáḥ < *vipruẓ-bhyas dat./abl. pl. of विप्रुट् vipruṭ 'drop'. (2) In external sandhi, -iḥ, -uḥ (< *-iṣ, *-uṣ) are substituted with -r if they are followed by a vowel or a voiced consonant, e.g. अग्निरस्ति agnir asti < agniḥ + asti 'there is fire', or in the compound यजुर्वेद yajur-veda < yajuḥ + veda 'the Veda of the (sacrificial) formulas'. This sandhi rule can also be explained through a similar change where *ṣ > *ẓ / __[+ voiced], and at a later stage *ẓ > r.
If this account is correct, then in theory we should only find ḍ before inflectional suffixes beginning in voiced consonants, e.g. -bhiḥ instrumental, -bhyaḥ, -bhyām dative and ablative plural and dual, because as far as I know, when declining a noun, only internal sandhi applies. However, this doesn't seem to be the case. As a matter of fact, besides nouns like विप्रुष् vipruṣ- 'drop', द्विष् dviṣ- 'enemy', which indeed do have ḍ in their declension (let's call them Set A), there are also a few s-stems, e.g. हविस् havis- 'oblation', यजुस् yájus- 'sacrificial formula' and of the like, which have for example हविर्भिः havir-bhiḥ and यजुर्भिः yájur-bhiḥ (let's call them Set B), almost as if an external sandhi would apply here.
It seems to me that there is no relevant difference between nouns of Set A and B, at least from a phonological standpoint. More specifically, their phonological context is the same, i.e. an original PIE *s is retroflexed to *ṣ (because it is placed after i or u), which then turns into *ẓ whenever followed by a voiced consonant. Yet, they appear to show different reflexes of *ẓ, mainly ḍ for Set A and r for Set B. How is this possible? Can this apparent incongruence be phonologically motivated?