What makes a text a “commentary”? The question is naif enough to allow for a complicated answer. First of all, let me note the obvious: There is not a single word for “commentary” in Sanskrit, where one needs to distinguish between bhāṣyas, vārttikas, ṭippanīs, etc., often bearing poetical names, evoking Moons, mirrors and the like.
Sanskrit authors, thus, had in mind a widely different set of texts which we all bring back to the seemingly single category of “commentary”. Some of them are chiefly line-by-line or word-by-word explanations (an illustrious example is Manorathanandin’s commentary on Dharmakīrti’s PV). Others entail elaborate philosophical disquisitions (such as Vācaspati’s Nyāyakaṇikā on Maṇḍana’s Vidhiviveka). Still others just comment on a few words or sentences every 10 pages or so (such as Cakradhara’s Granthibhaṅga on Jayanta’s Nyāyamañjarī).
Some of them are part of a longer history, that they fully embrace. This is especially true in the case of the philosophical sūtras and of their first Bhāṣya-commentary, which tends to be fused in a single text. This last sentence could also be interpreted as saying that a sūtra-part was only later extracted out of the respective Bhāṣya.
Vācaspati’s commentary of the Nyāyasūtra, for instance, embeds comments also on its Bhāṣya by Vātsyāyana, but typically also on the Vārttika thereon. Others focus only on one text and neglect the successive history. Śrīprapāduka’s commentary on the same Nyāyasūtra, for instance, explicitly focuses only on it.
What is constant in all these cases is that a commentary is in close dialogue with a root text (with or without its commentaries), which remain(s) its main interlocutor(s).
This makes the definition wide enough to encompass texts such as the Nyāyamañjarī itself, which comments extensively on some selected Nyāyasūtras (Graheli 2016 contains an appendix with the sūtra numbers and the impressive amount of pages dedicated to each of them). Similarly, Veṅkaṭanātha’s Seśvaramīmāṃsā comments anew the Mīmāṃsāsūtra, programmatically neglecting the commentary by Śabara.
Thus, we could sum up the relation “A is a commentary of B” as “B is the main interlocutor of A”. **UPDATE: The relation of “being the main interlocutor” can be more loosely understood if A and B belong to the same śāstric tradition, whereas it needs to entail a very close (e.g., page-by-page or line-by-line) dialogue in order to consider A, which is polemical about B, a commentary of it.**
However, the picture may become still more complicated, because a text A apparently commenting on B may have in fact in view most of all B’s other commentary, C, so that C, though never mentioned, is A’s main interlocutor.
Coming back to the example mentioned above, the Seśvaramīmāṃsā comments on the Mīmāṃsāsūtra, but while having constantly in view the Śabara’s Bhāṣya thereon and, more strikingly, Rāmānuja’s Bhāṣya on a different sūtra, namely the Brahmasūtra. One ends up with a net of main interlocutors rather than a single one.
**I thank Amod Lele for the discussion in the comments on the same post at the Indian Philosophy blog.