This is a preliminary clarification question on the fundamental verse used by the Gemmorah (Sanhedrin 49a) and Rambam for allowing King to kill his rebels (following "where-does-the-power-of-a-jewish-king-to-sentence-to-death-come-from"):
"וַיַּעֲנוּ אֶת־יְהוֹשֻׁעַ לֵאמֹר כֹּל אֲשֶׁר־צִוִּיתָנוּ נַעֲשֶׂה וְאֶל־כָּל־אֲשֶׁר תִּשְׁלָחֵנוּ נֵלֵךְ׃
כְּכֹל אֲשֶׁר־שָׁמַעְנוּ אֶל־מֹשֶׁה כֵּן נִשְׁמַע אֵלֶיךָ רַק יִהְיֶה ה' אֱלֹקיךָ עִמָּךְ כַּאֲשֶׁר הָיָה עִם־מֹשֶׁה׃ כָּל־אִישׁ אֲשֶׁר־יַמְרֶה אֶת־פִּיךָ וְלֹא־יִשְׁמַע אֶת־דְּבָרֶיךָ לְכֹל אֲשֶׁר־תְּצַוֶּנּוּ יוּמָת רַק חֲזַק וֶאֱמָץ׃" (Joshua 1:18)
Here are the points I'd like to clarify about this Posuk and this ruling:
This Posuk was said neither by G-d nor by Yehoshua, it was said by the people, accepting upon themselves (seemingly against the laws of the Jewish justice given to Moses) being killed by Yehoshua if caught rebelling against him.
This verse was seemingly a מצווה לשעתה, it was not given to Moses or to the main sequence of Jewish Kings, starting from Saul, as G-d clearly does not count it in the 30 attributes of a King in Samuel A 9. Similarly, Rambam does not count it as a Mitzvah on a King.
(AFAIK) this rule was not applied before the main sequence of kings (ie. from Yehoshua to Shmuel), rather the only existing examples are starting from Saul/David times.
So besides of being an אסמכתא בעלמא how this verse can be the source for that law?