The longer the beans stay inside roasting machine, the more flavor it develop and the darker it get. On the contrary, the longer means the shorter time before the beloved and hard produced coffee turns to a worthless charcoal.
Roasting coffee can be as simple as boiling a fresh egg and can be as complicated as cooking kare-kare for a five star hotel, a champagne or a Japanese sushi. It requires a well trained judgement skill and or a very sophisticated machine.
I think the very first basis of coffee degree of roast is the color. The roast names were derived on varying degree of darkness / lightness. The light roast, medium roast, dark roast, very dark roast and the charcoal roast in case you let the beans reached its limit. The rare flame roast is a result of complete negligence and it can burn the whole factory as well.
Time frame is a popular connotation in recipes. Simmer for 15 minutes, boil for 30 minutes. The same rule is true to coffee roasting. Roast for 15 minutes or until the desired color is reached.
The more scientific way is the time, temperature and color combination. Commercial coffee roasting machines are equipped with temperature control/sensor and a small glass window for color monitoring. Time factor is human responsibility.
Roasting maybe carried out by: The roaster is pre-heated to desired temperature. Measured amount of beans are loaded. Continues heat bring up the temperature again to desired level. Maintained until the specified time. Beans ejected and cooled immediately.
Or: A modification …. After the beans are loaded, the beans must reach a certain temperature for a specified time frame. A more strict rule the above.
To make things more techie, an electronic eye and chip can be installed to roasting machine. It monitor temperature, time and color. Stop the process and eject the beans when the set criteria are met.