You shall not go outside the entrance of the Tent of Meeting for seven days, until the day that your period of ordination is completed. For your ordination will require seven days.
We learn in Leviticus it takes seven days to ordain a priest or to consecrate something and to make it holy. (The Torah was compiled ca. 4th Century BCE)
And what justification did they see for making Channuka eight days? Wasn’t the dedication (channuka) which Moshe did in the wilderness only seven days? ... So what reason did they see to make this dedication eight days? In the days of the kingdom of Greece the Hasmoneans entered the Temple, built the altar, plastered it with plaster [which took a day] and for seven days they were preparing the vessels for service.
The Tannaim (earlier ancient rabbis) made reference back to the Torah and wondered why Chanukah is eight days instead of seven days. It took an eighth day for the Temple to be purified and dedicated back to God in the account of Chanukah which is why Chanukah is eight days. (The commentaries in the Mishna are believed to date back ca. 2nd Century CE)
The Sages taught in a baraita: The basic mitzva of Hanukkah is each day to have a light kindled by a person, the head of the household, for himself and his household. And the mehadrin, i.e., those who are meticulous in the performance of mitzvot, kindle a light for each and every one in the household. And the mehadrin min hamehadrin, who are even more meticulous, adjust the number of lights daily. Beit Shammai and Beit Hillel disagree as to the nature of that adjustment. Beit Shammai say: On the first day one kindles eight lights and, from there on, gradually decreases the number of lights until, on the last day of Hanukkah, he kindles one light. And Beit Hillel say: On the first day one kindles one light, and from there on, gradually increases the number of lights until, on the last day, he kindles eight lights.
The Amoraim (later ancient rabbis) used what was stated in the Mishna to create Halacha on how we should light candles at home to mark Chanukah. (The Gemara portion of the Talmud is believed to have been compiled ca. 7th Century CE)
By the time we get to the Shulchan Arukh, the Halacha is more clear about how many candles to light each night of Chanukah. (Authored ca 16th Century)