While I do agree with the hardcoding when it comes to specific content, I don't think the same can be said for the top level stuff. Their game cycle executes a series of tasks which you can reverse engineer to an extent with some ingame testing. For example, I was able to figure this one out by asking questions to people who know the osrs game cycle well and by performing some tests on my own. I now have an idea how the queue system works for tasks.
That was the main goal of this question: figuring out the behavior of the task queue based on a complicated test case. I don't really care about tick eating specifically
---------------
Here's the conclusion for melee tick eating where T is the tick the NPC hits you on if anyone's curious:
Between T-2 and T-1: Equip mind shield and stack 2 interfaces (ex: 2 unavailable prayers)
T-1 : High priority stall for equiping the shield added to queue, so the 2 interfaces are queued instead of being executed
T : Mind shield stall end, melee hit is queued after the 2 stacked interfaces, first interface task runs, queue end
Between T and T+1: Eat is queued
T+1: eat is procesed and then second interface task runs, queue end
T+2: hit is processed after closing the second interface (since high priority tasks can close interfaces)
Also works fine if you delay everything by 1 tick. Only hardcoded thing seems to be the number of stacked interfaces being limited to 2 for chatbox dialogues.