CHIYUV MISAH FOR RULING IN FRONT OF ONE'S PRIMARY REBBI [Hora'ah: Rabo Muvhak]
Gemara
5b: (Rebbi authorized Rabah bar Chanah and Rav to teach Halachos.) Why did they need permission? They were learned!
Answer: This was decreed after an episode in which a Chacham expounded, and people midunderstood him.
110a (Rav Chisda): One who challenges his Rebbi is like one who challenges Hash-m. (It says about Korach's rebellion) "b'Hatzosam Al Hash-m."
(R. Chama b'Rebbi Chanina): One who makes a quarrel with his Rebbi is like one who quarrels with Hash-m - "Mei Merivah Asher Ravu Vnei Yisrael Es Hash-m."
(R. Chanina bar Papa): One who complains about his Rebbi is like one who complains about Hash-m - "Lo Aleinu Selunoseichem Ki Al Hash-m."
Eruvin 62b (Abaye): Even though Megilas Ta'anis (days when one may not fast or eulogize) is written, one may not rule about it in front of his Rebbi Rav Chisda refused to permit even eggs with milk while Rav Huna was alive!
63a (Rava): One may not rule in front of his Rebbi. One is Chayav Misah (b'Yedei Shomayim) for this. Not in front of his Rebbi it is forbidden, but one is not Chayav Misah.
Question: Even not in front of his Rebbi one is Chayav Misah!
(Beraisa - R. Eliezer): Aharon's sons were killed for (implicitly) ruling in front of Moshe their Rebbi (even though fire descends from Shomayim, it is a Mitzvah for people to bring fire.)
A Talmid of R. Eliezer ruled in front of him. R. Eliezer said 'I will be amazed if he survives the year. I have a tradition that one who rules in front of his Rebbi is Chayav Misah.' (The Talmid died.)
(Rabah bar bar Chanah): The Talmid was Yehudah ben Gurya, he was three Parsa'os away from his Rebbi.
Answer: Yehudah ruled in front of R. Eliezer. (He lived three Parsa'os from his Rebbi).
Kesuvos 60b: Abaye's sharecropper asked whether he may be Mekadesh a woman nursing a baby 15 months old. Abaye permitted, based on four reasons. He came in front of Rav Yosef, without told him that Rav and Shmuel both require waiting 24 months. Abaye ran three Parsa'os, but did not catch his sharecropper to retract his ruling.
Abaye: Chachamim say 'do not rule in the place of your Rebbi, even to permit eating eggs with milk.' This is not (only) due to arrogance. Rather, he will err! I had learned this teaching of Rav and Shmuel, and still, I erred!
Bava Metzia 33a (Beraisa - R. Meir): One's Rebbi's is the one who taught him Chachmah, not the one who taught him written Torah or Mishnah;
R. Yehudah says, it is whom he learned most of his Chachmah from;
R. Yosi says, it is even if he explained only one Mishnah to him.
(R. Yochanan): The Halachah follows R. Yehudah.
(Rav Acha bar Rav Huna): The Halachah follows R. Yosi.
Rishonim
Rambam (Hilchos Talmud Torah 5:1): One who argues with his Rebbi, quarrels with him or complains about him is like one who argues or quarrels with or complains about Hash-m
Rambam (2): Arguing with one's Rebbi is fixing a Shi'ur in which he expounds without his Rebbi's Reshus (permission), in his Rebbi's lifetime, even if he is in another country. One who rules in front of his Rebbi is Chayav Misah.
Rambam (9): Rabo Muvhak is the Rebbi who taught to him most of his Chachmah. If he did not learn most of his Chachmah from him, he is a Talmid Chaver.
Rosh (Eruvin 6:2): A proper Talmid may not rule even not in front of his Rebbi, even outside of three Parsa'os, just then he is not Chayav Misah. We asked why Yehudah was Chayav Misah for ruling not in front of one's Rebbi, but we did not question that it was forbidden! Within three Parsa'os is considered in front of him, like the Talmid who ruled in front of R. Eliezer. Presumably, Aharon's sons did not rule directly in front of Moshe, just they were in Machaneh Yisrael. This is the source for the Shi'ur of three Parsa'os.
Poskim
Shulchan Aruch (YD 242:4): One may never rule in front of his Rebbi. One who does so is Chayav Misah.
Gra (8): This refers even to a question that happened to occur, like the case of Tanchum. (They questioned why he ruled where his Rebbi was.) We learn Misah from Moshe, who was a Rav Muvhak. The Rashba (111) says that Sanhedrin 5b forbids a Stam Talmid, i.e. even a proper Talmid. Letter of the law, outside of three Parsa'os is permitted. 'In front of him' is right in front of, and 'not in front' is within three Parsa'os. We decree to forbid even outside of three Parsa'os. This is why we asked that since they were learned, they did not need Reshus. I.e. even a proper Talmid should be permitted outside of three Parsa'os. Within three Parsa'os, letter of the law it is forbidden, so Reshus does not help.
Rema: Reshus does not help within three Parsa'os (about 12 kilometers) of Rabo Muvhak.
Beis Yosef (DH u'Mashma): Tosfos says that Reshus does not help within three Parsa'os. Kesuvos 60b supports this. Within three Parsa'os, Reshus causes that he does not violate honor of his Rebbi, but it is still forbidden, for it is considered in front of his Rebbi.
Shach (4): The Ra'avad, Rashba and Rivash hold that Reshus helps even within three Parsa'os.
Gra (8): Tosfos in Kesuvos holds that Reshus helps for within three Parsa'os, but in any case one will not succeed. Perhaps Rav Yosef was not Abaye's Rabo Muvhak (rather, Rabah was).
Shulchan Aruch (ibid.): Some say that a proper Talmid within three Parsa'os is Chayav Misah if he rules, and outside of three Parsa'os is forbidden, but he is exempt.
Beis Yosef (DH uv'Perek): The Rambam says that outside three Parsa'os is forbidden when he fixed himself to rule, but permitted if someone happened to ask. Tosfos and the Rosh forbid a proper Talmid outside of three Parsa'os, and permit a Talmid Chaver.
Shulchan Aruch (ibid): Reshus from one Rebbi does not suffice. He must ask Reshus from all his Rabosav Muvhakim.
Source: Beis Yosef (DH u'Mashma, citing Maharik 169)
Maharik (169): Semak says in the name of Maharam that the Isur to rule in front of one's Rebbi was only the days of the Tana'im and Amora'im. Even if Maharam said so, the Rambam, Tur and other Poskim hold that the Isur applies today, and one is Chayav Misah for it. I think that Maharam means that then, all Hora'ah was forbidden, but nowadays what is explained in Poskim is permitted. What is not explained is still forbidden. A Talmid may not rule about what is written in Megilas Ta'anis. One must be stringent only for Rabo Muvhak from whom he learned most of his Chachmah. Rav Achai Ga'on, Ri, Rambam, Rid, Rosh and Tur all rule like R. Yehudah, that one must honor only the Rebbi who taught to him most of his Chachmah. R. Chananel and Avi ha'Ezri rule like R. Yosi, but only for tearing and standing, but not for other laws of Rabo Muvhak which are learned in Sanhedrin 110a from Moshe. There is no source for Rabo she'Eino Muvhak.
Rema: Usually, Rabo Muvhak is the Rebbi from whom he learned most of his Chachmah. If so, one cannot have more than one! Here it must mean a proper Talmid, to exclude a Talmid Chaver, i.e. a Talmid who grew in Torah and became a colleague, i.e. almost as great a Chacham as his Rebbi.
Shach (12): The first opinion in the Rema holds that one is a Talmid even if he did not learn most of his Chachmah from him. I disagree. Most rule like R. Yehudah, that one must honor only the Rebbi who taught to him most of his Chachmah. Even those who rule like R. Yosi say so only for tearing and standing, but not for other laws of Rabo Muvhak. Reish Lakish learned most of his Chachmah and received Semichah from R. Yochanan, and even so Reish Lakish argued with him and ruled in practice in front of him, for he became almost as great as him. The Rema's proof is invalid, for one can have many Rebbeyim Muvhakim, i.e. the ones who taught him most of his Mikra, Mishnah, Gemara, Agada, Kabalah, etc.
Shulchan Aruch (30): Rabo Muvhak is the one from whom he learned most of his Chachmah, be it Mikra, Mishnah or Gemara.